public virtual void TestOldArgsWithIndex() { string[] arrayArgs = new string[] { "ignore", "-a", "b", "-c" }; { CommandFormat cf = new CommandFormat(0, 9, "a", "c"); IList <string> parsedArgs = cf.Parse(arrayArgs, 0); Assert.Equal(SetOf(), cf.GetOpts()); Assert.Equal(ListOf("ignore", "-a", "b", "-c"), parsedArgs); } { CommandFormat cf = new CommandFormat(0, 9, "a", "c"); IList <string> parsedArgs = cf.Parse(arrayArgs, 1); Assert.Equal(SetOf("a"), cf.GetOpts()); Assert.Equal(ListOf("b", "-c"), parsedArgs); } { CommandFormat cf = new CommandFormat(0, 9, "a", "c"); IList <string> parsedArgs = cf.Parse(arrayArgs, 2); Assert.Equal(SetOf(), cf.GetOpts()); Assert.Equal(ListOf("b", "-c"), parsedArgs); } }
private static CommandFormat CheckArgLimits <T>(Type expectedErr, int min, int max , params string[] opts) { CommandFormat cf = new CommandFormat(min, max, opts); IList <string> parsedArgs = new AList <string>(args); Type cfError = null; try { cf.Parse(parsedArgs); } catch (ArgumentException e) { System.Console.Out.WriteLine(e.Message); cfError = e.GetType(); } Assert.Equal(expectedErr, cfError); if (expectedErr == null) { Assert.Equal(expectedArgs, parsedArgs); Assert.Equal(expectedOpts, cf.GetOpts()); } return(cf); }