night-light/NightLight.Core.Tests/Arbitraries.fs
Sven van Heugten c8e1f0c9fe Make sure that the first interaction sets the time
This is what happens in the `NightLight` program as well.
2026-01-04 19:41:34 +01:00

29 lines
1 KiB
FSharp

namespace NightLight.Core.Tests
open System
open FsCheck
open FsCheck.FSharp
open NightLight.Core.Models
type Arbitraries =
static member Interactions() : Arbitrary<Interaction list> =
gen {
let genTimeChangedInteraction =
gen {
let! time = ArbMap.defaults |> ArbMap.generate<DateTime>
return Interaction.TimeChanged time
}
let genHumanInteraction =
gen {
let! light = Gen.elements lights
let! humanInteraction = Gen.elements [ LightTurnedOn light; LightTurnedOff light ]
return Interaction.HumanInteraction humanInteraction
}
let! initialTimeChangedInteraction = genTimeChangedInteraction
let! remainingInteractions = Gen.oneof [ genTimeChangedInteraction; genHumanInteraction ] |> Gen.listOf
return initialTimeChangedInteraction :: remainingInteractions
}
|> Arb.fromGen