Skip to content

Commit aec9243

Browse files
committed
✏️Update xmldoc for UnitAbbreviationsCacheFixture
Make it clear that tests manipulating CultureInfo.CurrentCulture does not require this.
1 parent 9fbd6b4 commit aec9243

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed
Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
using Xunit;
1+
using System.Globalization;
2+
using Xunit;
23

3-
namespace UnitsNet.Tests
4-
{
5-
[CollectionDefinition(nameof(UnitAbbreviationsCacheFixture), DisableParallelization = true)]
6-
public class UnitAbbreviationsCacheFixture : ICollectionFixture<object>
7-
{
8-
// This class has no code, and is never created. Its purpose is simply
9-
// to be the place to apply [CollectionDefinition] and all the
10-
// ICollectionFixture<> interfaces.
4+
namespace UnitsNet.Tests;
115

12-
// Apply this collection fixture to classes:
13-
// 1. That rely on manipulating CultureInfo. See https://github.com/angularsen/UnitsNet/issues/436
14-
// 2. To avoid accessing static ToString/Parse from multiple tests where UnitAbbreviationsCache.Default is modified
15-
}
16-
}
6+
/// <summary>
7+
/// Apply to test classes that manipulate static fields, such as
8+
/// <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitAbbreviations"/>,
9+
/// to disable parallelization and avoid flaky tests.
10+
/// <br /><br />
11+
/// To apply to test class, add attribute just before class definition: <c>[Collection(nameof(UnitAbbreviationsCacheFixture))]</c>
12+
/// </summary>
13+
/// <remarks>
14+
/// This is not necessary for thread-static fields like <see cref="CultureInfo"/>.<see cref="CultureInfo.CurrentCulture"/>, typically used when testing Parse/ToString() without an explicit culture,
15+
/// as long as each test method reverts its changes with try-finally or <see cref="CultureScope"/>.
16+
/// </remarks>
17+
[CollectionDefinition(nameof(UnitAbbreviationsCacheFixture), DisableParallelization = true)]
18+
public class UnitAbbreviationsCacheFixture : ICollectionFixture<object>;

0 commit comments

Comments
 (0)