Example #1
0
        public void Not_Throw_If_An_Unexpected_Argument_Is_Found()
        {
            // arrange
            var builder = DefaultBuilder.CreateDefaultBuilder();
            var strat   = new ParseStrategy(builder.Context);
            var mock    = new Mock <IPotentialConsumerStrategy>();

            mock.SetupAllProperties();
            mock.Setup(s => s.IdentifyPotentialConsumer(It.IsAny <PotentialConsumerRequest>())).Returns(
                new PotentialConsumerResult(builder.Context.PathToRoot("util"), new ConsumptionResult[0],
                                            new IterationInfo("-h".Split(' '))));
            strat.PotentialConsumerStrategy = mock.Object;
            IParseResult res        = null;
            Action       mightThrow = () => res = strat.Parse("-h".Split(' '));

            // act
            // assert
            mightThrow.Should().NotThrow();
            var isParsed = false;

            res.WhenError(exceptions =>
            {
                exceptions.Single().Should().BeOfType <UnexpectedArgException>();
                isParsed = true;
            });
            isParsed.Should().BeTrue();
        }
Example #2
0
        public void Not_Throw_If_No_Factory_Function_Set()
        {
            // arrange
            var builder = new ContextBuilder()
                          .AddParser("root")
                          .Finish;
            var          strat      = new ParseStrategy(builder.Context);
            IParseResult res        = null;
            Action       mightThrow = () => res = strat.Parse("-h".Split(' '));

            // act
            // assert
            mightThrow.Should().NotThrow();
            var isParsed = false;

            res.WhenError(exceptions =>
            {
                isParsed = true;
                exceptions.Single().Should().BeOfType <NoFactoryFunctionException>();
            });
            isParsed.Should().BeTrue();
        }