Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        [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());
        }
Ejemplo n.º 6
0
 public void ShouldThrowInvalidOperationExceptionForInvalidKey()
 {
     Assert.Throws <InvalidOperationException>(() => CommandLookup.GetCommand("X"));
 }
Ejemplo n.º 7
0
        public void ShouldReturnMoveForwardCommandByMoveForwardKey()
        {
            var command = CommandLookup.GetCommand("M");

            Assert.IsInstanceOf(typeof(MoveForwardCommand), command);
        }
Ejemplo n.º 8
0
        public void ShouldReturnSpinRightCommandByRightKey()
        {
            var command = CommandLookup.GetCommand("R");

            Assert.IsInstanceOf(typeof(SpinRightCommand), command);
        }
Ejemplo n.º 9
0
 public void ShouldThrowInvalidOperationExceptionForInvalidPlateauCoordinates()
 {
     Assert.Throws <InvalidOperationException>(() => CommandLookup.GetCommand("X"));
 }