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>(); }
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); }
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>(); }
public async Task NewKMapCommandHandlerExecuteShouldReturnFalseForCommandWithoutArguments() { var command = new NewKMapCommand { Args = null }; var commandHandler = new NewKMapCommandHandler(this.keyMapService); (await commandHandler.Execute(command)).Should().BeFalse(); }