Make tests target specific lights when testing
This commit is contained in:
parent
0ddcd17fd4
commit
d57ca23822
5 changed files with 72 additions and 74 deletions
|
|
@ -5,9 +5,9 @@ open NightLight.Core.Models
|
|||
open NightLight.Core.Tests.GenHelpers
|
||||
open NightLight.Core.Tests.TimeChangedGenerators
|
||||
|
||||
let private genHumanInteraction =
|
||||
let private genHumanInteraction biasTowardsLight =
|
||||
let genLightInteraction =
|
||||
Gen.elements lights
|
||||
Gen.oneof [ Gen.constant biasTowardsLight; Gen.elements lights ]
|
||||
|> Gen.bind (fun light -> Gen.elements [ LightPoweredOn light; LightPoweredOff light ])
|
||||
|
||||
let genRemoteInteraction =
|
||||
|
|
@ -16,15 +16,17 @@ let private genHumanInteraction =
|
|||
Gen.oneof [ genLightInteraction; genRemoteInteraction ]
|
||||
|> Gen.map Interaction.HumanInteraction
|
||||
|
||||
let private genInteraction = Gen.oneof [ genTimeChanged; genHumanInteraction ]
|
||||
let private genInteraction biasTowardsLight =
|
||||
Gen.oneof [ genTimeChanged; genHumanInteraction biasTowardsLight ]
|
||||
|
||||
let private genInteractionsListThatStartsWithTimeChanged =
|
||||
[ genTimeChanged |> Gen.map List.singleton; Gen.listOf genInteraction ]
|
||||
let private genInteractionsListThatStartsWithTimeChanged biasTowardsLight =
|
||||
[ genTimeChanged |> Gen.map List.singleton
|
||||
Gen.listOf <| genInteraction biasTowardsLight ]
|
||||
|> concatGens
|
||||
|
||||
let genInitialInteractionsAndEndWith (endsWith: Interaction) =
|
||||
let genInitialInteractionsAndEndWith biasTowardsLight (endsWith: Interaction) =
|
||||
let genNonTrivialList =
|
||||
genInteractionsListThatStartsWithTimeChanged
|
||||
genInteractionsListThatStartsWithTimeChanged biasTowardsLight
|
||||
|> Gen.map (fun lst -> lst @ [ endsWith ])
|
||||
|
||||
match endsWith with
|
||||
|
|
@ -33,5 +35,7 @@ let genInitialInteractionsAndEndWith (endsWith: Interaction) =
|
|||
Gen.frequency [ 1, genTrivialList; 9, genNonTrivialList ]
|
||||
| _ -> genNonTrivialList
|
||||
|
||||
let genInteractionsExcept disqualifier =
|
||||
genInteraction |> Gen.filter (not << disqualifier) |> Gen.listOf
|
||||
let genInteractionsExcept biasTowardsLight disqualifier =
|
||||
genInteraction biasTowardsLight
|
||||
|> Gen.filter (not << disqualifier)
|
||||
|> Gen.listOf
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue