Example #1
0
        public void Passing_short_value_to_byte_option_must_fail_gracefully()
        {
            var options = new NumberSetOptions();
            var parser = new Parser();
            var result = parser.ParseArguments(new string[] { "-b", short.MaxValue.ToString(CultureInfo.InvariantCulture) }, options);

            result.Should().BeFalse();
        }
Example #2
0
        public void ParseNegativeIntegerValue_InputStyle2()
        {
            var options = new NumberSetOptions();
            var parser = new Parser();
            var result = parser.ParseArguments(new string[] { "-i-4096" }, options);

            result.Should().BeTrue();
            options.IntegerValue.Should().Be(-4096);
        }
Example #3
0
        public void Parse_negative_floating_point_value_input_style4()
        {
            var options = new NumberSetOptions();
            var parser = new Parser();
            var result = parser.ParseArguments(new string[] { "--double=-4096.1024" }, options);

            result.Should().BeTrue();
            options.DoubleValue.Should().Be(-4096.1024D);
        }
Example #4
0
        public void Passing_no_value_to_a_short_type_long_option_fails()
        {
            var options = new NumberSetOptions();
            var parser = new Parser();
            var result = parser.ParseArguments(new string[] { "--short" }, options);

            result.Should().BeFalse();
        }
Example #5
0
        public void Parse_culture_specific_number()
        {
            //var actualCulture = Thread.CurrentThread.CurrentCulture;
            //Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT");
            var options = new NumberSetOptions();
            var parser = new Parser(new ParserSettings { ParsingCulture = new CultureInfo("it-IT") });
            var result = parser.ParseArguments(new string[] { "-d", "10,986" }, options);

            result.Should().BeTrue();
            options.DoubleValue.Should().Be(10.986D);

            //Thread.CurrentThread.CurrentCulture = actualCulture;
        }
Example #6
0
        public void Parse_culture_specific_nullable_number()
        {
            var actualCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT");
            var options = new NumberSetOptions();
            var parser = new Parser();
            var result = parser.ParseArguments(new string[] { "--n-double", "12,32982" }, options);

            result.Should().BeTrue();
            options.NullableDoubleValue.Should().Be(12.32982D);

            Thread.CurrentThread.CurrentCulture = actualCulture;
        }
Example #7
0
        public void Passing_no_value_to_an_integer_type_long_option_fails()
        {
            var options = new NumberSetOptions();
            var parser = new CommandLine.Parser();
            var result = parser.ParseArguments(new string[] { "--int" }, options);

            result.Should().BeFalse();
        }
Example #8
0
        public void Passing_long_value_to_integer_option_must_fail_gracefully()
        {
            var options = new NumberSetOptions();
            var parser = new CommandLine.Parser();
            var result = parser.ParseArguments(new string[] { "-i", long.MaxValue.ToString(CultureInfo.InvariantCulture) }, options);

            result.Should().BeFalse();
        }
Example #9
0
        public void Parse_negative_floating_point_value()
        {
            var options = new NumberSetOptions();
            var parser = new CommandLine.Parser();
            var result = parser.ParseArguments(new string[] { "-d", "-4096.1024" }, options);

            result.Should().BeTrue();
            options.DoubleValue.Should().Be(-4096.1024D);
        }