public static void UnParsing_instance_with_equal_token_returns_command_line_with_long_option_using_equal_sign()
 {
     var options = new Simple_Options { BoolValue = true, IntSequence = new[] { 1, 2, 3 }, StringValue = "nospaces", LongValue = 123456789 };
     new Parser()
         .FormatCommandLine(options, config => config.UseEqualToken = true)
         .ShouldBeEquivalentTo("-i 1 2 3 --stringvalue=nospaces -x 123456789");
 }
Example #2
0
        public void Parse_options()
        {
            // Fixture setup
            var expectedOptions = new Simple_Options { StringValue = "strvalue", IntSequence = new[] { 1, 2, 3 } };
            var sut = new Parser();

            // Exercize system
            var result = sut.ParseArguments<Simple_Options>(new[] { "--stringvalue=strvalue", "-i1", "2", "3" });

            // Verify outcome
            ((Parsed<Simple_Options>)result).Value.ShouldBeEquivalentTo(expectedOptions);
            // Teardown
        }
        public void Parse_to_mutable()
        {
            // Fixture setup
            var expectedResult = new Simple_Options { StringValue="strval0", IntSequence=new[] { 9, 7, 8 }, BoolValue = true,  LongValue = 9876543210L };

            // Exercize system
            var result = InstanceBuilder.Build(
                Maybe.Just<Func<Simple_Options>>(() => new Simple_Options()),
                new[] { "--stringvalue=strval0", "-i", "9", "7", "8", "-x", "9876543210" },
                StringComparer.Ordinal,
                CultureInfo.InvariantCulture,
                Enumerable.Empty<ErrorType>());

            // Verify outcome
            expectedResult.ShouldBeEquivalentTo(((Parsed<Simple_Options>)result).Value);

            // Teardown
        }
        public void Explicit_help_request_generates_help_requested_error()
        {
            // Fixture setup
            var fakeOptions = new Simple_Options();
            var expectedResult = new NotParsed<Simple_Options>(
                TypeInfo.Create(typeof(Simple_Options)), new Error[] { new HelpRequestedError() });

            // Exercize system
            var result = InstanceBuilder.Build(
                Maybe.Just<Func<Simple_Options>>(() => fakeOptions),
                new[] { "--help" },
                StringComparer.Ordinal,
                CultureInfo.InvariantCulture,
                Enumerable.Empty<ErrorType>());

            // Verify outcome
            result.ShouldBeEquivalentTo(expectedResult);

            // Teardown
        }
 public static void UnParsing_instance_returns_command_line(Simple_Options options, string result)
 {
     new Parser()
         .FormatCommandLine(options)
         .ShouldBeEquivalentTo(result);
 }
Example #6
0
        public void When_IgnoreUnknownArguments_is_set_valid_unknown_arguments_avoid_a_failure_parsing(
            string[] arguments,
            Simple_Options expected)
        {
            // Fixture setup
            var sut = new Parser(config => config.IgnoreUnknownArguments = true);

            // Exercize system
            var result = sut.ParseArguments<Simple_Options>(arguments);

            // Verify outcome
            result.Tag.ShouldBeEquivalentTo(ParserResultType.Parsed);
            result.WithParsed(opts => opts.ShouldBeEquivalentTo(expected));

            // Teardown
        }