-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #436 Flaky test: UnitsNet.Tests.UnitSystemTests.PositiveInfinityF…
…ormatting (#438) * Fix #436 Flaky test: UnitsNet.Tests.UnitSystemTests.PositiveInfinityFormatting Fixes #436 Added `UnitSystemFixture` class which is a `CollectionDefinition` class used to group test classes: 1. that rely on manipulating CultureInfo. See #436 2. to avoid accessing static prop DefaultToString in parallel from multiple tests: a. UnitSystemTests.DefaultToStringFormatting() b. LengthTests.ToStringReturnsCorrectNumberAndUnitWithCentimeterAsDefualtUnit() Changes in this PR: - `UnitSystemTests.GetDefaultAbbreviationFallsBackToUsEnglishCulture`: Set CultureInfo properties back to their original values. - Specify `InvariantCulture` on the following `UnitSystemTests` tests: 1. `NegativeInfinityFormatting` 2. `PositiveInfinityFormatting` - Applied `[Collection(nameof(UnitSystemFixture)]` attribute to test classes that: - Sets `UnitSystem.DefaultCulture` - Originally uses `[Collection("DefaulToString")]` that also depends on `CultureInfo` - Only one `Collection` attribute per test class. - Updated to `xunit` and `xunit.runner.visualstudio` to v2.3.1 (was v2.3.0-beta4-build3742) - To have the [CollectionDefinition(DisableParallelization = true)] feature. See https://xunit.github.io/releases/2.3-beta5 * Removed `InvariantCulture` Removed `InvariantCulture` on the following `UnitSystemTests` tests: 1. `NegativeInfinityFormatting` 2. `PositiveInfinityFormatting` * Specified InvariantCulture in InfinityFormatting Tests
- Loading branch information
Showing
7 changed files
with
53 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Xunit; | ||
|
||
namespace UnitsNet.Tests | ||
{ | ||
[CollectionDefinition(nameof(UnitSystemFixture), DisableParallelization = true)] | ||
public class UnitSystemFixture : ICollectionFixture<object> | ||
{ | ||
// This class has no code, and is never created. Its purpose is simply | ||
// to be the place to apply [CollectionDefinition] and all the | ||
// ICollectionFixture<> interfaces. | ||
|
||
// Apply this collection fixture to classes: | ||
// 1. that rely on manipulating CultureInfo. See https://github.com/angularsen/UnitsNet/issues/436 | ||
// 2. to avoid accessing static prop DefaultToString in parallel from multiple tests: | ||
// a. UnitSystemTests.DefaultToStringFormatting() | ||
// b. LengthTests.ToStringReturnsCorrectNumberAndUnitWithCentimeterAsDefualtUnit() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters