Skip to content

Commit bf83f7a

Browse files
authored
Refactored test: From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit (#1596)
Replaced the in-lined iteration with `Assert.All` and replaced the use of the named property with the `Value`
1 parent 18dbc2f commit bf83f7a

File tree

129 files changed

+904
-6805
lines changed

Some content is hidden

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

129 files changed

+904
-6805
lines changed

CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ public string Generate()
178178
using System.Globalization;
179179
using System.Linq;
180180
using System.Threading;
181+
using UnitsNet.InternalHelpers;
181182
using UnitsNet.Tests.Helpers;
182183
using UnitsNet.Tests.TestsBase;
183184
using UnitsNet.Units;
@@ -322,19 +323,13 @@ public void Ctor_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
322323
323324
[Fact]
324325
public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
325-
{{");
326-
var i = 0;
327-
foreach (var unit in _quantity.Units)
328-
{
329-
var quantityVariable = $"quantity{i++:D2}";
330-
Writer.WL($@"
331-
var {quantityVariable} = {_quantity.Name}.From(1, {GetUnitFullName(unit)});
332-
AssertEx.EqualTolerance(1, {quantityVariable}.{unit.PluralName}, {unit.PluralName}Tolerance);
333-
Assert.Equal({GetUnitFullName(unit)}, {quantityVariable}.Unit);
334-
");
335-
336-
}
337-
Writer.WL($@"
326+
{{
327+
Assert.All(EnumHelper.GetValues<{_unitEnumName}>(), unit =>
328+
{{
329+
var quantity = {_quantity.Name}.From(1, unit);
330+
Assert.Equal(1, quantity.Value);
331+
Assert.Equal(unit, quantity.Unit);
332+
}});
338333
}}
339334
340335
[Fact]

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

Lines changed: 7 additions & 68 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: 7 additions & 56 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: 7 additions & 68 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: 7 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)