By default DefaultValueHandling is Ignore. Since F# Option.None
is treated as null, it will be ignored by default. To include Option.None
use VerifierSettings.AddExtraSettings
at module startup:
VerifierSettings.AddExtraSettings(fun settings ->
settings.NullValueHandling <- NullValueHandling.Include)
F# does not respect implicit operator conversion. SettingsTask
uses implicit operator conversion to provide a fluent api in combination with an instance that can be awaited. As such SettingsTask.ToTask()
needs to be awaited when used inside F#.
[<Fact>]
let MyTest () =
async {
do! Verifier.Verify(15)
.ToTask() |> Async.AwaitTask
}
Tasks can also be used directly via a task
computation expression builder, such as the ones included in Ply, TaskBuilder.fs, or (starting with F# 6.0) FSharp.Core:
[<Fact>]
let MyTaskTest () =
task {
do! Verifier.Verify(15)
}
[<VerifyXunit.UsesVerify>]
module Tests
open Xunit
open VerifyTests
open VerifyXunit
open Newtonsoft.Json
VerifierSettings.AddExtraSettings(fun settings ->
settings.NullValueHandling <- NullValueHandling.Include)
[<Fact>]
let MyTest () =
async {
do! Verifier.Verify(15)
.ToTask() |> Async.AwaitTask
}
[<Fact>]
let MyTaskTest () =
task {
do! Verifier.Verify(15)
}
[<Fact>]
let WithFluentSetting () =
async {
do! Verifier.Verify(15)
.UseMethodName("customName")
.ToTask() |> Async.AwaitTask
}
do ()