Skip to content

Some unit tests fail when run on a Windows machine set to a culture that doesn't use dot as the decimal separator #2193

Open
@monoman

Description

@monoman

Those tests (in command-line-api\src\System.CommandLine.Tests\Binding\TypeConversionTests.cs) fail as is assumed that dot ('.') is always the decimal separator what is not true for pt-BR, or perhaps the parsing should use invariant culture to standardize the decimal separator

       [Fact]
        public void Values_can_be_correctly_converted_to_decimal_without_the_parser_specifying_a_custom_converter()
            => GetValue(new CliOption<decimal>("-x"), "-x 123.456").Should().Be(123.456m);

        [Fact]
        public void Values_can_be_correctly_converted_to_nullable_decimal_without_the_parser_specifying_a_custom_converter()
            => GetValue(new CliOption<decimal?>("-x"), "-x 123.456").Should().Be(123.456m);

        [Fact]
        public void Values_can_be_correctly_converted_to_double_without_the_parser_specifying_a_custom_converter()
            => GetValue(new CliOption<double>("-x"), "-x 123.456").Should().Be(123.456d);

        [Fact]
        public void Values_can_be_correctly_converted_to_nullable_double_without_the_parser_specifying_a_custom_converter()
            => GetValue(new CliOption<double?>("-x"), "-x 123.456").Should().Be(123.456d);

        [Fact]
        public void Values_can_be_correctly_converted_to_float_without_the_parser_specifying_a_custom_converter()
            => GetValue(new CliOption<float>("-x"), "-x 123.456").Should().Be(123.456f);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions