public void CanCorrectlyDetectAMoveRightKeyPress() { var keyboardInputCollector = default(KeyboardInputCollector); var result = default(ICommand); "Given I have pressed the key to move right on the keyboard".Context(() => { var fakeKeyboardStateCollector = A.Fake<IKeyboardStateCollector>(); A.CallTo(() => fakeKeyboardStateCollector.GetKeyboardState()) .Returns(new KeyboardState(new Keys[] { Keys.Right })); keyboardInputCollector = new KeyboardInputCollector(fakeKeyboardStateCollector, A.Fake<IGameController>()); }); "When I get the controller action".Do(() => result = keyboardInputCollector.Collect()); "Then the action to call move right command should be returned".Observation( () => result.ShouldBeOfType<MoveRightCommand>()); }
public void CanCorrectlyDetectNoKeysPressed() { var keyboardInputCollector = default(KeyboardInputCollector); var result = default(ICommand); "Given I have pressed the key to rotate left on the keyboard".Context(() => { var fakeKeyboardStateCollector = A.Fake<IKeyboardStateCollector>(); KeyboardState keyboardState = new KeyboardState(new Keys[] {}); A.CallTo(() => fakeKeyboardStateCollector.GetKeyboardState()).Returns(keyboardState); keyboardInputCollector = new KeyboardInputCollector(fakeKeyboardStateCollector, A.Fake<IGameController>()); }); "When I get the controller action".Do(() => result = keyboardInputCollector.Collect()); "Then null should be returned".Observation( () => result.ShouldBeNull()); }