public void SendCommand_CommandIsToggleWindow_ShouldNotThrow() { var command = nameof(Command.ToggleWindow); var keyboardCommandService = new KeyboardCommandService(); Action invoke = () => keyboardCommandService.SendCommand(command); invoke.Should().NotThrow(); }
public void SendCommand_CommandIsNotRegisted_KeyNotFoundExceptionIsThrown() { var command = ((Command) new Random().Next(1, Enum.GetValues(typeof(Command)).Length)).ToString(); var keyboardCommandService = new KeyboardCommandService(); Action invoke = () => keyboardCommandService.SendCommand(command); invoke.Should().Throw <KeyNotFoundException>(); }
public void SendCommand_CommandIsNotRegisted_KeyNotFoundExceptionIsThrown() { var command = _fixture.Create <Command>(); var keyboardCommandService = new KeyboardCommandService(); Action invoke = () => keyboardCommandService.SendCommand(command); invoke.Should().Throw <KeyNotFoundException>(); }
public void SendCommand_CommandIsRegistered_HandlerGetsInvoked() { var command = ((Command) new Random().Next(1, Enum.GetValues(typeof(Command)).Length)).ToString(); var handlerCalled = false; var keyboardCommandService = new KeyboardCommandService(); keyboardCommandService.RegisterCommandHandler(command, () => handlerCalled = true); keyboardCommandService.SendCommand(command); handlerCalled.Should().BeTrue(); }
public void SendCommand_CommandIsRegistered_HandlerGetsInvoked() { var command = _fixture.Create <Command>(); var handlerCalled = false; var keyboardCommandService = new KeyboardCommandService(); keyboardCommandService.RegisterCommandHandler(command, () => handlerCalled = true); keyboardCommandService.SendCommand(command); handlerCalled.Should().BeTrue(); }