Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moodmosaic/cb1a4a8310f1da0c206e to your computer and use it in GitHub Desktop.
Save moodmosaic/cb1a4a8310f1da0c206e to your computer and use it in GitHub Desktop.
ReturnValueMustNotBeNullAssertionScenarios
namespace ReturnValueMustNotBeNullAssertionScenarios
open FsCheck
open Ploeh.AutoFixture.Idioms.FsCheck
open Ploeh.AutoFixture.Kernel
open Ploeh.AutoFixture.Xunit
open System
open Xunit.Extensions
type Generators =
static member Version() =
Arb.generate<byte>
|> Gen.map int
|> Gen.four
|> Gen.map (fun (ma, mi, bu, re) -> Version(ma, mi, bu, re))
|> Arb.fromGen
module Foo =
let bar (s : string, v : Version) =
match v.Major with
| ma when v.Major > 10 -> null
| _ -> Version(v.Major, v.Minor + 1, v.Build, v.Revision)
[<Theory; AutoDataAttribute>]
let ``bar query must not be null`` (builder : ISpecimenBuilder) =
Arb.register<Generators>() |> ignore
let methodInfo = bar.GetType().DeclaringType.GetMethod("bar")
ReturnValueMustNotBeNullAssertion(builder).Verify(methodInfo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment