Exemplo n.º 1
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"));
 }
Exemplo n.º 2
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.º 3
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);
        }