public void ValidateCommandWithFewerArguments()
 {
     ConsoleCommands commands = new ConsoleCommands(_commandConfigs);
       string[] commandRawData = { "move", "top" };
       CommandValidationStatus validationStatus = commands.Validate(commandRawData);
       Assert.IsTrue(validationStatus == CommandValidationStatus.InvalidNumberOfArguments);
 }
Example #2
0
 static ConsoleCommands InitializeCommands()
 {
     Console.Write("Initialize collection of commands... ");
       IList<ConsoleCommandConfig> commandConfigs = ResourceHelper.LoadConsoleCommandConfigs();
       var console = new ConsoleCommands(commandConfigs);
       Console.WriteLine(console != null ? "DONE" : "FAIL");
       return console;
 }
 public void ParseUnknownCommand()
 {
     ConsoleCommands commands = new ConsoleCommands(_commandConfigs);
       string[] commandRawData = { "qwerty", null };
       ConsoleCommand command = commands.Parse(commandRawData);
       Assert.IsTrue(
     command.Name == CommandName.Unknown &&
     command.ValidationStatus == CommandValidationStatus.CommandNotFound);
 }
 public void ParseEmptyCommand()
 {
     ConsoleCommands commands = new ConsoleCommands(_commandConfigs);
       string[] commandRawData = { };
       ConsoleCommand command = commands.Parse(commandRawData);
       Assert.IsTrue(
     command.Name == CommandName.Unknown &&
     command.ValidationStatus == CommandValidationStatus.Unvalidated);
 }
 public void ParseValidCommand()
 {
     ConsoleCommands commands = new ConsoleCommands(_commandConfigs);
       string[] commandRawData = { "move", "top", "4" };
       ConsoleCommand command = commands.Parse(commandRawData);
       Assert.IsTrue(
     command.Name == CommandName.Move &&
     command.Call == CommandCall.External &&
     command.ValidationStatus == CommandValidationStatus.Ok &&
     command.Arguments.Length == 2 && command.Arguments[0] == "top" && command.Arguments[1] == "4");
 }
 public void ValidateCommandWithInvalidTextArguments()
 {
     ConsoleCommands commands = new ConsoleCommands(_commandConfigs);
       string[] commandRawData = { "move", "qwerty", "12345" };
       CommandValidationStatus validationStatus = commands.Validate(commandRawData);
       Assert.IsTrue(validationStatus == CommandValidationStatus.ArgumentHasInvalidValue);
 }
 public void ValidateUnknownCommand()
 {
     ConsoleCommands commands = new ConsoleCommands(_commandConfigs);
       string[] commandRawData = { "unknownCommand", "12345" };
       CommandValidationStatus validationStatus = commands.Validate(commandRawData);
       Assert.IsTrue(validationStatus == CommandValidationStatus.CommandNotFound);
 }
 public void ValidateNullCommand()
 {
     ConsoleCommands commands = new ConsoleCommands(_commandConfigs);
       string[] commandRawData = null;
       CommandValidationStatus validationStatus = commands.Validate(commandRawData);
       Assert.IsTrue(validationStatus == CommandValidationStatus.Unvalidated);
 }
 public void ValidateCommandWithOutOfRangeNumericArguments()
 {
     ConsoleCommands commands = new ConsoleCommands(_commandConfigs);
       string[] commandRawData = { "move", "right", "123" };
       CommandValidationStatus validationStatus = commands.Validate(commandRawData);
       Assert.IsTrue(validationStatus == CommandValidationStatus.ArgumentHasInvalidValue);
 }
 public void ValidateCommandWithoutArguments()
 {
     ConsoleCommands commands = new ConsoleCommands(_commandConfigs);
       string[] commandRawData = { "exit" };
       CommandValidationStatus validationStatus = commands.Validate(commandRawData);
       Assert.IsTrue(validationStatus == CommandValidationStatus.Ok);
 }
Example #11
0
 public ConsoleClient(ConsoleCommands commands, ConsoleClientCommunicator communicator)
 {
     _commands = commands;
       _communicator = communicator;
 }