Пример #1
0
        public void RegisterHandlerAlreadyRegistered_ThrowsException()
        {
            var repeatHandler = new TestInputHandler();

            _inputBinderComponent.RegisterInputHandler(repeatHandler);
            Assert.Throws <InvalidInputHandlerException>(() => _inputBinderComponent.RegisterInputHandler(repeatHandler));
        }
Пример #2
0
        public void Analog_WrongBinding_Unhandled()
        {
            var inputHandler = new TestInputHandler();

            inputHandler.AddAnalogResponse
            (
                EInputKey.Interact, analogValue => EInputHandlerResult.Handled
            );

            Assert.AreEqual(inputHandler.HandleAnalogInput(EInputKey.HorizontalAnalog, 0.0f), EInputHandlerResult.Unhandled);
            inputHandler.ClearResponses();
        }
Пример #3
0
        public void Button_WrongBinding_Unhandled()
        {
            var inputHandler = new TestInputHandler();

            inputHandler.AddButtonResponse
            (
                EInputKey.Interact, pressed => EInputHandlerResult.Handled
            );

            Assert.AreEqual(inputHandler.HandleButtonInput(EInputKey.HorizontalAnalog, false), EInputHandlerResult.Unhandled);
            inputHandler.ClearResponses();
        }
Пример #4
0
        public void Mouse_WrongBinding_Unhandled()
        {
            var inputHandler = new TestInputHandler();

            inputHandler.AddMouseResponse
            (
                EInputKey.Interact, mousePosition => EInputHandlerResult.Handled
            );

            Assert.AreEqual(inputHandler.HandleMouseInput(EInputKey.HorizontalAnalog, new Vector3()), EInputHandlerResult.Unhandled);
            inputHandler.ClearResponses();
        }
Пример #5
0
        public void Analog_BindingHandles_Handled()
        {
            var             inputHandler     = new TestInputHandler();
            const EInputKey expectedInputKey = EInputKey.Interact;

            inputHandler.AddAnalogResponse
            (
                expectedInputKey, analogValue => EInputHandlerResult.Handled
            );

            Assert.AreEqual(inputHandler.HandleAnalogInput(expectedInputKey, 0.0f), EInputHandlerResult.Handled);
            inputHandler.ClearResponses();
        }
Пример #6
0
        public void Button_BindingDoesNotHandle_Unhandled()
        {
            var             inputHandler     = new TestInputHandler();
            const EInputKey expectedInputKey = EInputKey.Interact;

            inputHandler.AddButtonResponse
            (
                expectedInputKey, pressed => EInputHandlerResult.Unhandled
            );

            Assert.AreEqual(inputHandler.HandleButtonInput(expectedInputKey, false), EInputHandlerResult.Unhandled);
            inputHandler.ClearResponses();
        }
Пример #7
0
        public void Mouse_BindingDoesNotHandle_Unhandled()
        {
            var             inputHandler     = new TestInputHandler();
            const EInputKey expectedInputKey = EInputKey.Interact;

            inputHandler.AddMouseResponse
            (
                expectedInputKey, mousePosition => EInputHandlerResult.Unhandled
            );

            Assert.AreEqual(inputHandler.HandleMouseInput(expectedInputKey, new Vector3()), EInputHandlerResult.Unhandled);
            inputHandler.ClearResponses();
        }
Пример #8
0
        public void Analog_NoBinding_Unhandled()
        {
            var inputHandler = new TestInputHandler();

            Assert.AreEqual(inputHandler.HandleAnalogInput(EInputKey.HorizontalAnalog, 0.0f), EInputHandlerResult.Unhandled);
        }
Пример #9
0
        public void Button_NoBinding_Unhandled()
        {
            var inputHandler = new TestInputHandler();

            Assert.AreEqual(inputHandler.HandleButtonInput(EInputKey.HorizontalAnalog, false), EInputHandlerResult.Unhandled);
        }
Пример #10
0
        public void Mouse_NoBinding_Unhandled()
        {
            var inputHandler = new TestInputHandler();

            Assert.AreEqual(inputHandler.HandleMouseInput(EInputKey.HorizontalAnalog, new Vector3()), EInputHandlerResult.Unhandled);
        }
Пример #11
0
        public void RegisterNullHandler_ThrowsException()
        {
            TestInputHandler nullHandler = null;

            Assert.Throws <InvalidInputHandlerException>(() => _inputBinderComponent.RegisterInputHandler(nullHandler));
        }