Label properties with the state of FakeHome

This commit is contained in:
Sven van Heugten 2026-01-18 07:07:22 +01:00
parent da5f7ea4df
commit e5141d528e
2 changed files with 9 additions and 0 deletions

View file

@ -156,3 +156,8 @@ type FakeHome with
this.LightStates this.LightStates
|> Seq.filter (fst >> _.ControlledWithRemote >> (<>) NonRemote) |> Seq.filter (fst >> _.ControlledWithRemote >> (<>) NonRemote)
|> Seq.toList |> Seq.toList
member this.Label =
this.LightsThatAreOn
|> Seq.map (fun (light, state) -> $"{light.FriendlyName.Get}: {state}")
|> String.concat ", "

View file

@ -38,6 +38,7 @@ type NightLightTests() =
| Night -> color = Red) | Night -> color = Red)
|> Prop.collect partOfDay |> Prop.collect partOfDay
|> Prop.collect $"{fakeHome.LightsThatAreOn.Length} light(s) on" |> Prop.collect $"{fakeHome.LightsThatAreOn.Length} light(s) on"
|> Prop.label fakeHome.Label
|> Prop.trivial (fakeHome.LightsThatAreOn.Length = 0) |> Prop.trivial (fakeHome.LightsThatAreOn.Length = 0)
[<Property(Arbitrary = [| typeof<ArbitraryInteractions> |])>] [<Property(Arbitrary = [| typeof<ArbitraryInteractions> |])>]
@ -55,6 +56,7 @@ type NightLightTests() =
| { Bulb = PaulmannBulb }, On(80uy, Red) -> true | { Bulb = PaulmannBulb }, On(80uy, Red) -> true
| _ -> false) | _ -> false)
|> Prop.collect $"{fakeHome.LightsThatAreOn.Length} light(s) on" |> Prop.collect $"{fakeHome.LightsThatAreOn.Length} light(s) on"
|> Prop.label fakeHome.Label
|> Prop.trivial (fakeHome.LightsThatAreOn.Length = 0) |> Prop.trivial (fakeHome.LightsThatAreOn.Length = 0)
[<Property(Arbitrary = [| typeof<ArbitraryInteractions> |])>] [<Property(Arbitrary = [| typeof<ArbitraryInteractions> |])>]
@ -69,6 +71,7 @@ type NightLightTests() =
nonRemotelyControlledLightsWithPower nonRemotelyControlledLightsWithPower
|> Seq.forall (snd >> _.IsOn) |> Seq.forall (snd >> _.IsOn)
|> Prop.collect $"{nonRemotelyControlledLightsWithPower.Length} non-remotely controlled light(s) with power" |> Prop.collect $"{nonRemotelyControlledLightsWithPower.Length} non-remotely controlled light(s) with power"
|> Prop.label fakeHome.Label
|> Prop.trivial (nonRemotelyControlledLightsWithPower.Length = 0) |> Prop.trivial (nonRemotelyControlledLightsWithPower.Length = 0)
[<Property(Arbitrary = [| typeof<ArbitraryInteractions> |])>] [<Property(Arbitrary = [| typeof<ArbitraryInteractions> |])>]
@ -104,4 +107,5 @@ type NightLightTests() =
|> Prop.collect $"last remote interaction is {maybeLastRemoteInteraction |> Option.map snd}" |> Prop.collect $"last remote interaction is {maybeLastRemoteInteraction |> Option.map snd}"
|> Prop.collect $"{remotelyControlledLightsWithPower.Length} remotely controlled light(s) with power" |> Prop.collect $"{remotelyControlledLightsWithPower.Length} remotely controlled light(s) with power"
|> Prop.classify hasNewDayStartedSinceThen "new day has started since then" |> Prop.classify hasNewDayStartedSinceThen "new day has started since then"
|> Prop.label fakeHome.Label
|> Prop.trivial (remotelyControlledLightsWithPower.Length = 0) |> Prop.trivial (remotelyControlledLightsWithPower.Length = 0)