Skip to content

Commit d50aab2

Browse files
lipchevangularsen
andauthored
Clean up commented bits from QuantityInfo and IQuantityInfo (#1592)
- cleaned up some commented-out bits from `QuantityInfo` and `IQuantityInfo` - making the `IQuantityInfo` interface internal for `net8+` - extended the test for `XXX_QuantityInfo_ReturnsQuantityInfoDescribingQuantity` with the checks for the explicit interface implementations - simplified the test for `Ctor_SIUnitSystem_ReturnsQuantityWithSIUnits` --------- Co-authored-by: Andreas Gullberg Larsen <andreas.larsen84@gmail.com>
1 parent 28ac7db commit d50aab2

File tree

133 files changed

+1381
-1078
lines changed

Some content is hidden

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

133 files changed

+1381
-1078
lines changed

CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public virtual void Ctor_SIUnitSystem_ReturnsQuantityWithSIUnits()
307307
{{
308308
var quantity = new {_quantity.Name}(value: 1, unitSystem: UnitSystem.SI);
309309
Assert.Equal(1, quantity.Value);
310-
Assert.True(quantity.QuantityInfo.UnitInfos.First(x => x.Value == quantity.Unit).BaseUnits.IsSubsetOf(UnitSystem.SI.BaseUnits));
310+
Assert.True(quantity.QuantityInfo[quantity.Unit].BaseUnits.IsSubsetOf(UnitSystem.SI.BaseUnits));
311311
}}
312312
313313
[Fact]
@@ -324,15 +324,19 @@ public void Ctor_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
324324
[Fact]
325325
public void {_quantity.Name}_QuantityInfo_ReturnsQuantityInfoDescribingQuantity()
326326
{{
327+
{_unitEnumName}[] unitsOrderedByName = EnumHelper.GetValues<{_unitEnumName}>().OrderBy(x => x.ToString()).ToArray();
327328
var quantity = new {_quantity.Name}(1, {_baseUnitFullName});
328329
329-
QuantityInfo<{_unitEnumName}> quantityInfo = quantity.QuantityInfo;
330+
QuantityInfo<{_quantity.Name}, {_unitEnumName}> quantityInfo = quantity.QuantityInfo;
330331
331-
Assert.Equal({_quantity.Name}.Zero, quantityInfo.Zero);
332332
Assert.Equal(""{_quantity.Name}"", quantityInfo.Name);
333-
334-
var units = Enum.GetValues<{_unitEnumName}>().OrderBy(x => x.ToString()).ToArray();
335-
var unitNames = units.Select(x => x.ToString());
333+
Assert.Equal({_quantity.Name}.Zero, quantityInfo.Zero);
334+
Assert.Equal({_quantity.Name}.BaseUnit, quantityInfo.BaseUnitInfo.Value);
335+
Assert.Equal(unitsOrderedByName, quantityInfo.Units);
336+
Assert.Equal(unitsOrderedByName, quantityInfo.UnitInfos.Select(x => x.Value));
337+
Assert.Equal({_quantity.Name}.Info, quantityInfo);
338+
Assert.Equal(quantityInfo, ((IQuantity)quantity).QuantityInfo);
339+
Assert.Equal(quantityInfo, ((IQuantity<{_unitEnumName}>)quantity).QuantityInfo);
336340
}}
337341
338342
[Fact]

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

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

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

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

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

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

0 commit comments

Comments
 (0)