コード例 #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();
        }
コード例 #2
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();
        }
コード例 #3
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();
        }
コード例 #4
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();
        }