I'm using Ookii.CommandLine (yay!) as well as some internal command line processing of the values after they've passed through Ookii.CommandLine.

I want to add some unit tests that will allow us to show that we correctly respond to invalid data on the command line, but I am hoping to do this by building the array of args from a single string, NOT by manually populating the args themselves.  i.e. I want to create a bunch of unit tests to do this:

string[] args = "-Arg1 argvalue1 -Arg2 argvalue2".Split();

CommandLineParser.Parse(args);

not this:

string[] args = {"-Arg1", "argvalue1", "-Arg2", "argvalue2"};

CommandLineParser.Parse(args);

 

I want to do this because there is some crafty processing that is handled by cmd.exe when the app is run and I'd like to know that if the user intermixes quotes or other special characters in the argument list, we handle it correctly (or fail gracefully).  Further, this will satisfy a security requirement that we attempted to address being 'hacked' by a malicious user into behaving badly through crazy command line arguments.

Does anyone know how to mimic the same processing done by cmd.exe so that I can get the arguments returned in args?