public void DefineKeyCommandHandlerExecuteThrowsForALowercaseKeySequence() { this.keyMapService.AddKeyMap("testKeyMap"); var commandArg = "testKeyMap t testCommand arg1"; var definekeyHandler = new DefinekeyCommandHandler(this.keyMapService, this.commandService); Func<Task> action = async () => await definekeyHandler.Execute(new DefinekeyCommand { Args = commandArg }); action.ShouldThrow<ArgumentException>() .WithInnerException<ArgumentException>() .And.ParamName.Should().Be("command"); }
public void DefineKeyCommandHandlerExecuteThrowsForNullCommand() { var definekeyHandler = new DefinekeyCommandHandler(this.keyMapService, this.commandService); Func<Task> action = async () => await definekeyHandler.Execute(null); action.ShouldThrow<ArgumentNullException>().And.ParamName.Should().Be("command"); }
public void DefineKeyCommandHandlerExecuteThrowsForInvalidCommandArguments() { this.keyMapService.AddKeyMap("testKeyMap"); var invalidArguments = new[] { string.Empty, null, "a b" }; var definekeyHandler = new DefinekeyCommandHandler(this.keyMapService, this.commandService); foreach (var a in invalidArguments) { var invalidArgument = a; Func<Task> action = async () => await definekeyHandler.Execute(new DefinekeyCommand { Args = invalidArgument }); action.ShouldThrow<ArgumentException>().And.ParamName.Should().Be("command.Args"); } }
public async Task DefineKeyCommandHandlerExecuteRegistersActionForAKeyMap() { this.keyMapService.AddKeyMap("testKeyMap"); var commandArgs = new[] { "testKeyMap T testCommand arg1", "testKeyMap T,Alt testCommand arg1" }; var definekeyHandler = new DefinekeyCommandHandler(this.keyMapService, this.commandService); foreach (var arg in commandArgs) { var commandArg = arg; var keySequence = GetKeysFromString(commandArg.Split(' ')[1]); (await definekeyHandler.Execute(new DefinekeyCommand { Args = commandArg })).Should().BeTrue(); var keymap = this.keyMapService.GetKeyMapByName("testKeyMap"); (await keymap.Execute(keySequence, string.Empty)).Should().BeTrue(); } }