Skip to content

Latest commit

 

History

History
68 lines (52 loc) · 2.23 KB

fsharp.md

File metadata and controls

68 lines (52 loc) · 2.23 KB

Usage in FSharp

NullValueHandling

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)

snippet source | anchor

Async Qwerks

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 () =
     Verifier.Verify(15).ToTask() |> Async.AwaitTask

snippet source | anchor

Full tests

[<VerifyXunit.UsesVerify>]
module Tests

open Xunit
open VerifyTests
open VerifyXunit
open Newtonsoft.Json

VerifierSettings.AddExtraSettings(fun settings -> settings.NullValueHandling <- NullValueHandling.Include)

[<Fact>]
let MyTest () =
     Verifier.Verify(15).ToTask() |> Async.AwaitTask

[<Fact>]
let WithFluentSetting () =
    Verifier
        .Verify(15)
        .UseMethodName("customName")
        .ToTask()
    |> Async.AwaitTask
do ()

snippet source | anchor