I am trying to check that my function returns Some(x)
testedFunc() |> should be (sameAs Some)
testedFunc() |> should be Some
testedFunc() |> should equal Some
All don’t work. I’d rather not use:
match testedFunc() with
| Some -> Pass()
| None -> Fail()
Anyone know of a way to do this?
I haven’t really used FsUnit, but something like this should work…
Or because an Option already has an IsSome property, you could do this, but be careful of case – it’s different from the
Option.isSomefunction.A third approach would be to compose together the function you’re testing with
Option.isSometo get a function that returns boolean directly. This isn’t so useful in this example, but if you need to test an Option-returning function several times with a variety of inputs, this approach could help reduce duplicate code.