示例#1
0
文件: Tests.cs 项目: kurtaj/CLAP
        public void Execute_HandleError_Registered_ValidationError()
        {
            var sample = new ValidationSample_01();

            var p = new Parser<ValidationSample_01>();
            var handled = false;

            p.RegisterErrorHandler(ex =>
            {
                handled = true;
            }, false);

            p.Run(new[] { "morethan5", "/n=1" }, sample);

            Assert.IsTrue(handled);
        }
示例#2
0
文件: Tests.cs 项目: kurtaj/CLAP
        public void Execute_HandleError_Registered_UnhandledParameters()
        {
            var mock = new Mock<IPrinter>();
            var sample = new Sample_02 { Printer = mock.Object };

            var p = new Parser<Sample_02>();

            var handled = false;

            p.RegisterErrorHandler(ex =>
            {
                handled = true;
            }, false);

            p.Run(new[]
            {
                "-count:1",
                "-message:a",
                "-prefix:p",
                "-upper",
                "-what:x"
            }, sample);

            Assert.IsTrue(handled);
        }
示例#3
0
文件: Tests.cs 项目: kurtaj/CLAP
        public void Execute_HandleError_Registered_NoRethrow()
        {
            var p = new Parser<Sample_39>();
            var handled = false;

            p.RegisterErrorHandler(ex =>
            {
                handled = true;
            }, false);

            p.Run(new string[] { });

            Assert.IsTrue(handled);
        }
示例#4
0
文件: Tests.cs 项目: kurtaj/CLAP
        public void Execute_HandleError_Registered_Rethrow()
        {
            var p = new Parser<Sample_39>();
            var handled = false;

            p.RegisterErrorHandler(ex =>
            {
                handled = true;
            }, true);

            try
            {
                p.Run(new string[] { });

                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.IsTrue(handled);
            }
        }
示例#5
0
文件: Tests.cs 项目: kurtaj/CLAP
        public void RegisterError_MoreThanOne_Exception()
        {
            var p = new Parser<Sample_02>();

            p.RegisterErrorHandler(delegate { });
            p.RegisterErrorHandler(delegate { });
        }