public void can_handle_flags() { var args = NativeMethods.CommandLineToArgs("/e"); var simple = new SimpleCli(); var result = simple.CliParse(args); Assert.AreEqual(true, result.Successful); Assert.AreEqual(0, result.CliParseMessages.ToList().Count); Assert.AreEqual(false, result.ShowHelp); Assert.AreEqual(true, simple.Flage); }
public void can_parse_single_arguments_by_short_name() { var args = NativeMethods.CommandLineToArgs("/x testname"); var simple = new SimpleCli(); var result = simple.CliParse(args); Assert.AreEqual(true, result.Successful); Assert.AreEqual(0, result.CliParseMessages.ToList().Count); Assert.AreEqual(false, result.ShowHelp); Assert.AreEqual("testname", simple.FieldX); }
public void can_set_default_values() { var args = NativeMethods.CommandLineToArgs("/e"); var simple = new SimpleCli(); var result = simple.CliParse(args); Assert.AreEqual(true, result.Successful); Assert.AreEqual(0, result.CliParseMessages.ToList().Count); Assert.AreEqual(false, result.ShowHelp); Assert.AreEqual(true, simple.Flage); Assert.AreEqual("defaultValue", simple.Fieldc); Assert.AreEqual(22, simple.Fieldf); }
public void can_execute_pre_and_post_methods() { var args = NativeMethods.CommandLineToArgs("-f 1"); var simple = new SimpleCli(); var result = simple.CliParse(args); Assert.AreEqual(true, result.Successful); Assert.AreEqual(0, result.CliParseMessages.Count()); Assert.AreEqual(false, result.ShowHelp); Assert.AreEqual(true, simple.PreParseExecuted); Assert.AreEqual(true, simple.PostParseExecuted); }
public void can_error_when_parsable_is_null() { var args = NativeMethods.CommandLineToArgs("/a"); var simple = new SimpleCli(); simple = null; simple.CliParse(args); }
public void can_error_missing_values() { var args = NativeMethods.CommandLineToArgs("/x"); var simple = new SimpleCli(); var result = simple.CliParse(args); Assert.AreEqual(false, result.Successful); Assert.AreEqual(1, result.CliParseMessages.ToList().Count); Assert.AreEqual(false, result.ShowHelp); }
public void can_map_multiple_shortname_paramaters_provided_together() { // Issue #1 var args = NativeMethods.CommandLineToArgs("-aAdDv"); var simpleCli = new SimpleCli(); var result = simpleCli.CliParse(args); Assert.AreEqual(true, result.Successful); Assert.AreEqual(0, result.CliParseMessages.ToList().Count); Assert.AreEqual(false, result.ShowHelp); Assert.AreEqual(true, simpleCli.Add); Assert.AreEqual(true, simpleCli.All); Assert.AreEqual(true, simpleCli.Delete); Assert.AreEqual(true, simpleCli.Detailed); Assert.AreEqual(true, simpleCli.Verbose); }
public void can_handle_help_arguments() { var args = NativeMethods.CommandLineToArgs("//help"); var simple = new SimpleCli(); var result = simple.CliParse(args); Assert.AreEqual(true, result.Successful); Assert.AreEqual(0, result.CliParseMessages.ToList().Count); Assert.AreEqual(true, result.ShowHelp); args = NativeMethods.CommandLineToArgs("/?"); simple = new SimpleCli(); result = simple.CliParse(args); Assert.AreEqual(true, result.Successful); Assert.AreEqual(0, result.CliParseMessages.ToList().Count); Assert.AreEqual(true, result.ShowHelp); args = NativeMethods.CommandLineToArgs("//help"); simple = new SimpleCli(); result = simple.CliParse(args); Assert.AreEqual(true, result.Successful); Assert.AreEqual(0, result.CliParseMessages.ToList().Count); Assert.AreEqual(true, result.ShowHelp); args = NativeMethods.CommandLineToArgs("-?"); simple = new SimpleCli(); result = simple.CliParse(args); Assert.AreEqual(true, result.Successful); Assert.AreEqual(0, result.CliParseMessages.ToList().Count); Assert.AreEqual(true, result.ShowHelp); args = NativeMethods.CommandLineToArgs("--help"); simple = new SimpleCli(); result = simple.CliParse(args); Assert.AreEqual(true, result.Successful); Assert.AreEqual(0, result.CliParseMessages.ToList().Count); Assert.AreEqual(true, result.ShowHelp); args = NativeMethods.CommandLineToArgs("--help"); simple = new SimpleCli(); result = simple.CliParse(args); Assert.AreEqual(true, result.Successful); Assert.AreEqual(0, result.CliParseMessages.ToList().Count); Assert.AreEqual(true, result.ShowHelp); }
public void can_handle_unrecognised_arguments() { var args = NativeMethods.CommandLineToArgs("/unknownflag testflag"); var simple = new SimpleCli(); var result = simple.CliParse(args); Assert.AreEqual(false, result.Successful); Assert.AreEqual(1, result.CliParseMessages.ToList().Count); Assert.AreEqual(false, result.ShowHelp); }