dotnet / dotnet/command-line-api

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

Open
#2,193 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

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("-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("-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("-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("-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("-x"), "-x 123.456").Should().Be(123.456f);

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.