public void PassingDoubleValueToFloatOptionMustFailGracefully()
        {
            var options = new NumberSetOptions();
            bool result = base.Parser.ParseArguments(new string[] { "-f", double.MaxValue.ToString(CultureInfo.InvariantCulture) }, options);

            base.AssertParserFailure(result);
        }
        public void ParseNegativeIntegerValue_InputStyle4()
        {
            var options = new NumberSetOptions();
            bool result = base.Parser.ParseArguments(new string[] { "--int=-4096" }, options);

            base.AssertParserSuccess(result);
            Assert.AreEqual(-4096, options.IntegerValue);
        }
        public void ParseNegativeFloatingPointValue_InputStyle4()
        {
            var options = new NumberSetOptions();
            bool result = base.Parser.ParseArguments(new string[] { "--double=-4096.1024" }, options);

            base.AssertParserSuccess(result);
            Assert.AreEqual(-4096.1024, options.DoubleValue);
        }
        public void PassingNoValueToAShortTypeLongOptionFails()
        {
            var options = new NumberSetOptions();
            Result = base.Parser.ParseArguments(new string[] { "--short" }, options);

            ResultShouldBeFalse();
        }
        public void ParseNegativeIntegerValue_InputStyle3()
        {
            var options = new NumberSetOptions();
            Result = base.Parser.ParseArguments(new string[] { "--int", "-4096" }, options);

            ResultShouldBeTrue();
            Assert.AreEqual(-4096, options.IntegerValue);
        }
        public void ParseCultureSpecificNumber()
        {
            var actualCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT");
            var options = new NumberSetOptions();
            Result = base.Parser.ParseArguments(new string[] { "-d", "10,986" }, options);

            ResultShouldBeTrue();
            options.DoubleValue.Should().Equal(10.986D);

            Thread.CurrentThread.CurrentCulture = actualCulture;
        }
        public void ParseNegativeIntegerValue_InputStyle4()
        {
            var options = new NumberSetOptions();
            Result = base.Parser.ParseArguments(new string[] { "--int=-4096" }, options);

            ResultShouldBeTrue();
            options.IntegerValue.Should().Equal(-4096);
        }
        public void Parse_negative_floating_point_value_input_style4()
        {
            var options = new NumberSetOptions();
            var parser = new CommandLineParser();
            var result = parser.ParseArguments(new string[] { "--double=-4096.1024" }, options);

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

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

            result.Should().BeFalse();
        }
        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 CommandLineParser();
            var result = parser.ParseArguments(new string[] { "-d", "10,986" }, options);

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

            Thread.CurrentThread.CurrentCulture = actualCulture;
        }
Example #12
0
        public void Passing_long_value_to_integer_option_must_fail_gracefully()
        {
            var options = new NumberSetOptions();
            var parser = new Parser();
            var result = parser.ParseArguments(new string[] { "-i", long.MaxValue.ToString(CultureInfo.InvariantCulture) }, options);

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

            result.Should().BeTrue();
            options.DoubleValue.Should().Be(-4096.1024D);
        }
Example #14
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;
        }
        public void PassingNoValueToAShortTypeLongOptionFails()
        {
            var options = new NumberSetOptions();
            bool result = base.Parser.ParseArguments(new string[] { "--short" }, options);

            base.AssertParserFailure(result);
        }
        public void Passing_short_value_to_byte_option_must_fail_gracefully()
        {
            var options = new NumberSetOptions();
            var parser = new CommandLineParser();
            var result = parser.ParseArguments(new string[] { "-b", short.MaxValue.ToString(CultureInfo.InvariantCulture) }, options);

            result.Should().BeFalse();
        }
        public void ParseCultureSpecificNullableNumber()
        {
            var actualCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("it-IT");
            var options = new NumberSetOptions();
            Result = base.Parser.ParseArguments(new string[] { "--n-double", "12,32982" }, options);

            ResultShouldBeTrue();
            options.NullableDoubleValue.Should().Equal(12.32982D);

            Thread.CurrentThread.CurrentCulture = actualCulture;
        }
        public void ParseNegativeIntegerValue_InputStyle2()
        {
            var options = new NumberSetOptions();
            var parser = new CommandLineParser();
            var result = parser.ParseArguments(new string[] { "-i-4096" }, options);

            result.Should().BeTrue();
            options.IntegerValue.Should().Be(-4096);
        }
        public void ParseNegativeFloatingPointValue_InputStyle4()
        {
            var options = new NumberSetOptions();
            Result = base.Parser.ParseArguments(new string[] { "--double=-4096.1024" }, options);

            ResultShouldBeTrue();
            options.DoubleValue.Should().Equal(-4096.1024D);
        }
        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;
        }
        public void PassingLongValueToIntegerOptionMustFailGracefully()
        {
            var options = new NumberSetOptions();
            Result = base.Parser.ParseArguments(new string[] { "-i", long.MaxValue.ToString(CultureInfo.InvariantCulture) }, options);

            ResultShouldBeFalse();
        }
        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;
        }
        public void PassingShortValueToByteOptionMustFailGracefully()
        {
            var options = new NumberSetOptions();
            Result = base.Parser.ParseArguments(new string[] { "-b", short.MaxValue.ToString(CultureInfo.InvariantCulture) }, options);

            ResultShouldBeFalse();
        }
        public void ParseNegativeFloatingPointValue_InputStyle3()
        {
            var options = new NumberSetOptions();
            Result = base.Parser.ParseArguments(new string[] { "--double", "-4096.1024" }, options);

            ResultShouldBeTrue();
            Assert.AreEqual(-4096.1024, options.DoubleValue);
        }