public void Parse_KeyValueCommandParser_HandlesSwitchesAndRoutesTheCommandCorrectly() { // Arrange var parser = new KeyValueCommandParser(); var commandName = ""; // Act var param = parser.Parse("ls path \"c:\\ProgramFiles\" filter \"*.csv\" /s /switch", out commandName); var route = _routing.FindRoute(commandName, param); // Assert Assert.AreEqual("ls", commandName); Assert.AreEqual(4, param.Count); // two param and 2 switches Assert.IsNotNull(route); Assert.AreEqual("ls", route.Name); }
public void ExecuteCommand(string command) { if (string.IsNullOrEmpty(command)) { return; } _commandParser.SetRoutes(_commandRouter.GetRoutes()); var commandName = ""; var parameters = _commandParser.Parse(command, out commandName); var route = _commandRouter.FindRoute(commandName, parameters); route.Execute(parameters, _console, _state); }