Skip to content

Instantly share code, notes, and snippets.

@stephen-swensen
Created April 12, 2012 12:09
Show Gist options
  • Save stephen-swensen/2366849 to your computer and use it in GitHub Desktop.
Save stephen-swensen/2366849 to your computer and use it in GitHub Desktop.
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