Esempio n. 1
0
File: Tests.cs Progetto: kurtaj/CLAP
        public void RegisterParameterHandler_CallsTheHandler_UseTheValue()
        {
            var printer = new Printer();
            var sample = new Sample_02 { Printer = printer };

            var debug = String.Empty;

            var p = new Parser<Sample_02>();
            p.RegisterParameterHandler<string>("debug", str => debug = str);

            p.Run("print /c=5 /msg=test /prefix=hello_ /debug=true".Split(' '), sample);

            Assert.AreEqual("true", debug);
        }
Esempio n. 2
0
File: Tests.cs Progetto: kurtaj/CLAP
        public void _Help_WithEverything_Coverage()
        {
            var p = new Parser<Sample_10>();

            p.RegisterParameterHandler("param", delegate { }, "description");

            p.GetHelpString();
        }
Esempio n. 3
0
File: Tests.cs Progetto: kurtaj/CLAP
        public void RegisterParameterHandler_CallsTheHandler_IgnoreTheValue()
        {
            var printer = new Printer();
            var sample = new Sample_02 { Printer = printer };

            int x = 0;

            var p = new Parser<Sample_02>();

            // with and without description for coverage
            //
            p.RegisterParameterHandler("dec", delegate { x--; });
            p.RegisterParameterHandler("inc", delegate { x++; }, "description");

            p.Run("print /c=5 /msg=test /prefix=hello_ /inc".Split(' '), sample);

            Assert.AreEqual(1, x);

            p.Run("print /c=5 /msg=test /prefix=hello_ /dec".Split(' '), sample);

            Assert.AreEqual(0, x);
        }