I'm writing F# code and tests in xUnit 1.9.
For normal sync stuff, I simply return unit
and all is well; but now, I'm migrating the sync innards to be async
workflows.
In other words, my simple AAA is getting explicit Async
usage pushed out into it as I refactor the system:
let [<Fact>] ``Can consume using NEventStore InMemory`` () =
let store = NesGateway.createInMemory ()
let finalDirection = playCircuit store |> Async.RunSynchronously // <----- YUCK
test <@ CounterClockWise = finalDirection @>
To remedy this, I want to make the body of the test be async
. However, to the best of my knowledge, xUnit.net only manages methods returning Task
-derived types, and hence I need a safe way of having my async
test body be wrapped suitably for xUnit.net's runner to pick it up and handle it appropriately.
What's the best way to express my above test ?
As part of xUnit 2.2 Beta 3, @Brad Wilson has done the necessary to make it work natively directly. Hence one can now simply write:
let [<Fact>] ``Can consume NEventStore InMemory`` () = async {
let store = NesGateway.createInMemory ()
let! finalDirection = playCircuit store
test <@ CounterClockWise = finalDirection @> }