Beispiel #1
0
        public void DerivedType()
        {
            bool help = false;
            var  p    = new CiOptionSet()
            {
                { "h|help", v => help = v != null },
            };

            p.Parse(_("-H"));
            Assert.AreEqual(help, true);
            help = false;
            p.Parse(_("-HELP"));
            Assert.AreEqual(help, true);

            Assert.AreEqual(p.GetOptionForName("h"), p [0]);
            Assert.AreEqual(p.GetOptionForName("help"), p [0]);
            Assert.AreEqual(p.GetOptionForName("invalid"), null);

            Assert.That(() => p.Add("N|NUM=", (int n) => {}), Throws.TypeOf <ArgumentException>());
            // Utils.AssertException (typeof(ArgumentException), "prototypes must be null!",
            //      p, v => { v.Add ("N|NUM=", (int n) => {}); });
            Assert.That(() => p.GetOptionForName(null), Throws.TypeOf <ArgumentNullException>());
            // Utils.AssertException (typeof(ArgumentNullException),
            //      "Argument cannot be null.\nParameter name: option",
            //      p, v => { v.GetOptionForName (null); });
        }
        public void DerivedType()
        {
            bool help = false;
            var  p    = new CiOptionSet()
            {
                { "h|help", v => help = v != null },
            };

            p.Parse(_("-H"));
            Assert.AreEqual(help, true);
            help = false;
            p.Parse(_("-HELP"));
            Assert.AreEqual(help, true);

            Assert.AreEqual(p.GetOptionForName("h"), p[0]);
            Assert.AreEqual(p.GetOptionForName("help"), p[0]);
            Assert.AreEqual(p.GetOptionForName("invalid"), null);

            Utils.Assert <ArgumentException>("prototypes must be null!", () => p.Add("N|NUM=", (int n) => { }));
            Utils.AssertArgumentNullException("option", () => p.GetOptionForName(null));
        }