Re-use getPartOfDayAfterInteractions in an ensure... function
This commit is contained in:
parent
f22f31ee6c
commit
cbc948c005
2 changed files with 4 additions and 11 deletions
|
|
@ -70,15 +70,7 @@ let ensureLightHasPower (light: Light) (genInteractions: Gen<Interaction list>)
|
||||||
let ensurePartOfDayIs (desiredPartOfDay: PartOfDay) (genInteractions: Gen<Interaction list>) =
|
let ensurePartOfDayIs (desiredPartOfDay: PartOfDay) (genInteractions: Gen<Interaction list>) =
|
||||||
genInteractions
|
genInteractions
|
||||||
|> Gen.bind (fun interactions ->
|
|> Gen.bind (fun interactions ->
|
||||||
let maybeActualTime =
|
if getPartOfDayAfterInteractions interactions = desiredPartOfDay then
|
||||||
interactions
|
|
||||||
|> Seq.choose (fun interaction ->
|
|
||||||
match interaction with
|
|
||||||
| Interaction.TimeChanged time -> Some time
|
|
||||||
| _ -> None)
|
|
||||||
|> Seq.tryLast
|
|
||||||
|
|
||||||
if maybeActualTime |> Option.map getPartOfDay = Some desiredPartOfDay then
|
|
||||||
Gen.constant interactions
|
Gen.constant interactions
|
||||||
else
|
else
|
||||||
desiredPartOfDay
|
desiredPartOfDay
|
||||||
|
|
|
||||||
|
|
@ -85,10 +85,11 @@ type NightLightTests() =
|
||||||
(light: Light)
|
(light: Light)
|
||||||
=
|
=
|
||||||
concatGens
|
concatGens
|
||||||
[ genBiasedInteractions light |> ensurePartOfDayIs Night
|
[ genBiasedInteractions light
|
||||||
|
|> ensureStartsWithTimeChanged
|
||||||
|
|> ensurePartOfDayIs Night
|
||||||
genTimeChangedToPartOfDay Day |> Gen.map List.singleton
|
genTimeChangedToPartOfDay Day |> Gen.map List.singleton
|
||||||
genBiasedInteractionsExcept light _.IsRemoteInteraction ]
|
genBiasedInteractionsExcept light _.IsRemoteInteraction ]
|
||||||
|> ensureStartsWithTimeChanged
|
|
||||||
|> ensureLightHasPower light
|
|> ensureLightHasPower light
|
||||||
|> Arb.fromGen
|
|> Arb.fromGen
|
||||||
|> Prop.forAll
|
|> Prop.forAll
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue