Make sure that the first interaction sets the time
This is what happens in the `NightLight` program as well.
This commit is contained in:
parent
4e6fc6645c
commit
c8e1f0c9fe
1 changed files with 20 additions and 13 deletions
|
|
@ -1,22 +1,29 @@
|
||||||
namespace NightLight.Core.Tests
|
namespace NightLight.Core.Tests
|
||||||
|
|
||||||
open System
|
open System
|
||||||
|
open FsCheck
|
||||||
open FsCheck.FSharp
|
open FsCheck.FSharp
|
||||||
open NightLight.Core.Models
|
open NightLight.Core.Models
|
||||||
|
|
||||||
type Arbitraries =
|
type Arbitraries =
|
||||||
static member Interaction() =
|
static member Interactions() : Arbitrary<Interaction list> =
|
||||||
let genTimeChangedInteraction =
|
gen {
|
||||||
gen {
|
let genTimeChangedInteraction =
|
||||||
let! time = ArbMap.defaults |> ArbMap.generate<DateTime>
|
gen {
|
||||||
return Interaction.TimeChanged time
|
let! time = ArbMap.defaults |> ArbMap.generate<DateTime>
|
||||||
}
|
return Interaction.TimeChanged time
|
||||||
|
}
|
||||||
|
|
||||||
let genHumanInteraction =
|
let genHumanInteraction =
|
||||||
gen {
|
gen {
|
||||||
let! light = Gen.elements lights
|
let! light = Gen.elements lights
|
||||||
let! humanInteraction = Gen.elements [ LightTurnedOn light; LightTurnedOff light ]
|
let! humanInteraction = Gen.elements [ LightTurnedOn light; LightTurnedOff light ]
|
||||||
return Interaction.HumanInteraction humanInteraction
|
return Interaction.HumanInteraction humanInteraction
|
||||||
}
|
}
|
||||||
|
|
||||||
Gen.oneof [ genTimeChangedInteraction; genHumanInteraction ] |> Arb.fromGen
|
let! initialTimeChangedInteraction = genTimeChangedInteraction
|
||||||
|
let! remainingInteractions = Gen.oneof [ genTimeChangedInteraction; genHumanInteraction ] |> Gen.listOf
|
||||||
|
|
||||||
|
return initialTimeChangedInteraction :: remainingInteractions
|
||||||
|
}
|
||||||
|
|> Arb.fromGen
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue