Example #1
0
        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();
        }
Example #2
0
        public void SwitchPlayer_VerifyActionNotCalled()
        {
            var action = new MockAction();
            var state  = CHECK_FOR_WIN();

            StateTests <IGameState>
            .For(state)
            .When(() => state.SwitchPlayer(() => action.Run()))
            .Invoke();

            action.VerifyActionNotCalled();
        }
Example #3
0
        public void Play_VerifyActionCalled()
        {
            var action = new MockAction();
            var state  = PLAY();

            StateTests <IGameState>
            .For(state)
            .When(() => state.Play(() => action.Run()))
            .Invoke();

            action.VerifyActionCalled();
        }
Example #4
0
        public void CheckForWin_VerifyFunctionNotCalled()
        {
            var predicate = new MockFunc <bool>();
            var state     = PLAY();

            StateTests <IGameState>
            .For(state)
            .When(() => state.CheckForWin(() => predicate.Run()))
            .Invoke();

            predicate.VerifyFunctionNotCalled();
        }
Example #5
0
        public void SwitchPlayer_VerifyActionCalled()
        {
            var action = new MockAction();
            var state  = SWITCH_PLAYER();

            StateTests <IGameState>
            .For(state)
            .When(() => state.SwitchPlayer(() => action.Run()))
            .Invoke();

            action.VerifyActionCalled();
        }
Example #6
0
        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();
        }
Example #7
0
        public void Start_ChangeStates()
        {
            var state = PLAY();

            StateTests <IGameState>
            .For(state)
            .When(() => state.CheckForWin(() => new MockFunc <bool>().Run())).TransitionTo(PLAY).And()
            .When(() => state.End()).TransitionTo(PLAY).And()
            .When(() => state.Over()).TransitionTo(PLAY).And()
            .When(() => state.Play(() => new MockAction().Run())).TransitionTo(CHECK_FOR_WIN).And()
            .When(() => state.PlayAgain(() => new MockFunc <bool>().Run())).TransitionTo(PLAY).And()
            .When(() => state.Start()).TransitionTo(PLAY).And()
            .When(() => state.SwitchPlayer(() => new MockAction().Run())).TransitionTo(PLAY)
            .Assert();
        }
Example #8
0
        public void Initialize_ChangeStates()
        {
            var state = INITIALIZE();

            StateTests <IGameState>
            .For(state)
            .When(() => state.CheckForWin(() => new MockFunc <bool>().Run())).TransitionTo(INITIALIZE).And()
            .When(() => state.End()).TransitionTo(INITIALIZE).And()
            .When(() => state.Over()).TransitionTo(INITIALIZE).And()
            .When(() => state.Play(() => new MockAction().Run())).TransitionTo(INITIALIZE).And()
            .When(() => state.PlayAgain(() => new MockFunc <bool>().Run())).TransitionTo(INITIALIZE).And()
            .When(() => state.Start()).TransitionTo(START).And()
            .When(() => state.SwitchPlayer(() => new MockAction().Run())).TransitionTo(INITIALIZE)
            .Assert();
        }
Example #9
0
        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();
        }