예제 #1
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");
        }
예제 #2
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();
        }
예제 #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();
        }
예제 #4
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();
        }