public void LookupTest() { var configuration = new CommandConfiguration(); configuration.CommandAssemblies.Add(Assembly.GetExecutingAssembly()); var target = new CommandLookup(configuration); var commandRepository = target.Commands; target.Run(commandRepository.First(), new object[]{ "", 4, "de" }); Assert.NotNull(commandRepository); }
public void LookupTest() { var configuration = new CommandConfiguration(); configuration.CommandAssemblies.Add(Assembly.GetExecutingAssembly()); var target = new CommandLookup(configuration); var commandRepository = target.Commands; //target.Run(commandRepository.First(), new object[]{ "", 4, "de" }); //Assert.NotNull(commandRepository); }
public static List <Command> ParseCommandInput(String command) { char[] inputArray = command.ToCharArray(); List <Command> commandList = new List <Command>(); foreach (char character in inputArray) { Command currentCommand = CommandLookup.GetCommand(character.ToString()); commandList.Add(currentCommand); } return(commandList); }
public void MappingTest(string commandLineArguments, ResultState expectedResult, string firstArgumentValue, ParserNotation notation) { // Setup var parser = new CommandParser(notation); var args = parser.Parse(commandLineArguments); var configuration = new CommandConfiguration(); configuration.CommandAssemblies.Add(Assembly.GetExecutingAssembly()); var lookup = new CommandLookup(configuration); var command = lookup.GetCommand(args.First().Key); Assert.NotNull(args); Assert.NotNull(command); // Test var target = new CommandMapper(); var result = target.Map(args.Skip(1), command.Arguments); // Assert Assert.NotNull(result); Assert.True(result.State == expectedResult); Assert.True(firstArgumentValue == null || firstArgumentValue == result?.ResultArguments?.First().ToString()); }
[InlineData("dummysearch -take=10 -language=de", ResultState.MissingArguments, null, ParserNotation.Unix)] // check required arguments public void MappingTest(string commandLineArguments, ResultState expectedResult, string firstArgumentValue, ParserNotation notation) { // Setup var parser = new CommandParser(notation); var args = parser.Parse(commandLineArguments); var configuration = new CommandConfiguration(); configuration.CommandAssemblies.Add(Assembly.GetExecutingAssembly()); var lookup = new CommandLookup(configuration); var command = lookup.GetCommand(args.First().Key); Assert.NotNull(args); Assert.NotNull(command); // Test var target = new CommandMapper(); var result = target.Map(args.Skip(1), command.Arguments); // Assert Assert.NotNull(result); Assert.True(result.State == expectedResult); Assert.True(firstArgumentValue == null || firstArgumentValue == result?.ResultArguments?.First().ToString()); }
public void ShouldThrowInvalidOperationExceptionForInvalidKey() { Assert.Throws <InvalidOperationException>(() => CommandLookup.GetCommand("X")); }
public void ShouldReturnMoveForwardCommandByMoveForwardKey() { var command = CommandLookup.GetCommand("M"); Assert.IsInstanceOf(typeof(MoveForwardCommand), command); }
public void ShouldReturnSpinRightCommandByRightKey() { var command = CommandLookup.GetCommand("R"); Assert.IsInstanceOf(typeof(SpinRightCommand), command); }
public void ShouldThrowInvalidOperationExceptionForInvalidPlateauCoordinates() { Assert.Throws <InvalidOperationException>(() => CommandLookup.GetCommand("X")); }