public void Update_SingleRegisteredKeyPressed_InputHandlerGetNotification() { 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(); handlerMock.Verify(o => o.HandleInput(It.IsAny<CommandKeys>()), Times.Once); }
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); }
protected override void Initialize() { base.Initialize(); screen = new Screen(Registry.TypeRegistry.ResolveType<ScreenConstants>(), GraphicsDevice); GuiManager = Registry.TypeRegistry.ResolveType<GUIManager>(); input = Registry.TypeRegistry.ResolveType<InputComponent>(); Window.ClientSizeChanged += delegate { screen.WindowsResizeHandler(Window.ClientBounds.Width, Window.ClientBounds.Height); }; screen.WindowsResizeHandler(Window.ClientBounds.Width, Window.ClientBounds.Height); Registry.StartModule("GameEngine", this); Registry.StartModule(startModule, this); if (Graphic == null) throw new InvalidOperationException("Graphic component is not set"); Graphic.Setup(); GuiManager.Setup(); }
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); }
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); }