Ejemplo n.º 1
0
        public async Task NewKMapCommandHandlerExecuteThrowsForExistingKeyMap()
        {
            var command = new NewKMapCommand { Args = "dummyKeyMap" };
            var commandHandler = new NewKMapCommandHandler(this.keyMapService);
            (await commandHandler.Execute(command)).Should().BeTrue();

            Func<Task> action = async () => await commandHandler.Execute(command);
            action.ShouldThrow<ArgumentException>();
        }
Ejemplo n.º 2
0
        public async Task NewKMapCommandHandlerExecuteShouldCreateANewKeyMapWithDefinedTopKey()
        {
            var command = new NewKMapCommand { Args = "dummyKeyMap" };
            var commandHandler = new NewKMapCommandHandler(this.keyMapService);
            var result = await commandHandler.Execute(command);
            result.Should().BeTrue();

            var keyMap = this.keyMapService.GetKeyMapByName("dummyKeyMap");
            keyMap.Should().NotBeNull();
            keyMap.TopKey.ShouldBeEquivalentTo(Keys.None);
        }
Ejemplo n.º 3
0
        public async Task DelKMapCommandHandlerExecuteShouldDeleteAKeyMapWithGivenName()
        {
            var delkmapHandler = new DelKMapCommandHandler(this.keyMapService);
            var newkmapHandler = new NewKMapCommandHandler(this.keyMapService);
            (await newkmapHandler.Execute(new NewKMapCommand { Args = "dummyKeyMap" })).Should().BeTrue();

            var result = await delkmapHandler.Execute(new DelKMapCommand { Args = "dummyKeyMap" });
            result.Should().BeTrue();

            var getKeyMap = new Action(() => this.keyMapService.GetKeyMapByName("dummyKeyMap"));
            getKeyMap.ShouldThrow<KeyNotFoundException>();
        }
Ejemplo n.º 4
0
 public async Task NewKMapCommandHandlerExecuteShouldReturnFalseForCommandWithoutArguments()
 {
     var command = new NewKMapCommand { Args = null };
     var commandHandler = new NewKMapCommandHandler(this.keyMapService);
     (await commandHandler.Execute(command)).Should().BeFalse();
 }