示例#1
0
        public void TestEnumAllowedOut()
        {
            var p = new CmdArgsParser <ConfEnumAllowed>();

            Assert.Throws <CmdException>(
                () => p.ParseCommandLine(new[] { "-a", "2" }));
        }
示例#2
0
        public void TestWrongFieldType()
        {
            var p = new CmdArgsParser <ConfWrongFieldType>();

            Assert.Throws <ConfException>(() =>
                                          p.ParseCommandLine(new[] { "-f", "./sadf" }));
        }
示例#3
0
        public void TestFileOk()
        {
            var            p   = new CmdArgsParser <ConfFile>();
            Res <ConfFile> res = p.ParseCommandLine(new[] { "-f", "./asdf" });

            Assert.AreEqual("asdf", res.Args.File.Name);
        }
示例#4
0
        public void TestLongEmptyName()
        {
            var p = new CmdArgsParser <ConfOkOne>();

            Assert.Throws <CmdException>(() =>
                                         p.ParseCommandLine(new[] { "--DEFINE=val" }));
        }
示例#5
0
        public void TestFileDefaultValueOk()
        {
            var p = new CmdArgsParser <ConfFileDefaultValue>();
            Res <ConfFileDefaultValue> r = p.ParseCommandLine(new[] { "-f" });

            Assert.AreEqual("prog.conf", r.Args.File.Name);
        }
示例#6
0
        public void TestAllowedByPredicate()
        {
            var p = new CmdArgsParser <ConfAllowedByPredicate>();

            Assert.Throws <ConfException>(() =>
                                          p.ParseCommandLine(new[] { "-p", "1:3" }));
        }
示例#7
0
        public void TestBadSign()
        {
            var p = new CmdArgsParser <ConfBadSign>();

            Assert.Throws <ConfException>(() =>
                                          p.ParseCommandLine(new[] { "-p", "23:64" }));
        }
示例#8
0
        public void TestRegexIntOk()
        {
            var p = new CmdArgsParser <ConfRegexInt>();
            Res <ConfRegexInt> res = p.ParseCommandLine(new[] { "-b", "208" });

            Assert.AreEqual(208, res.Args.B);
        }
示例#9
0
        public void TestRegexIntBad()
        {
            var p = new CmdArgsParser <ConfRegexInt>();

            Assert.Throws <CmdException>(() =>
                                         p.ParseCommandLine(new[] { "-b", "218" }));
        }
示例#10
0
        public void TestPredicateBadTypeAr()
        {
            var p = new CmdArgsParser <ConfPredicateBadTypeAr>();

            Assert.Throws <ConfException>(() =>
                                          p.ParseCommandLine(new[] { "-b", "25" }));
        }
示例#11
0
        public void TestRegexOk()
        {
            var             p   = new CmdArgsParser <ConfRegex>();
            Res <ConfRegex> res = p.ParseCommandLine(new[] { "-b", "bB1" });

            Assert.AreEqual("bB1", res.Args.B);
        }
示例#12
0
        public void TestPredicateArArBadOne()
        {
            var p = new CmdArgsParser <ConfPredicateArAr>();

            Assert.Throws <CmdException>(() =>
                                         p.ParseCommandLine(new[] { "-b", "25", "1", "12" }));
        }
示例#13
0
        public void TestAllowedBadAllowedByRegex()
        {
            var p = new CmdArgsParser <ConfAllowedBadAllowedByRegex>();

            Assert.Throws <ConfException>(() =>
                                          p.ParseCommandLine(new[] { "-b" }));
        }
示例#14
0
        public void TestBadDefaultByAllowed()
        {
            var p = new CmdArgsParser <ConfBadDefaultByAllowed>();

            Assert.Throws <ConfException>(() =>
                                          p.ParseCommandLine(new[] { "-b" }));
        }
示例#15
0
        public void TestDefNotAllowed()
        {
            var p = new CmdArgsParser <ConfDefNotAllowed>();

            Assert.Throws <ConfException>(() =>
                                          p.ParseCommandLine(new[] { "-p", "1:3" }));
        }
示例#16
0
        public void TestDefErrorUsenoarg()
        {
            var p = new CmdArgsParser <ConfDefErrorUsenoarg>();

            Assert.Throws <ConfException>(() =>
                                          p.ParseCommandLine(new[] { "--deftrue" }));
        }
示例#17
0
        public void TestDefarrayPredicate()
        {
            var p = new CmdArgsParser <ConfDefarrayPredicate>();

            Assert.Throws <ConfException>(() =>
                                          p.ParseCommandLine(new[] { "-p" }));
        }
示例#18
0
        public void TestNegative()
        {
            var        p  = new CmdArgsParser <Conf>();
            Res <Conf> rv = p.ParseCommandLine(new[] { "-s", "-1" });

            Assert.AreEqual(actual: rv.Args.Some, expected: -1);
        }
示例#19
0
        public void TestCantDeser()
        {
            var p = new CmdArgsParser <ConfCantDeser>();

            Assert.Throws <CmdException>(() =>
                                         p.ParseCommandLine(new[] { "-p", "13" }));
        }
示例#20
0
        public void TestIntLongVal()
        {
            var        p  = new CmdArgsParser <Conf>();
            Res <Conf> rv = p.ParseCommandLine(new[] { "-d", "11" });

            Assert.AreEqual(11L, rv.Args.Dummy);
        }
示例#21
0
        public void TestOnlyEq()
        {
            var p = new CmdArgsParser <ConfOkOne>();

            Assert.Throws <CmdException>(() =>
                                         p.ParseCommandLine(new[] { "-D=" }));
        }
示例#22
0
        public void TestChar()
        {
            var            p  = new CmdArgsParser <ConfChar>();
            Res <ConfChar> rv = p.ParseCommandLine(new[] { "-c", "u" });

            Assert.AreEqual(actual: rv.Args.C, expected: 'u');
        }
示例#23
0
        public void TestFileNotExists()
        {
            var p = new CmdArgsParser <ConfFileEx>();

            Assert.Throws <CmdException>(
                () => p.ParseCommandLine(new[] { "-f", "./asdf" }));
        }
示例#24
0
        public void TestStringSpacesEquality()
        {
            var p = new CmdArgsParser <ConfString>();
            Res <ConfString> rv = p.ParseCommandLine(new[] { "-s=value with value" });

            Assert.AreEqual("value with value", rv.Args.S);
        }
示例#25
0
        public void TestFileAllowedValuesBadType()
        {
            var p = new CmdArgsParser <ConfFileAllowedValuesBadType>();

            Assert.Throws <ConfException>(() =>
                                          p.ParseCommandLine(new[] { "-f", "./asdf" }));
        }
示例#26
0
        public void TestDirWrongUrl()
        {
            var p = new CmdArgsParser <ConfDir>();

            Assert.Throws <CmdException>(() =>
                                         p.ParseCommandLine(new[] { "-f", "./asdf:asdf" }));
        }
示例#27
0
        public void TestWrongArgType()
        {
            var p = new CmdArgsParser <ConfWrongArgType>();

            Assert.Throws <ConfException>(() =>
                                          p.ParseCommandLine(new string[] { }));
        }
示例#28
0
        public void TestDirDefaultValueOk()
        {
            var p = new CmdArgsParser <ConfDirDefaultValue>();
            Res <ConfDirDefaultValue> r = p.ParseCommandLine(new[] { "-f" });

            Assert.AreEqual("somename", r.Args.Dir.Name);
        }
示例#29
0
        public void TestFileWrongUrl1()
        {
            var p = new CmdArgsParser <ConfFile>();

            Assert.Throws <CmdException>(() =>
                                         p.ParseCommandLine(new[] { "-f", "./asdf\"" }));
        }
示例#30
0
        public void TestEnumAllowedOk()
        {
            var p = new CmdArgsParser <ConfEnumAllowed>();
            Res <ConfEnumAllowed> res = p.ParseCommandLine(new[] { "-a", "3" });

            Assert.AreEqual(Constraint.Three, res.Args.A);
        }