Skip to content

Commit 7264a1f

Browse files
committed
tests: ♻️Replace EnumUtils with Enum.GetValues<>
After upgrading to net7+, we can use the AOT compatible built-in method.
1 parent 69747df commit 7264a1f

File tree

131 files changed

+283
-299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+283
-299
lines changed

CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public void Ctor_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
306306
Assert.Equal({_quantity.Name}.Zero, quantityInfo.Zero);
307307
Assert.Equal(""{_quantity.Name}"", quantityInfo.Name);
308308
309-
var units = EnumUtils.GetEnumValues<{_unitEnumName}>().OrderBy(x => x.ToString()).ToArray();
309+
var units = Enum.GetValues<{_unitEnumName}>().OrderBy(x => x.ToString()).ToArray();
310310
var unitNames = units.Select(x => x.ToString());
311311
}}
312312
@@ -672,7 +672,7 @@ public void ParseUnit_WithCulture(string culture, string abbreviation, {_unitEnu
672672
foreach (KeyValuePair<string, List<Unit>> ambiguousPair in abbreviations)
673673
{
674674
Writer.WL($@"
675-
[InlineData(""{cultureName}"", ""{ambiguousPair.Key}"")] // [{string.Join(", ", ambiguousPair.Value.Select(x => x.SingularName))}] ");
675+
[InlineData(""{cultureName}"", ""{ambiguousPair.Key}"")] // [{string.Join(", ", ambiguousPair.Value.Select(x => x.SingularName))}]");
676676
}
677677
}
678678
Writer.WL($@"
@@ -764,7 +764,7 @@ public void TryParseUnit_WithCulture(string culture, string abbreviation, {_unit
764764
foreach (KeyValuePair<string, List<Unit>> ambiguousPair in abbreviations)
765765
{
766766
Writer.WL($@"
767-
[InlineData(""{cultureName}"", ""{ambiguousPair.Key}"")] // [{string.Join(", ", ambiguousPair.Value.Select(x => x.SingularName))}] ");
767+
[InlineData(""{cultureName}"", ""{ambiguousPair.Key}"")] // [{string.Join(", ", ambiguousPair.Value.Select(x => x.SingularName))}]");
768768
}
769769
}
770770
Writer.WL($@"
@@ -1011,7 +1011,7 @@ public void EqualsReturnsFalseOnNull()
10111011
[Fact]
10121012
public void HasAtLeastOneAbbreviationSpecified()
10131013
{{
1014-
var units = Enum.GetValues(typeof({_unitEnumName})).Cast<{_unitEnumName}>();
1014+
var units = Enum.GetValues<{_unitEnumName}>();
10151015
foreach (var unit in units)
10161016
{{
10171017
var defaultAbbreviation = UnitsNetSetup.Default.UnitAbbreviations.GetDefaultAbbreviation(unit);

UnitsNet.Tests/CustomCode/PressureTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public void ReferencePressure_WithInvalidPressureReference_ThrowsNotImplementedE
167167
[Fact]
168168
public void ReferencePressureReferences_ReturnsTheExpectedEnumValues()
169169
{
170-
IEnumerable<PressureReference> expectedValues = Enum.GetValues(typeof(PressureReference)).Cast<PressureReference>();
170+
IEnumerable<PressureReference> expectedValues = Enum.GetValues<PressureReference>();
171171

172172
PressureReference[] actualValues = ReferencePressure.References;
173173

UnitsNet.Tests/EnumUtils.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)