night-light/NightLight.Core.Tests/InteractionListGenerators.fs
Sven van Heugten 2da1972b06 Get rid of the [...]AndEndWith helper
I introduced this to test a very specific edge case right after
initialization, but it made all tests harder to read.
2026-01-08 22:30:47 +01:00

35 lines
1.2 KiB
FSharp

module NightLight.Core.Tests.InteractionListGenerators
open FsCheck.FSharp
open NightLight.Core.Models
open NightLight.Core.Tests.GenHelpers
open NightLight.Core.Tests.TimeChangedGenerators
let private genHumanInteraction biasTowardsLight =
let genLightInteraction =
Gen.oneof [ Gen.constant biasTowardsLight; Gen.elements lights ]
|> Gen.bind (fun light -> Gen.elements [ LightPoweredOn light; LightPoweredOff light ])
let genRemoteInteraction =
Gen.elements [ RemotePressedOnButton; RemotePressedOffButton ]
Gen.oneof [ genLightInteraction; genRemoteInteraction ]
|> Gen.map Interaction.HumanInteraction
let private genInteraction biasTowardsLight =
Gen.oneof [ genTimeChanged; genHumanInteraction biasTowardsLight ]
let genInitialInteractions biasTowardsLight =
[ genTimeChanged |> Gen.map List.singleton
Gen.listOf <| genInteraction biasTowardsLight ]
|> concatGens
let genInteractionsExcept biasTowardsLight disqualifier =
genInteraction biasTowardsLight
|> Gen.filter (not << disqualifier)
|> Gen.listOf
let genInitialInteractionsExcept biasTowardsLight disqualifier =
[ genTimeChanged |> Gen.map List.singleton
genInteractionsExcept biasTowardsLight disqualifier ]
|> concatGens