Skip to content

Latest commit

 

History

History
75 lines (56 loc) · 2.44 KB

fsharp.md

File metadata and controls

75 lines (56 loc) · 2.44 KB

Usage in FSharp

Argon ships F# support in a separate nuget Argon.FSharp.

To serialize F# types properly, add the converters:

VerifierSettings.AddExtraSettings(fun settings -> settings.AddFSharpConverters())

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

module Tests

open Xunit
open VerifyTests
open VerifyXunit
open Argon

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