module Snake.Tests.M05Game open Expecto open Snake open Snake.Tests.Fixtures let private replayCase () = List.head (cases "m05-replay") let private start () = gameState (arg 0 (replayCase ())) let private actions () = list action (arg 1 (replayCase ())) [] let tests = testList "M05 Game" [ yield! fixtureTests "m05-update" "update" (fun c -> Expect.equal (Game.update (gameState (arg 0 c)) (action (arg 1 c))) (gameState (expected c)) "update") yield! fixtureTests "m05-replay" "replay" (fun c -> Expect.equal (Game.replay (gameState (arg 0 c)) (list action (arg 1 c))) (gameState (expected c)) "replay") yield! fixtureTests "m05-history" "history" (fun c -> Expect.equal (Game.history (gameState (arg 0 c)) (list action (arg 1 c))) (list gameState (expected c)) "history") testCase "history has one more state than there are actions" (fun () -> Expect.equal (List.length (Game.history (start ()) (actions ()))) (List.length (actions ()) + 1) "length") testCase "history starts at the start state and ends where replay ends" (fun () -> let states = Game.history (start ()) (actions ()) Expect.equal (List.head states) (start ()) "first" Expect.equal (List.last states) (Game.replay (start ()) (actions ())) "last") ]