예제 #1
0
        public void Update_SingleRegisteredKeyPressedUpdateCalledTwice_InputHandlerGetNotificationOnce()
        {
            var handlerMock = new Mock<IInputHandler>();
            var managerMock = CreateInputManagerFake(keys.First());
            var component = new InputComponent(managerMock, map);

            component.Handler = handlerMock.Object;

            // Assert the that only the first key is detected
            component.Update();
            component.Update();
            handlerMock.Verify(o => o.HandleInput(It.IsAny<CommandKeys>()), Times.Once);
        }
예제 #2
0
        public void Update_MultipleRegistredKeysPressed_AllKeysAreGivenToInputHandler()
        {
            var handlerMock = new Mock<IInputHandler>();
            var managerMock = CreateInputManagerFake(keys.ToArray());
            var component = new InputComponent(managerMock, map);

            component.Handler = handlerMock.Object;


            // Assert that every test key is detected once
            component.Update();
            foreach(var key in keys)
                handlerMock.Verify(o => o.HandleInput(map[key]), Times.Once);
        }
예제 #3
0
        public void Update_SingleUnregistredKeyIsPressed_InputHandlerIsNotCalled()
        {
            // The component should not watch out for D
            var handlerMock = new Mock<IInputHandler>();
            var managerMock = CreateInputManagerFake(Keys.D);
            var component = new InputComponent(managerMock, map);

            component.Handler = handlerMock.Object;


            // Make sure, that no test key was detected
            component.Update();
            handlerMock.Verify(o => o.HandleInput(It.IsAny<CommandKeys>()), Times.Never);
        }
예제 #4
0
        public void Update_OneRegistredAndOneUnregistredKeyArePressed_InputHandlerIsCalledOnce()
        {

            var handlerMock = new Mock<IInputHandler>();
            var managerMock = CreateInputManagerFake(Keys.D, Keys.Down);
            var component = new InputComponent(managerMock, map);

            component.Handler = handlerMock.Object;

            component.Update();

            handlerMock.Verify(o => o.HandleInput(It.IsAny<CommandKeys>()), Times.Once);
            handlerMock.Verify(o => o.HandleInput(map[Keys.Down]), Times.Once);
        }