Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet test fails when decimal separator is not dot in regional format #1405

Closed
codepic opened this issue Jan 1, 2023 · 1 comment · Fixed by #1424
Closed

dotnet test fails when decimal separator is not dot in regional format #1405

codepic opened this issue Jan 1, 2023 · 1 comment · Fixed by #1424
Assignees
Labels
bug Something isn't working feature: language Issues that affect language such keywords and variables
Milestone

Comments

@codepic
Copy link

codepic commented Jan 1, 2023

Description of the issue

When current culture decimal separator is not ., the dotnet test fails

To Reproduce

Set the regional format as follows:
image

cd PSRule
dotnet test

Expected behaviour

Tests should pass

Error output

[xUnit.net 00:00:02.66]     PSRule.AssertTests.LessOrEqual [FAIL]
  Failed PSRule.AssertTests.LessOrEqual [7 ms]
  Error Message:
   Assert.False() Failure
Expected: False
Actual:   True
  Stack Trace:
     at PSRule.AssertTests.LessOrEqual() in C:\Users\JaniHyytiäinen\src\OpsOps.PSRule\tests\PSRule.Tests\AssertTests.cs:line 1023
[xUnit.net 00:00:02.81]     PSRule.AssertTests.GreaterOrEqual [FAIL]
[xUnit.net 00:00:02.83]     PSRule.AssertTests.Less [FAIL]
  Failed PSRule.AssertTests.GreaterOrEqual [3 ms]
  Error Message:
   Assert.True() Failure
Expected: True
Actual:   False
  Stack Trace:
     at PSRule.AssertTests.GreaterOrEqual() in C:\Users\JaniHyytiäinen\src\OpsOps.PSRule\tests\PSRule.Tests\AssertTests.cs:line 887
  Failed PSRule.AssertTests.Less [14 ms]
  Error Message:
   Assert.False() Failure
Expected: False
Actual:   True
  Stack Trace:
     at PSRule.AssertTests.Less() in C:\Users\JaniHyytiäinen\src\OpsOps.PSRule\tests\PSRule.Tests\AssertTests.cs:line 955
[xUnit.net 00:00:02.87]     PSRule.AssertTests.Greater [FAIL]
  Failed PSRule.AssertTests.Greater [3 ms]
  Error Message:
   Assert.True() Failure
Expected: True
Actual:   False
  Stack Trace:
     at PSRule.AssertTests.Greater() in C:\Users\JaniHyytiäinen\src\OpsOps.PSRule\tests\PSRule.Tests\AssertTests.cs:line 819

Failed!  - Failed:     4, Passed:   274, Skipped:     0, Total:   278, Duration: 5 s - PSRule.Tests.dll (net6.0)

Module in use and version:

  • Module: PSRule
  • Version: branch: main

Captured output from $PSVersionTable:

Name                           Value
----                           -----
PSVersion                      7.3.1
PSEdition                      Core
GitCommitId                    7.3.1
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional context

All of the failing tests initialize the value as decimal with a dot separator:

value = GetObject((name: "value", value: "4.5"));
Assert.True(assert.Greater(value, "value", 2, convert: true).Result);

When regional format is set to en-US, the tests pass:

image

cd PSRule
dotnet test
...
Passed!  - Failed:     0, Passed:   278, Skipped:     0, Total:   278, Duration: 5 s - PSRule.Tests.dll (net6.0)
@BernieWhite
Copy link
Member

@codepic Thanks for reporting the issue.

Instead of . how would this normally be represented with your recommended culture settings?

@BernieWhite BernieWhite added bug Something isn't working feature: language Issues that affect language such keywords and variables labels Jan 3, 2023
@BernieWhite BernieWhite self-assigned this Feb 5, 2023
@BernieWhite BernieWhite added this to the v2.8.0 milestone Feb 5, 2023
BernieWhite added a commit to BernieWhite/PSRule that referenced this issue Feb 5, 2023
@BernieWhite BernieWhite mentioned this issue Mar 27, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature: language Issues that affect language such keywords and variables
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants