Esempio n. 1
0
        public void ShortTest2()
        {
            Parser p = new Parser();

            p.AddDefinition(new OptionDefinition()
            {
                IsFlag = true, ShortName = 'a', LongName = "abc"
            });
            p.AddDefinition(new OptionDefinition()
            {
                IsFlag = true, ShortName = 'b', LongName = "bc"
            });
            p.Parse(new string[] { "-ab" });
            Assert.Equal <bool>(true, p.IsOptionDefined("abc"));
            Assert.Equal <bool>(true, p.IsOptionDefined("bc"));
        }
Esempio n. 2
0
 public void ShortTest3()
 {
     Assert.Throws <Exception>(delegate
     {
         Parser p = new Parser();
         p.AddDefinition(new OptionDefinition()
         {
             IsFlag = false, ShortName = 'a', LongName = "abc"
         });
         p.AddDefinition(new OptionDefinition()
         {
             IsFlag = false, ShortName = 'b', LongName = "bc"
         });
         p.Parse(new string[] { "-ab=c" });
         Assert.Equal <bool>(true, p.IsOptionDefined("abc"));
         Assert.Equal <bool>(true, p.IsOptionDefined("bc"));
     });
 }
Esempio n. 3
0
        public void Normal()
        {
            Parser p = new Parser();

            p.AddDefinition(new OptionDefinition()
            {
                IsFlag = true, LongName = "abc"
            });
            p.Parse(new string[] { "--abc" });
            Assert.Equal <bool>(true, p.IsOptionDefined("abc"));
        }
Esempio n. 4
0
        public void GetValue()
        {
            Parser p = new Parser();

            p.AddDefinition(new OptionDefinition()
            {
                IsFlag = false, LongName = "abc"
            });
            p.Parse(new string[] { "--abc=def" });
            Assert.Equal <bool>(true, p.IsOptionDefined("abc"));
            Assert.Equal <string>("def", p.GetOptionStringValue("abc"));
        }
Esempio n. 5
0
 public void UnknownOption()
 {
     Assert.Throws <Exception>(delegate
     {
         Parser p = new Parser();
         p.AddDefinition(new OptionDefinition()
         {
             IsFlag = true, LongName = "abc", IsRequired = true
         });
         p.Parse(new string[] { "--aaa" });
     });
 }
Esempio n. 6
0
        public void ShortTest5()
        {
            Parser p = new Parser();

            p.AddDefinition(new OptionDefinition()
            {
                IsFlag = true, ShortName = '1', LongName = "runonce"
            });
            p.AddDefinition(new OptionDefinition()
            {
                IsFlag = true, ShortName = 'f', LongName = "flag", IsRequired = true
            });
            p.AddDefinition(new OptionDefinition()
            {
                IsFlag = false, ShortName = 'x', LongName = "bcc"
            });
            p.Parse(new string[] { "-1f", "-x=tt" });
            Assert.Equal <bool>(true, p.IsOptionDefined("runonce"));
            Assert.Equal <bool>(true, p.IsOptionDefined("flag"));
            Assert.Equal <string>("tt", p.GetOptionStringValue("bcc"));
        }