public void PlayAgain_VerifyFunctionNotCalled() { var predicate = new MockFunc <bool>(); var state = CHECK_FOR_WIN(); StateTests <IGameState> .For(state) .When(() => state.PlayAgain(() => predicate.Run())) .Invoke(); predicate.VerifyFunctionNotCalled(); }
public void CheckForWin_VerifyFunctionNotCalled() { var predicate = new MockFunc <bool>(); var state = PLAY(); StateTests <IGameState> .For(state) .When(() => state.CheckForWin(() => predicate.Run())) .Invoke(); predicate.VerifyFunctionNotCalled(); }
public void PlayAgain_VerifyFunctionReturnsFalse_StateChangesEnd() { var predicate = new MockFunc <bool>().RunReturns(true); var state = PLAY_AGAIN(); StateTests <IGameState> .For(state) .When(() => state.PlayAgain(() => predicate.Run())) .Invoke(); predicate.VerifyFunctionCalled(); }
public void Start_ChangeStates() { var predicateTrue = new MockFunc <bool>().RunReturns(true); var predicateFalse = new MockFunc <bool>().RunReturns(false); var state = CHECK_FOR_WIN(); StateTests <IGameState> .For(state) .When(() => state.CheckForWin(() => predicateTrue.Run())).TransitionTo(OVER).And() .When(() => state.CheckForWin(() => predicateFalse.Run())).TransitionTo(SWITCH_PLAYER).And() .When(() => state.End()).TransitionTo(CHECK_FOR_WIN).And() .When(() => state.Over()).TransitionTo(CHECK_FOR_WIN).And() .When(() => state.Play(() => new MockAction().Run())).TransitionTo(CHECK_FOR_WIN).And() .When(() => state.PlayAgain(() => new MockFunc <bool>().Run())).TransitionTo(CHECK_FOR_WIN).And() .When(() => state.Start()).TransitionTo(CHECK_FOR_WIN).And() .When(() => state.SwitchPlayer(() => new MockAction().Run())).TransitionTo(CHECK_FOR_WIN) .Assert(); }