Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Demonstrate asserting a function returns Some using Unquote
//here is the function we'd like to test
let testedFunc() = None:option<int>
//here is our Unquote assertion function (using xUnit.net, but can use any unit testing framework such as NUnit)
[<Fact>]
let ``tested func does not return None`` () =
test <@ testedFunc() |> Option.isSome @>
//here is the output from the failing assertion
(*
Test 'TestModule.tested func does not return None' failed:
testedFunc() |> Option.isSome
None |> Option.isSome
false
C:\TestModule.fs(964,0): at TestModule.tested func does not return None()
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment