Example #1
0
 public void UndefinekeyCommandHandlerExecuteThrowsForInvalidCommandArgs()
 {
     var invalidArgs = new[] { null, string.Empty, "arg1", "arg1 arg2 arg3", TestKeyMap + " NotAKey" };
     var undefinekeyCommandHandler = new UndefinekeyCommandHandler(this.keyMapService);
     foreach (var invalidArg in invalidArgs)
     {
         var undefinekeyCommand = new UndefinekeyCommand { Args = invalidArg };
         Func<Task> action = async () => await undefinekeyCommandHandler.Execute(undefinekeyCommand);
         action.ShouldThrow<ArgumentException>();
     }
 }
Example #2
0
        public async Task UndefinekeyCommandHandlerExecuteUnregistersAKeySequence()
        {
            var keySequences = new[] { "A", "Control+T", "Control+Shift+Alt+T" };
            var undefinekeyCommandHandler = new UndefinekeyCommandHandler(this.keyMapService);
            var keymap = this.keyMapService.GetKeyMapByName(TestKeyMap);
            foreach (var keySequence in keySequences)
            {
                var undefinekeyCommand = new UndefinekeyCommand { Args = TestKeyMap + " " + keySequence };
                (await undefinekeyCommandHandler.Execute(undefinekeyCommand)).Should().BeTrue();

                var registerKey = new Action(
                    () =>
                        {
                            keymap.RegisterAction((Keys)new KeysConverter().ConvertFrom(keySequence), args => Task.Run(() => true));
                        });
                registerKey.ShouldNotThrow();
            }
        }
Example #3
0
 public void UndefinekeyCommandHasNameAsUndefinekey()
 {
     var undefinekey = new UndefinekeyCommand();
     undefinekey.Name.Should().Be("undefinekey");
 }