Exemplo n.º 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"));
 }
Exemplo n.º 2
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"));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            string schema = "bool,int#,double##,string*,stringArray[*]";

            string[]  vargs  = { "-bool", "-int", "10", "-double", System.Math.PI.ToString(), "-string", "hi", "-stringArray", "Hello", "World" };
            Args.Args parser = new Args.Args(schema, vargs);

            Console.WriteLine("bool: {0}", parser.GetBoolean("bool"));
            Console.WriteLine("int: {0}", parser.GetInt("int"));
            Console.WriteLine("double: {0}", parser.GetDouble("double"));
            Console.WriteLine("string: {0}", parser.GetString("string"));

            string[] stringArray = parser.GetStringArray("stringArray");
            for (int i = 0; i < stringArray.Length; i++)
            {
                Console.WriteLine("stringArray {0}: {1}", i, stringArray[i]);
            }

            Console.ReadLine();
        }
Exemplo n.º 4
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"));
        }
Exemplo n.º 5
0
 public void TestSimpleBooleanPresent()
 {
     Args.Args args = new Args.Args("x", new String[] { "-x" });
     Assert.AreEqual(1, args.Cardinality());
     Assert.AreEqual(true, args.GetBoolean("x"));
 }