Improve types for remote button presses in tests
This commit is contained in:
parent
3913522cc3
commit
1dc1faa16a
4 changed files with 25 additions and 27 deletions
|
|
@ -47,7 +47,7 @@ type NightLightTests() =
|
|||
let time = getTimeAfterInteractions interactions |> _.TimeOfDay
|
||||
|
||||
let alarm =
|
||||
hasNewDayStartedSince interactions (tryGetLastBedroomRemoteInteraction interactions)
|
||||
hasNewDayStartedSince interactions (tryGetLastBedroomControllingRemoteInteraction interactions)
|
||||
&& startOfDay <= time
|
||||
&& time <= endOfAlarm
|
||||
|
||||
|
|
@ -90,15 +90,16 @@ type NightLightTests() =
|
|||
|> Seq.filter (fun (light, _) -> doesLightHavePowerAfterInteractions light interactions)
|
||||
|> Seq.toList
|
||||
|
||||
let lastBedroomRemoteInteraction = tryGetLastBedroomRemoteInteraction interactions
|
||||
let lastBedroomControllingRemoteInteraction =
|
||||
tryGetLastBedroomControllingRemoteInteraction interactions
|
||||
|
||||
let newDayStartedSinceBedroomRemote =
|
||||
hasNewDayStartedSince interactions lastBedroomRemoteInteraction
|
||||
hasNewDayStartedSince interactions lastBedroomControllingRemoteInteraction
|
||||
|
||||
let hasPressedRight =
|
||||
interactions
|
||||
|> Seq.exists (function
|
||||
| Interaction.RemoteInteraction RemotePressedRightButton -> true
|
||||
| Interaction.LivingRoomControllingRemoteInteraction RemotePressedRightButton -> true
|
||||
| _ -> false)
|
||||
|
||||
let isExpectedOn light =
|
||||
|
|
@ -108,11 +109,10 @@ type NightLightTests() =
|
|||
if newDayStartedSinceBedroomRemote then
|
||||
true
|
||||
else
|
||||
match lastBedroomRemoteInteraction with
|
||||
match lastBedroomControllingRemoteInteraction with
|
||||
| Some(_, RemotePressedOffButton) -> false
|
||||
| Some(_, RemotePressedLeftButton) -> light = LeftBedroomLamp
|
||||
| Some(_, RemotePressedOnButton) -> true
|
||||
| Some(_, RemotePressedRightButton) -> failwith "unexpected"
|
||||
| None -> true
|
||||
| LivingRoomWallLamp
|
||||
| LivingRoomFloorLamp -> not hasPressedRight
|
||||
|
|
@ -120,7 +120,8 @@ type NightLightTests() =
|
|||
|
||||
lightsWithPower
|
||||
|> Seq.forall (fun (light, state) -> state.IsOn = isExpectedOn light)
|
||||
|> Prop.collect $"last bedroom remote interaction is {lastBedroomRemoteInteraction |> Option.map snd}"
|
||||
|> Prop.collect
|
||||
$"last bedroom controlling remote interaction is {lastBedroomControllingRemoteInteraction |> Option.map snd}"
|
||||
|> Prop.collect $"pressed right: {hasPressedRight}"
|
||||
|> Prop.collect $"{lightsWithPower.Length} light(s) with power"
|
||||
|> Prop.classify newDayStartedSinceBedroomRemote "new day since bedroom remote"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue