示例#1
0
        public void OnInput(InputEvent inputEvent)
        {
            if (inputEvent.Key.Key != ConsoleKey.Enter)
            {
                return;
            }

            switch (_textBox.Text.ToLower())
            {
            case "reset":
            case "retry":
                _gameFlow.GenerateNewGame();
                _inputReactionCallbacks.HandleReset();
                break;

            case "exit":
                _inputReactionCallbacks.Stop();
                break;

            default:
                HandleShotInput();
                break;
            }

            _textBox.Text      = string.Empty;
            inputEvent.Handled = true;
        }
        public void GenerateNewGame_HasFactoryMethod_FactoryMethodUsed()
        {
            var factoryMethodCalled = false;

            IHandlePlayerInteraction FactoryMethodMock()
            {
                factoryMethodCalled = true;
                return(_interactionHandlerMock.Object);
            }

            var sut = new GameFlowFacade(_boardViewUpdaterMock.Object, FactoryMethodMock);

            sut.GenerateNewGame();

            factoryMethodCalled.Should().BeTrue();
            _boardViewUpdaterMock.Verify(u => u.ResetGame());
        }