Esempio n. 1
0
        public void can_parse_example_class()
        {
            var args = NativeMethods.CommandLineToArgs("stringValue");

            var simple = new ExampleParsable();
            var result = simple.CliParse(args);
            
            Assert.AreEqual(true, result.Successful);
            Assert.AreEqual(0, result.CliParseMessages.Count());
            Assert.AreEqual(false, result.ShowHelp);

            Assert.AreEqual("stringValue", simple.StringArgument);
            Assert.AreEqual(false, simple.BoolArgument);

            Console.Write(simple.GetHelpInfo());
        }
Esempio n. 2
0
        public void can_map_bool_parameter_with_supplied_value()
        {
            // Issue #1
            var args = NativeMethods.CommandLineToArgs("myString -b false");
            var exampleParsable = new ExampleParsable();
            var result = exampleParsable.CliParse(args);

            Assert.AreEqual(true, result.Successful);
            Assert.AreEqual(0, result.CliParseMessages.ToList().Count);
            Assert.AreEqual(false, result.ShowHelp);

            Assert.AreEqual(false, exampleParsable.BoolArgument);
            Assert.AreEqual("myString", exampleParsable.StringArgument);
        }
Esempio n. 3
0
        public void can_map_named_parameter_with_impliedPosition_out_of_order()
        {
            // Issue #1
            var args = NativeMethods.CommandLineToArgs("-d nonDefault -s myString");
            var exampleParsable = new ExampleParsable();
            var result = exampleParsable.CliParse(args);

            Assert.AreEqual(true, result.Successful);
            Assert.AreEqual(0, result.CliParseMessages.ToList().Count);
            Assert.AreEqual(false, result.ShowHelp);

            Assert.AreEqual("nonDefault", exampleParsable.DefaultedArgument);
            Assert.AreEqual("myString", exampleParsable.StringArgument);
            Assert.AreEqual(false, exampleParsable.BoolArgument);
            Assert.AreEqual(43, exampleParsable.IntArgument);
        }
Esempio n. 4
0
        public void can_map_non_named_parameters_which_match_parameter_name_longname()
        {
            /*
             Passing a value which matches a named parameter.
             It should be interpreted as a value by its ImpliedPosition and not as the named parameter.
            */
            var args = NativeMethods.CommandLineToArgs("boolArgument");
            var exampleParsable = new ExampleParsable();
            var result = exampleParsable.CliParse(args);

            Assert.AreEqual(true, result.Successful);
            Assert.AreEqual(0, result.CliParseMessages.ToList().Count);
            Assert.AreEqual(false, result.ShowHelp);

            Assert.AreEqual("boolArgument", exampleParsable.StringArgument);
            Assert.AreEqual(false, exampleParsable.BoolArgument);
        }