Exemple #1
0
 public void TestSpacesInFormat()
 {
     Args.Args args = new Args.Args("x, y", new String[] { "-x", "-y" });
     Assert.AreEqual(2, args.Cardinality());
     Assert.IsTrue(args.Has("x"));
     Assert.IsTrue(args.Has("y"));
     Assert.IsTrue(args.GetBoolean("x"));
     Assert.IsTrue(args.GetBoolean("y"));
 }
Exemple #2
0
 public void TestSimpleStringPresent()
 {
     Args.Args args = new Args.Args("x*", new String[] { "-x", "param" });
     Assert.AreEqual(1, args.Cardinality());
     Assert.IsTrue(args.Has("x"));
     Assert.AreEqual("param", args.GetString("x"));
 }
Exemple #3
0
 public void TestSimpleDoublePresent()
 {
     Args.Args args = new Args.Args("x##", new string[] { "-x", "42.3" });
     Assert.AreEqual(1, args.Cardinality());
     Assert.IsTrue(args.Has("x"));
     Assert.AreEqual(42.3, args.GetDouble("x"), .001);
 }
Exemple #4
0
 public void TestSimpleIntPresent()
 {
     Args.Args args = new Args.Args("x#", new string[] { "-x", "42" });
     Assert.AreEqual(1, args.Cardinality());
     Assert.IsTrue(args.Has("x"));
     Assert.AreEqual(42, args.GetInt("x"));
 }
Exemple #5
0
        public void TestSingleStringArrayWithMultipleArgsPresent()
        {
            Args.Args args = new Args.Args("x[*],l,d#", new String[] { "-x", "param1", "param2", "param3", "-l", "-d", "10" });
            Assert.AreEqual(3, args.Cardinality());
            Assert.IsTrue(args.Has("x"));
            Assert.IsTrue(args.Has("l"));
            Assert.IsTrue(args.Has("d"));

            String[] expected = new String[] { "param1", "param2", "param3" };
            String[] actual   = args.GetStringArray("x");
            for (int i = 0; i < 3; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
            Assert.IsTrue(args.GetBoolean("l"));
            Assert.AreEqual(10, args.GetInt("d"));
        }
Exemple #6
0
        public void TestMultipleStringArrayWithOneWordPresent()
        {
            String[]  expected;
            Args.Args args = new Args.Args("f*,t[*],s[*],b[*]",
                                           new String[] { "-f", "*****@*****.**", "-t", "*****@*****.**", "-s", "Test Email Subject" });

            Assert.AreEqual(3, args.Cardinality());
            Assert.IsTrue(args.Has("f"));
            Assert.IsTrue(args.Has("t"));
            Assert.IsTrue(args.Has("s"));

            Assert.AreEqual("*****@*****.**", args.GetString("f"));
            expected = args.GetStringArray("t");
            Assert.AreEqual("*****@*****.**", expected[0]);

            expected = args.GetStringArray("s");
            Assert.AreEqual("Test Email Subject", expected[0]);

            expected = args.GetStringArray("b");
            Assert.AreEqual(0, expected.Length);
        }
Exemple #7
0
        public void TestSingleStringArrayPresent()
        {
            Args.Args args = new Args.Args("x[*]", new String[] { "-x", "param1", "param2", "param3" });
            Assert.AreEqual(1, args.Cardinality());
            Assert.IsTrue(args.Has("x"));

            String[] expected = new String[] { "param1", "param2", "param3" };
            String[] actual   = args.GetStringArray("x");
            for (int i = 0; i < 3; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
Exemple #8
0
        public void TestMultipleStringArrayWithMultipleArgsSimilarWordsPresent()
        {
            Args.Args args = new Args.Args("x[*],y[*],l", new String[] { "-x", "param1", "param2", "param3", "-y", "param2", "param3", "-l" });
            Assert.AreEqual(3, args.Cardinality());
            Assert.IsTrue(args.Has("x"));
            Assert.IsTrue(args.Has("y"));
            Assert.IsTrue(args.Has("l"));

            String[] expected = new String[] { "param1", "param2", "param3" };
            String[] actual   = args.GetStringArray("x");
            for (int i = 0; i < 3; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }

            expected = new String[] { "param2", "param3" };
            actual   = args.GetStringArray("y");
            for (int i = 0; i < 2; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
            Assert.IsTrue(args.GetBoolean("l"));
        }