示例#1
0
        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");
        }
示例#2
0
 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");
 }
示例#3
0
 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");
     }
 }
示例#4
0
        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();
            }
        }