-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Domain.Tests.LightTests | ||
|
||
open Domain.Light | ||
open Swensen.Unquote | ||
|
||
type Cases = Off | On | After3Cycles | ||
let establish = function | ||
| Off -> initial | ||
| On -> fold initial [| SwitchedOn |] | ||
| After3Cycles -> [| for _ in 1..3 do SwitchedOn; SwitchedOff |] |> fold initial | ||
|
||
let run cmd state = | ||
let events = decideSwitch cmd state | ||
events, fold state events | ||
|
||
let [<FsCheck.Xunit.Property>] props case cmd = | ||
let state = establish case | ||
let events, state = run cmd state | ||
match case, cmd with | ||
| Off, true -> events =! [| SwitchedOn |] | ||
| Off, false -> events =! [||] | ||
| On, true -> events =! [||] | ||
| On, false -> events =! [| SwitchedOff |] | ||
| After3Cycles, true -> events =! [| Broke |] | ||
| After3Cycles, false -> events =! [||] | ||
|
||
[||] = decideSwitch cmd state // all commands are idempotent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters