Esempio n. 1
0
        public void PassingNoValueToADoubleTypeLongOptionFails()
        {
            var  options = new NumberSetOptions();
            bool result  = base.Parser.ParseArguments(new string[] { "--double" }, options);

            base.AssertParserFailure(result);
        }
Esempio n. 2
0
        public void Passing_double_value_to_float_option_must_fail_gracefully()
        {
            var options = new NumberSetOptions();
            var parser  = new CommandLine.Parser();
            var result  = parser.ParseArguments(new string[] { "-f", double.MaxValue.ToString(CultureInfo.InvariantCulture) }, options);

            result.Should().BeFalse();
        }
Esempio n. 3
0
        public void Passing_no_value_to_a_double_type_long_option_fails()
        {
            var options = new NumberSetOptions();
            var parser  = new CommandLine.Parser();
            var result  = parser.ParseArguments(new string[] { "--double" }, options);

            result.Should().BeFalse();
        }
Esempio n. 4
0
        public void Parse_negative_floating_point_value_input_style4()
        {
            var options = new NumberSetOptions();
            var parser  = new CommandLine.Parser();
            var result  = parser.ParseArguments(new string[] { "--double=-4096.1024" }, options);

            result.Should().BeTrue();
            options.DoubleValue.Should().Be(-4096.1024D);
        }
Esempio n. 5
0
        public void ParseNegativeIntegerValue_InputStyle4()
        {
            var options = new NumberSetOptions();
            var parser  = new CommandLine.Parser();
            var result  = parser.ParseArguments(new string[] { "--int=-4096" }, options);

            result.Should().BeTrue();
            options.IntegerValue.Should().Be(-4096);
        }
Esempio n. 6
0
        public void ParseCultureSpecificNullableNumber()
        {
            var actualCulture = Thread.CurrentThread.CurrentCulture;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT");
            var  options = new NumberSetOptions();
            bool result  = base.Parser.ParseArguments(new string[] { "--n-double", "12,32982" }, options);

            base.AssertParserSuccess(result);
            Assert.AreEqual(12.32982, options.NullableDoubleValue);

            Thread.CurrentThread.CurrentCulture = actualCulture;
        }
Esempio n. 7
0
        public void ParseCultureSpecificNumber()
        {
            var actualCulture = Thread.CurrentThread.CurrentCulture;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT");
            var  options = new NumberSetOptions();
            bool result  = base.Parser.ParseArguments(new string[] { "-d", "10,986" }, options);

            base.AssertParserSuccess(result);
            Assert.AreEqual(10.986, options.DoubleValue);

            Thread.CurrentThread.CurrentCulture = actualCulture;
        }
Esempio n. 8
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 CommandLine.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;
        }
Esempio n. 9
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 CommandLine.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;
        }