public void Parse_TwoParamsSecondOneEscappedIncorrectlyAndThrowsAnException() { // Arrange var kvParser = new KeyValueCommandParser(); var commandName = ""; // Act var param = kvParser.Parse("ls path c:\\ProgramFiles filter \"*.csv", out commandName); }
public void Parse_WithTwoKeyValueParameters() { // Arrange var kvParser = new KeyValueCommandParser(); var commandName = ""; // Act var param = kvParser.Parse(@"ls path c:\ filter *.csv", out commandName); // Assert Assert.AreEqual(2, param.Count()); Assert.AreEqual("ls", commandName); }
public void Parse_CommandNameOnlyWithTrailingSpace() { // Arrange var kvParser = new KeyValueCommandParser(); var commandName = ""; // Act var param = kvParser.Parse("ls ", out commandName); // Assert Assert.AreEqual(0, param.Count()); Assert.AreEqual("ls", commandName); }
public void Parse_SingleParamIsSplitCorrectly() { // Arrange var kvParser = new KeyValueCommandParser(); var commandName = ""; // Act var param = kvParser.Parse(@"ls path c:\", out commandName); // Assert Assert.AreEqual(1, param.Count()); Assert.AreEqual("path", param.Keys.First()); Assert.AreEqual(@"c:\", param.Values.First()); }
public void Parse_SingleEscappedParam() { // Arrange var kvParser = new KeyValueCommandParser(); var commandName = ""; // Act var param = kvParser.Parse("ls path \"c:\\Program Files\"", out commandName); // Assert Assert.AreEqual(1, param.Count()); Assert.AreEqual("path", param.Keys.First()); Assert.AreEqual("c:\\Program Files", param.Values.First()); }
public void Parse_TwoParamsSecondOneEscapped() { // Arrange var kvParser = new KeyValueCommandParser(); var commandName = ""; // Act var param = kvParser.Parse("ls path c:\\ProgramFiles filter \"*.csv\"", out commandName); // Assert Assert.AreEqual(2, param.Count()); Assert.AreEqual("path", param.Keys.First()); Assert.AreEqual("c:\\ProgramFiles", param.Values.First()); Assert.AreEqual("filter", param.Keys.Skip(1).Take(1).Single()); Assert.AreEqual(@"*.csv", param.Values.Skip(1).Take(1).Single()); }
public void Parse_TwoParamAreSplitCorrectly() { // Arrange var kvParser = new KeyValueCommandParser(); var commandName = ""; // Act var param = kvParser.Parse(@"ls path c:\ filter *.csv", out commandName); // Assert Assert.AreEqual(2, param.Count()); Assert.AreEqual("path", param.Keys.First()); Assert.AreEqual(@"c:\", param.Values.First()); Assert.AreEqual("filter", param.Keys.Skip(1).Take(1).Single()); Assert.AreEqual(@"*.csv", param.Values.Skip(1).Take(1).Single()); }
public void Parse_KeyValueCommandParser_AddsSwitchesToTheParamsCorrectly() { // 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.IsTrue(param.ContainsKey("/s")); Assert.IsTrue(param.ContainsKey("/switch")); Assert.IsNotNull(route); Assert.AreEqual("ls", route.Name); }
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); }