Re-use getPartOfDayAfterInteractions in an ensure... function

This commit is contained in:
Sven van Heugten 2026-01-16 21:19:54 +01:00
parent f22f31ee6c
commit cbc948c005
2 changed files with 4 additions and 11 deletions

View file

@ -70,15 +70,7 @@ let ensureLightHasPower (light: Light) (genInteractions: Gen<Interaction list>)
let ensurePartOfDayIs (desiredPartOfDay: PartOfDay) (genInteractions: Gen<Interaction list>) =
genInteractions
|> Gen.bind (fun interactions ->
let maybeActualTime =
interactions
|> Seq.choose (fun interaction ->
match interaction with
| Interaction.TimeChanged time -> Some time
| _ -> None)
|> Seq.tryLast
if maybeActualTime |> Option.map getPartOfDay = Some desiredPartOfDay then
if getPartOfDayAfterInteractions interactions = desiredPartOfDay then
Gen.constant interactions
else
desiredPartOfDay