Created
November 5, 2014 21:45
-
-
Save moodmosaic/cb1a4a8310f1da0c206e to your computer and use it in GitHub Desktop.
ReturnValueMustNotBeNullAssertionScenarios
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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