public void ToArguments() { var testData = new ArgumentsData[] { new ArgumentsData() { CommandLine = null, Arguments = new string[0] }, new ArgumentsData() { CommandLine = "", Arguments = new string[0] }, new ArgumentsData() { CommandLine = " ", Arguments = new string[0] }, new ArgumentsData() { CommandLine = "-ei:utf-8 -eo:utf-8 -warn:4 /G:jQuery -p -z", Arguments = new string[] { "-ei:utf-8", "-eo:utf-8", "-warn:4", "/G:jQuery", "-p", "-z" } }, new ArgumentsData() { CommandLine = "\"foo bar.js\" -out \"c:\\test folder\\foo bar min.js\" ", Arguments = new string[] { "foo bar.js", "-out", "c:\\test folder\\foo bar min.js" } }, new ArgumentsData() { CommandLine = "foo\"bar\"ack", Arguments = new string[] { "foobarack" } }, new ArgumentsData() { CommandLine = "foo \"\"\"\" bar", Arguments = new string[] { "foo", "\"", "bar" } }, new ArgumentsData() { CommandLine = "now \" is the time \" for", Arguments = new string[] { "now", " is the time ", "for" } }, new ArgumentsData() { CommandLine = "now \" is \"\"the\"\" time \" for", Arguments = new string[] { "now", " is \"the\" time ", "for" } }, new ArgumentsData() { CommandLine = "now \"\" \" is \"\"the\"\" time \" for", Arguments = new string[] { "now", "", " is \"the\" time ", "for" } }, }; var ndxTest = 0; foreach (var test in testData) { Trace.Write(string.Format("Parsing test {0}, command line: ", ++ndxTest)); Trace.WriteLine(test.CommandLine ?? "<null pointer>"); var argsActual = SwitchParser.ToArguments(test.CommandLine); var argsExpected = test.Arguments; // assume succesful unless proven otherwise var success = true; Assert.IsTrue(argsActual.Length == argsExpected.Length, "Parsed arguments length {0} not equal to expected arguments length {1}", argsActual.Length, argsExpected.Length); Trace.WriteLine(string.Format(" {0} arguments", argsActual.Length)); for (var ndxArg = 0; ndxArg < argsActual.Length; ++ndxArg) { var theSame = string.CompareOrdinal(argsActual[ndxArg], argsExpected[ndxArg]) == 0; Trace.WriteLine(string.Format(" {0}: {1} {3} {2}", ndxArg + 1, argsActual[ndxArg], argsExpected[ndxArg], theSame ? "==" : "!=")); success = theSame ? success : false; } Assert.IsTrue(success, "TEST {0} FAILED!", ndxTest); } }