Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        public void can_error_when_parsable_is_null()
        {
            var args = NativeMethods.CommandLineToArgs("/a");

            var simple = new SimpleCli();
            simple = null;
            simple.CliParse(args);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }