Merge pull request #7 from svenvanheugten/add-more-tests
Add a test that verifies that the remote turns on the lights
This commit is contained in:
commit
9bb16b0935
1 changed files with 28 additions and 0 deletions
|
|
@ -23,6 +23,16 @@ type NightLightTests() =
|
||||||
|
|
||||||
fakeHome
|
fakeHome
|
||||||
|
|
||||||
|
let doesLightHavePowerAfter interactions light =
|
||||||
|
interactions
|
||||||
|
|> Seq.choose (fun interaction ->
|
||||||
|
match interaction with
|
||||||
|
| HumanInteraction(LightPoweredOff l) when l = light -> Some false
|
||||||
|
| HumanInteraction(LightPoweredOn l) when l = light -> Some true
|
||||||
|
| _ -> None)
|
||||||
|
|> Seq.tryLast
|
||||||
|
|> Option.defaultValue false
|
||||||
|
|
||||||
[<Property>]
|
[<Property>]
|
||||||
let ``All lights that are on should be white or yellow during the day`` () =
|
let ``All lights that are on should be white or yellow during the day`` () =
|
||||||
genTimeChangedToDay
|
genTimeChangedToDay
|
||||||
|
|
@ -43,6 +53,24 @@ type NightLightTests() =
|
||||||
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
|
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
|
||||||
fakeHome.ForAllLightsThatAreOn(fun (_, _, color) -> color = Red)
|
fakeHome.ForAllLightsThatAreOn(fun (_, _, color) -> color = Red)
|
||||||
|
|
||||||
|
[<Property>]
|
||||||
|
let ``After pressing 'On' on the remote, the remotely controlled lights that have power should be on until they are powered off or 'Off' is pressed``
|
||||||
|
()
|
||||||
|
=
|
||||||
|
genInteractionListContaining (HumanInteraction RemotePressedOnButton) (function
|
||||||
|
| HumanInteraction RemotePressedOffButton -> true
|
||||||
|
| HumanInteraction(LightPoweredOff l) when l.ControlledWithRemote -> true
|
||||||
|
| _ -> false)
|
||||||
|
|> Arb.fromGen
|
||||||
|
|> Prop.forAll
|
||||||
|
<| fun interactions ->
|
||||||
|
let fakeHome = createFakeHomeWithNightLightAndInteract interactions
|
||||||
|
|
||||||
|
fakeHome.LightStates
|
||||||
|
|> Seq.filter (fst >> doesLightHavePowerAfter interactions)
|
||||||
|
|> Seq.map snd
|
||||||
|
|> Seq.forall _.IsOn
|
||||||
|
|
||||||
[<Property>]
|
[<Property>]
|
||||||
let ``After pressing 'Off' on the remote, the remotely controlled lights should stay off until 'On' is pressed``
|
let ``After pressing 'Off' on the remote, the remotely controlled lights should stay off until 'On' is pressed``
|
||||||
()
|
()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue