コード例 #1
0
        public void ShouldCallCustomValidator()
        {
            var args = new [] { "--stringValue=foo", "-n1" };

            var parser = new OptionsParser(new ParserConfiguration { ThrowValidationException = true });
            var options = new OptionsWithCustomValidator();

            try
            {
                parser.Parse(options, args);
                Assert.Fail("Expected exception");
            }
            catch (ValidationException)
            {
                Assert.AreEqual(1, options.NumericValue);
                Assert.AreEqual("foo", options.StringValue);
            }
        }
コード例 #2
0
        public void ShouldCallCustomValidator()
        {
            var args = new [] { "--stringValue=foo", "-n1" };

            var parser = new OptionsParser(new ParserConfiguration {
                ThrowValidationException = true
            });
            var options = new OptionsWithCustomValidator();

            try
            {
                parser.Parse(options, args);
                Assert.Fail("Expected exception");
            }
            catch (ValidationException)
            {
                Assert.AreEqual(1, options.NumericValue);
                Assert.AreEqual("foo", options.StringValue);
            }
        }