예제 #1
0
        public void Allow_Help_To_Be_Added()
        {
            // arrange
            var contextBuilder = new ContextBuilder();
            var parser         = new Parser("a");
            var parserBuilder  = new ParserBuilder(contextBuilder, parser);

            parserBuilder.WithBooleanSwitch('h', "help", o => { },
                                            help => { help.SetName("Help").SetShortDescription("Get help"); });

            // act
            // assert
            parser.Parameters.Single().Help.Name.Should().Be("Help");
            parser.Parameters.Single().Help.ShortDescription.Should().Be("Get help");
        }
예제 #2
0
        public void Allow_Boolean_Switches_To_Be_Added()
        {
            // arrange
            var contextBuilder = new ContextBuilder();
            var parser         = new Parser("base");
            var builder        = new ParserBuilder(contextBuilder, parser);
            var parseCount     = 0;

            // act
            builder.WithBooleanSwitch('h', "help", o => parseCount++);

            // assert
            var result = (BooleanSwitch)parser.Parameters.Single();

            result.Letter.Should().Be('h');
            result.Word.Should().Be("help");
        }
예제 #3
0
        public void Allow_Boolean_Switches()
        {
            // arrange
            var contextBuilder = new ContextBuilder();
            var parser0        = new Parser <string>("base");
            var builder0       = new ParserBuilder <string>(contextBuilder, parser0);
            var parser1        = new Parser("base");
            var builder1       = new ParserBuilder(contextBuilder, parser1);

            // act
            builder0.WithBooleanSwitch('h', "help", s => { });
            builder1.WithBooleanSwitch('h', "help", s => { });

            // assert
            builder0.Parser.Parameters.Single().Should().BeAssignableTo <BooleanSwitch <string> >();
            builder1.Parser.Parameters.Single().Should().BeAssignableTo <BooleanSwitch>();
        }