Introduce ArbitraryInteractions

This commit is contained in:
Sven van Heugten 2026-01-16 21:49:38 +01:00
parent d278b5d8ea
commit 8866053172
2 changed files with 33 additions and 33 deletions

View file

@ -95,3 +95,7 @@ let ensureLastRemoteInteractionIs
interactions
else
interactions @ [ RemoteInteraction desiredLastRemoteInteraction ])
type ArbitraryInteractions() =
static member Interactions() =
genInteractions |> ensureStartsWithTimeChanged |> Arb.fromGen

View file

@ -25,10 +25,8 @@ type NightLightTests() =
fakeHome
[<Property>]
let ``All lights should either be off or have the right color`` () =
genInteractions |> ensureStartsWithTimeChanged |> Arb.fromGen |> Prop.forAll
<| fun interactions ->
[<Property(Arbitrary = [| typeof<ArbitraryInteractions> |])>]
let ``All lights should either be off or have the right color`` (interactions: Interaction list) =
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
let partOfDay = getPartOfDayAfterInteractions interactions
@ -44,10 +42,8 @@ type NightLightTests() =
|> Prop.trivial (fakeHome.LightsThatAreOn.Length = 0)
|> Prop.collect $"{fakeHome.LightsThatAreOn.Length} light(s) on"
[<Property>]
let ``All non-remotely controlled lights that have power should be on`` () =
genInteractions |> ensureStartsWithTimeChanged |> Arb.fromGen |> Prop.forAll
<| fun interactions ->
[<Property(Arbitrary = [| typeof<ArbitraryInteractions> |])>]
let ``All non-remotely controlled lights that have power should be on`` (interactions: Interaction list) =
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
let nonRemotelyControlledLightsWithPower =