Add a test that verifies that the remote turns on the lights

This commit is contained in:
Sven van Heugten 2026-01-05 23:39:51 +01:00
parent bb7e6d18ce
commit d3c0881c39

View file

@ -23,6 +23,16 @@ type NightLightTests() =
fakeHome
let doesLightHavePowerAfter interactions light =
interactions
|> Seq.choose (fun interaction ->
match interaction with
| HumanInteraction(LightPoweredOff l) when l = light -> Some false
| HumanInteraction(LightPoweredOn l) when l = light -> Some true
| _ -> None)
|> Seq.tryLast
|> Option.defaultValue false
[<Property>]
let ``All lights that are on should be white or yellow during the day`` () =
genTimeChangedToDay
@ -43,6 +53,24 @@ type NightLightTests() =
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
fakeHome.ForAllLightsThatAreOn(fun (_, _, color) -> color = Red)
[<Property>]
let ``After pressing 'On' on the remote, the remotely controlled lights that have power should be on until they are powered off or 'Off' is pressed``
()
=
genInteractionListContaining (HumanInteraction RemotePressedOnButton) (function
| HumanInteraction RemotePressedOffButton -> true
| HumanInteraction(LightPoweredOff l) when l.ControlledWithRemote -> true
| _ -> false)
|> Arb.fromGen
|> Prop.forAll
<| fun interactions ->
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
fakeHome.LightStates
|> Seq.filter (fst >> doesLightHavePowerAfter interactions)
|> Seq.map snd
|> Seq.forall _.IsOn
[<Property>]
let ``After pressing 'Off' on the remote, the remotely controlled lights should stay off until 'On' is pressed``
()