public void MultipleUnclaimed() { CommandLineConfiguration config = new CommandLineConfiguration(); config.Add(new CommandLineSwitch() { Name = "file", IsMultiple = true, IsDefaultOption = true }); var result = parser.Parse(new string[] { "f1", "f2", "f3" }, config); Assert.AreEqual(true, result != null); Assert.AreEqual(1, result.Count); Assert.AreEqual(true, result.ContainsKey("file")); CommandLineSwitch item = result["file"]; Assert.AreEqual(true, item != null); Assert.AreEqual(0, item.Index); Assert.AreEqual(null, item.Value); Assert.AreEqual(true, item.Values != null); Assert.AreEqual(3, item.Values.Count); Assert.AreEqual("f1", item.Values[0]); Assert.AreEqual("f2", item.Values[1]); Assert.AreEqual("f3", item.Values[2]); }
public void CommandLineInsideCommandLine() { CommandLineConfiguration config = new CommandLineConfiguration(); config.Add(new CommandLineSwitch() { Name = "exec", IsMultiple = true, IsDefaultOption = true }); var result = parser.Parse(new string[] { "--win", "--log=C:\\temp\\inject.log", "executable.exe", "--param1", "/param2" }, config); Assert.AreEqual(true, result != null); Assert.AreEqual(5, result.Count); Assert.AreEqual(true, result.ContainsKey("win")); CommandLineSwitch item = result["win"]; Assert.AreEqual(true, item != null); Assert.AreEqual(0, item.Index); Assert.AreEqual(null, item.Value); Assert.AreEqual(null, item.Values); Assert.AreEqual(true, result.ContainsKey("log")); item = result["log"]; Assert.AreEqual(true, item != null); Assert.AreEqual(1, item.Index); Assert.AreEqual(@"C:\temp\inject.log", item.Value); Assert.AreEqual(null, item.Values); Assert.AreEqual(true, result.ContainsKey("exec")); item = result["exec"]; Assert.AreEqual(true, item != null); Assert.AreEqual(2, item.Index); Assert.AreEqual(null, item.Value); Assert.AreEqual(true, item.Values != null); Assert.AreEqual(1, item.Values.Count); Assert.AreEqual("executable.exe", item.Values[0]); Assert.AreEqual(true, result.ContainsKey("param1")); item = result["param1"]; Assert.AreEqual(true, item != null); Assert.AreEqual(3, item.Index); Assert.AreEqual(null, item.Value); Assert.AreEqual(null, item.Values); Assert.AreEqual(true, result.ContainsKey("param2")); item = result["param2"]; Assert.AreEqual(true, item != null); Assert.AreEqual(4, item.Index); Assert.AreEqual(null, item.Value); Assert.AreEqual(null, item.Values); }
public void SimpleUnclaimedOption() { CommandLineConfiguration config = new CommandLineConfiguration(); config.Add(new CommandLineSwitch() { Name = "win", }); config.Add(new CommandLineSwitch() { Name = "exec", IsMultiple = true, IsDefaultOption = true, ExpectValue = true, }); var result = parser.Parse(new string[] { "--win", "C:\\temp\\inject.log" }, config); Assert.AreEqual(true, result != null); Assert.AreEqual(2, result.Count); Assert.AreEqual(true, result.ContainsKey("win")); CommandLineSwitch item = result["win"]; Assert.AreEqual(true, item != null); Assert.AreEqual(0, item.Index); Assert.AreEqual(null, item.Value); Assert.AreEqual(null, item.Values); Assert.AreEqual(true, result.ContainsKey("exec")); item = result["exec"]; Assert.AreEqual(true, item != null); Assert.AreEqual(1, item.Index); Assert.AreEqual(null, item.Value); Assert.AreEqual(true, item.Values != null); Assert.AreEqual(1, item.Values.Count); Assert.AreEqual("C:\\temp\\inject.log", item.Values[0]); }
public void SimpleSwitchDoubleDash() { CommandLineConfiguration config = new CommandLineConfiguration(); config.Add(new CommandLineSwitch() { Name = "test", }); var result = parser.Parse(new string[] { "--test" }, config); Assert.AreEqual(true, result != null); Assert.AreEqual(1, result.Count); Assert.AreEqual(true, result.ContainsKey("test")); CommandLineSwitch item = result["test"]; Assert.AreEqual(true, item != null); Assert.AreEqual(0, item.Index); Assert.AreEqual(null, item.Value); Assert.AreEqual(null, item.Values); }
public void OverwriteValue() { CommandLineConfiguration config = new CommandLineConfiguration(); config.Add(new CommandLineSwitch() { Name = "test", ExpectValue = true, }); var result = parser.Parse(new string[] { "-test", "1", "/test=2" }, config); Assert.AreEqual(true, result != null); Assert.AreEqual(1, result.Count); Assert.AreEqual(true, result.ContainsKey("test")); CommandLineSwitch item = result["test"]; Assert.AreEqual(true, item != null); Assert.AreEqual(2, item.Index); Assert.AreEqual("2", item.Value); Assert.AreEqual(null, item.Values); }