Exemplo n.º 1
0
        public void Handle_WhenNull_WhenNoAbsent_NothingDone()
        {
            var handlePresent = new MockAction <string>();
            var option        = Optional <string> .Of(null);

            option.Handle(value => handlePresent.Run(value));

            handlePresent.VerifyActionNotCalled();
        }
Exemplo n.º 2
0
        public void Handle_WhenPresent_WhenNoAbsent_RunPresentAction()
        {
            var handlePresent = new MockAction <string>();
            var option        = Optional <string> .Of("present");

            option.Handle(value => handlePresent.Run(value));

            handlePresent.VerifyActionCalled("present");
        }
Exemplo n.º 3
0
        public void Handle_WhenNull_RunAbsentAction()
        {
            var handlePresent = new MockAction <string>();
            var handleAbsent  = new MockAction();
            var option        = Optional <string> .Of(null);

            option.Handle(value => handlePresent.Run(value), () => handleAbsent.Run());

            handlePresent.VerifyActionNotCalled();
            handleAbsent.VerifyActionCalled();
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        public void Play_VerifyActionCalled()
        {
            var action = new MockAction();
            var state  = PLAY();

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

            action.VerifyActionCalled();
        }
Exemplo n.º 6
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();
        }