To always generate valid Quality
and ShelfLife
, you need to register Arbitrary instances:
type Arbs = static member Quality() = Arb.Default.NonNegativeInt() |> Arb.convert (fun (NonNegativeInt x) -> Quality x) (fun (Quality x) -> NonNegativeInt x) static member ShelfLife() = Arb.Default.NonNegativeInt() |> Arb.convert (fun (NonNegativeInt x) -> ShelfLife x) (fun (ShelfLife x) -> NonNegativeInt x)Arb.register<Arbs>()
For the actual property you want to check, here's a rewording that will help translate it to FsCheck: IF Style is not Legendary, THEN after 100 days the quality is 0. In code:
let ``Non-legendary item breaks after 100 days`` (item: Item) = (item.Style <> Legendary) ==> let agedItem = item |> repeat 100 decreaseQuality agedItem.Quality = Quality 0