diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 6c5cf268d0..c91c2f7244 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -1034,15 +1034,6 @@ public double As(UnitKey unitKey) }} "); - Writer.WL( $@" - - /// - public double As(UnitSystem unitSystem) - {{ - return As(Info.GetDefaultUnit(unitSystem)); - }} -"); - Writer.WL($@" /// /// Converts this {_quantity.Name} to another {_quantity.Name} with the unit representation . @@ -1140,14 +1131,6 @@ private bool TryToUnit({_unitEnumName} unit, [NotNullWhen(true)] out {_quantity. return true; }} "); - Writer.WL($@" - /// - public {_quantity.Name} ToUnit(UnitSystem unitSystem) - {{ - return ToUnit(Info.GetDefaultUnit(unitSystem)); - }} -"); - Writer.WL($@" #region Explicit implementations @@ -1168,14 +1151,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); }} - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity<{_unitEnumName}> IQuantity<{_unitEnumName}>.ToUnit({_unitEnumName} unit) => ToUnit(unit); /// - IQuantity<{_unitEnumName}> IQuantity<{_unitEnumName}>.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity<{_unitEnumName}> IQuantity<{_unitEnumName}>.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index 249277e290..b2ebbdf0b3 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -410,7 +410,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() }} [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() {{ Assert.Multiple(() => {{ @@ -428,17 +428,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal({_baseUnitFullName}, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }}, () => - {{ - IQuantity quantity = new {_quantity.Name}(value: 1, unit: {_baseUnitFullName}); + }}); + }} + + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + {{ + IQuantity quantity = new {_quantity.Name}(value: 1, unit: {_baseUnitFullName}); - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); - Assert.Equal({_baseUnitFullName}, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }}); + Assert.Equal({_baseUnitFullName}, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); }} + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() {{ @@ -446,15 +450,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => {{ var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }}, () => {{ IQuantity<{_unitEnumName}> quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }}, () => {{ IQuantity quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }}); }} "); @@ -520,15 +524,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }}, () => - {{ - IQuantity quantityToConvert = quantity; + }}); + }} - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + {{ + var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + var expectedUnit = {_quantity.Name}.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }}); + IQuantity quantityToConvert = quantity; + + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); }} [Fact] @@ -543,13 +554,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() {{ IQuantity<{_unitEnumName}> quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }}, () => - {{ - IQuantity quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }}); }} + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + {{ + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + }} + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() {{ @@ -562,12 +577,16 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() {{ IQuantity<{_unitEnumName}> quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }}, () => - {{ - IQuantity quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }}); }} + + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + {{ + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + }} "); } diff --git a/UnitsNet.Tests/CustomCode/ElectricApparentEnergyTests.cs b/UnitsNet.Tests/CustomCode/ElectricApparentEnergyTests.cs index c1f249132c..0e03d7c445 100644 --- a/UnitsNet.Tests/CustomCode/ElectricApparentEnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/ElectricApparentEnergyTests.cs @@ -37,23 +37,29 @@ public override void Ctor_SIUnitSystem_ReturnsQuantityWithSIUnits() { base.Ctor_SIUnitSystem_ReturnsQuantityWithSIUnits(); } - + [Fact(Skip = "See about changing the BaseUnit to VoltampereSecond or Joule (adding the unit)")] public override void BaseUnit_HasSIBase() { base.BaseUnit_HasSIBase(); } - + [Fact(Skip = "See about adding an SI unit (VoltampereSecond, Joules?)")] public override void As_UnitSystem_SI_ReturnsQuantityInSIUnits() { base.As_UnitSystem_SI_ReturnsQuantityInSIUnits(); } - + [Fact(Skip = "See about adding an SI unit (VoltampereSecond, Joules?)")] public override void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() { base.ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits(); } + + [Fact(Skip = "See about adding an SI unit (VoltampereSecond, Joules?)")] + public override void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + base.ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits(); + } } } diff --git a/UnitsNet.Tests/CustomCode/ElectricReactiveEnergyTests.cs b/UnitsNet.Tests/CustomCode/ElectricReactiveEnergyTests.cs index 3f0ea76660..c6a879999c 100644 --- a/UnitsNet.Tests/CustomCode/ElectricReactiveEnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/ElectricReactiveEnergyTests.cs @@ -36,23 +36,29 @@ public override void Ctor_SIUnitSystem_ReturnsQuantityWithSIUnits() { base.Ctor_SIUnitSystem_ReturnsQuantityWithSIUnits(); } - + [Fact(Skip = "See about changing the BaseUnit to VoltampereReactiveSecond or Joule (adding the unit)")] public override void BaseUnit_HasSIBase() { base.BaseUnit_HasSIBase(); } - + [Fact(Skip = "See about adding an SI unit (VoltampereReactiveSecond, Joules?)")] public override void As_UnitSystem_SI_ReturnsQuantityInSIUnits() { base.As_UnitSystem_SI_ReturnsQuantityInSIUnits(); } - + [Fact(Skip = "See about adding an SI unit (VoltampereReactiveSecond, Joules?)")] public override void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() { base.ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits(); } + + [Fact(Skip = "See about adding an SI unit (VoltampereReactiveSecond, Joules?)")] + public override void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + base.ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits(); + } } } diff --git a/UnitsNet.Tests/CustomCode/FuelEfficiencyTests.cs b/UnitsNet.Tests/CustomCode/FuelEfficiencyTests.cs index 329dac3619..06bf5627cb 100644 --- a/UnitsNet.Tests/CustomCode/FuelEfficiencyTests.cs +++ b/UnitsNet.Tests/CustomCode/FuelEfficiencyTests.cs @@ -24,19 +24,19 @@ namespace UnitsNet.Tests.CustomCode public class FuelEfficiencyTests : FuelEfficiencyTestsBase { protected override bool SupportsSIUnitSystem => false; - + protected override double KilometersPerLiterInOneKilometerPerLiter => 1; protected override double LitersPer100KilometersInOneKilometerPerLiter => 100; protected override double MilesPerUkGallonInOneKilometerPerLiter => 2.824809363318222; protected override double MilesPerUsGallonInOneKilometerPerLiter => 2.352145833333333; - + [Fact(Skip = "The SI unit would have to be MeterPerCubicMeter")] public override void BaseUnit_HasSIBase() { base.BaseUnit_HasSIBase(); } - + [Fact(Skip = "The SI unit would have to be MeterPerCubicMeter")] public override void Ctor_SIUnitSystem_ReturnsQuantityWithSIUnits() { @@ -54,5 +54,11 @@ public override void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() { base.ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits(); } + + [Fact(Skip = "The SI unit would have to be MeterPerCubicMeter")] + public override void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + base.ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits(); + } } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs index e3445b5909..1468b9c0bc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs @@ -321,15 +321,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new AbsorbedDoseOfIonizingRadiation(value: 1, unit: AbsorbedDoseOfIonizingRadiation.BaseUnit); + var expectedUnit = AbsorbedDoseOfIonizingRadiation.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -344,13 +351,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new AbsorbedDoseOfIonizingRadiation(value: 1, unit: AbsorbedDoseOfIonizingRadiation.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new AbsorbedDoseOfIonizingRadiation(value: 1, unit: AbsorbedDoseOfIonizingRadiation.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new AbsorbedDoseOfIonizingRadiation(value: 1, unit: AbsorbedDoseOfIonizingRadiation.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -363,13 +374,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new AbsorbedDoseOfIonizingRadiation(value: 1, unit: AbsorbedDoseOfIonizingRadiation.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new AbsorbedDoseOfIonizingRadiation(value: 1, unit: AbsorbedDoseOfIonizingRadiation.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new AbsorbedDoseOfIonizingRadiation(value: 1, unit: AbsorbedDoseOfIonizingRadiation.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cGy", AbsorbedDoseOfIonizingRadiationUnit.Centigray, 4.2)] [InlineData("en-US", "4.2 dGy", AbsorbedDoseOfIonizingRadiationUnit.Decigray, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index e9cd2bc642..df6b31005e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -303,15 +303,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Acceleration(value: 1, unit: Acceleration.BaseUnit); + var expectedUnit = Acceleration.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -326,13 +333,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Acceleration(value: 1, unit: Acceleration.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Acceleration(value: 1, unit: Acceleration.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Acceleration(value: 1, unit: Acceleration.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -345,13 +356,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Acceleration(value: 1, unit: Acceleration.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Acceleration(value: 1, unit: Acceleration.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Acceleration(value: 1, unit: Acceleration.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cm/s²", AccelerationUnit.CentimeterPerSecondSquared, 4.2)] [InlineData("en-US", "4.2 dm/s²", AccelerationUnit.DecimeterPerSecondSquared, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index d763ffe4e5..f83c68a30b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -321,15 +321,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new AmountOfSubstance(value: 1, unit: AmountOfSubstance.BaseUnit); + var expectedUnit = AmountOfSubstance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -344,13 +351,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new AmountOfSubstance(value: 1, unit: AmountOfSubstance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new AmountOfSubstance(value: 1, unit: AmountOfSubstance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new AmountOfSubstance(value: 1, unit: AmountOfSubstance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -363,13 +374,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new AmountOfSubstance(value: 1, unit: AmountOfSubstance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new AmountOfSubstance(value: 1, unit: AmountOfSubstance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new AmountOfSubstance(value: 1, unit: AmountOfSubstance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cmol", AmountOfSubstanceUnit.Centimole, 4.2)] [InlineData("en-US", "4.2 clbmol", AmountOfSubstanceUnit.CentipoundMole, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index e50a6f329b..3b46e2b40b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -184,7 +184,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -202,17 +202,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(AmplitudeRatioUnit.DecibelVolt, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new AmplitudeRatio(value: 1, unit: AmplitudeRatioUnit.DecibelVolt); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new AmplitudeRatio(value: 1, unit: AmplitudeRatioUnit.DecibelVolt); - Assert.Equal(AmplitudeRatioUnit.DecibelVolt, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(AmplitudeRatioUnit.DecibelVolt, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -220,15 +224,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new AmplitudeRatio(value: 1, unit: AmplitudeRatio.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new AmplitudeRatio(value: 1, unit: AmplitudeRatio.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new AmplitudeRatio(value: 1, unit: AmplitudeRatio.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index 1905e576a8..213bdd8424 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -250,7 +250,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -268,17 +268,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(AngleUnit.Radian, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new Angle(value: 1, unit: AngleUnit.Radian); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new Angle(value: 1, unit: AngleUnit.Radian); - Assert.Equal(AngleUnit.Radian, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(AngleUnit.Radian, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -286,15 +290,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new Angle(value: 1, unit: Angle.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new Angle(value: 1, unit: Angle.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new Angle(value: 1, unit: Angle.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index a41cea8ad7..6da629fbf6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -237,15 +237,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new AreaDensity(value: 1, unit: AreaDensity.BaseUnit); + var expectedUnit = AreaDensity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -260,13 +267,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new AreaDensity(value: 1, unit: AreaDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new AreaDensity(value: 1, unit: AreaDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new AreaDensity(value: 1, unit: AreaDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -279,13 +290,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new AreaDensity(value: 1, unit: AreaDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new AreaDensity(value: 1, unit: AreaDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new AreaDensity(value: 1, unit: AreaDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 g/m²", AreaDensityUnit.GramPerSquareMeter, 4.2)] [InlineData("en-US", "4.2 gsm", AreaDensityUnit.GramPerSquareMeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index c9e37a12fc..7476dc3f70 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -255,15 +255,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new AreaMomentOfInertia(value: 1, unit: AreaMomentOfInertia.BaseUnit); + var expectedUnit = AreaMomentOfInertia.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -278,13 +285,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new AreaMomentOfInertia(value: 1, unit: AreaMomentOfInertia.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new AreaMomentOfInertia(value: 1, unit: AreaMomentOfInertia.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new AreaMomentOfInertia(value: 1, unit: AreaMomentOfInertia.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -297,13 +308,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new AreaMomentOfInertia(value: 1, unit: AreaMomentOfInertia.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new AreaMomentOfInertia(value: 1, unit: AreaMomentOfInertia.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new AreaMomentOfInertia(value: 1, unit: AreaMomentOfInertia.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cm⁴", AreaMomentOfInertiaUnit.CentimeterToTheFourth, 4.2)] [InlineData("en-US", "4.2 dm⁴", AreaMomentOfInertiaUnit.DecimeterToTheFourth, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 07316d3858..197378c4e9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -303,15 +303,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Area(value: 1, unit: Area.BaseUnit); + var expectedUnit = Area.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -326,13 +333,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Area(value: 1, unit: Area.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Area(value: 1, unit: Area.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Area(value: 1, unit: Area.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -345,13 +356,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Area(value: 1, unit: Area.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Area(value: 1, unit: Area.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Area(value: 1, unit: Area.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 ac", AreaUnit.Acre, 4.2)] [InlineData("en-US", "4.2 ha", AreaUnit.Hectare, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index c235cf59ba..854e9900b1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -453,15 +453,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new BitRate(value: 1, unit: BitRate.BaseUnit); + var expectedUnit = BitRate.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -476,13 +483,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new BitRate(value: 1, unit: BitRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new BitRate(value: 1, unit: BitRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new BitRate(value: 1, unit: BitRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -495,13 +506,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new BitRate(value: 1, unit: BitRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new BitRate(value: 1, unit: BitRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new BitRate(value: 1, unit: BitRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 bit/s", BitRateUnit.BitPerSecond, 4.2)] [InlineData("en-US", "4.2 bps", BitRateUnit.BitPerSecond, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 6062eee45d..536f5b101f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -237,15 +237,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new BrakeSpecificFuelConsumption(value: 1, unit: BrakeSpecificFuelConsumption.BaseUnit); + var expectedUnit = BrakeSpecificFuelConsumption.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -260,13 +267,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new BrakeSpecificFuelConsumption(value: 1, unit: BrakeSpecificFuelConsumption.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new BrakeSpecificFuelConsumption(value: 1, unit: BrakeSpecificFuelConsumption.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new BrakeSpecificFuelConsumption(value: 1, unit: BrakeSpecificFuelConsumption.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -279,13 +290,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new BrakeSpecificFuelConsumption(value: 1, unit: BrakeSpecificFuelConsumption.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new BrakeSpecificFuelConsumption(value: 1, unit: BrakeSpecificFuelConsumption.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new BrakeSpecificFuelConsumption(value: 1, unit: BrakeSpecificFuelConsumption.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 g/kWh", BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, 4.2)] [InlineData("en-US", "4.2 kg/J", BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index 8db65616ee..64fcb85cca 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -255,15 +255,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new CoefficientOfThermalExpansion(value: 1, unit: CoefficientOfThermalExpansion.BaseUnit); + var expectedUnit = CoefficientOfThermalExpansion.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -278,13 +285,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new CoefficientOfThermalExpansion(value: 1, unit: CoefficientOfThermalExpansion.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new CoefficientOfThermalExpansion(value: 1, unit: CoefficientOfThermalExpansion.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new CoefficientOfThermalExpansion(value: 1, unit: CoefficientOfThermalExpansion.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -297,13 +308,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new CoefficientOfThermalExpansion(value: 1, unit: CoefficientOfThermalExpansion.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new CoefficientOfThermalExpansion(value: 1, unit: CoefficientOfThermalExpansion.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new CoefficientOfThermalExpansion(value: 1, unit: CoefficientOfThermalExpansion.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 °C⁻¹", CoefficientOfThermalExpansionUnit.PerDegreeCelsius, 4.2)] [InlineData("en-US", "4.2 °F⁻¹", CoefficientOfThermalExpansionUnit.PerDegreeFahrenheit, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs index 9a4fa19df3..964d15a611 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs @@ -261,15 +261,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Compressibility(value: 1, unit: Compressibility.BaseUnit); + var expectedUnit = Compressibility.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -284,13 +291,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Compressibility(value: 1, unit: Compressibility.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Compressibility(value: 1, unit: Compressibility.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Compressibility(value: 1, unit: Compressibility.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -303,13 +314,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Compressibility(value: 1, unit: Compressibility.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Compressibility(value: 1, unit: Compressibility.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Compressibility(value: 1, unit: Compressibility.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 atm⁻¹", CompressibilityUnit.InverseAtmosphere, 4.2)] [InlineData("en-US", "4.2 1/atm", CompressibilityUnit.InverseAtmosphere, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index 5af5af8aa4..48e3d7e820 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -555,15 +555,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Density(value: 1, unit: Density.BaseUnit); + var expectedUnit = Density.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -578,13 +585,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Density(value: 1, unit: Density.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Density(value: 1, unit: Density.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Density(value: 1, unit: Density.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -597,13 +608,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Density(value: 1, unit: Density.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Density(value: 1, unit: Density.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Density(value: 1, unit: Density.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cg/dl", DensityUnit.CentigramPerDeciliter, 4.2)] [InlineData("en-US", "4.2 cg/l", DensityUnit.CentigramPerLiter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DoseAreaProductTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DoseAreaProductTestsBase.g.cs index 7e87f51cdc..d2c1304e26 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DoseAreaProductTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DoseAreaProductTestsBase.g.cs @@ -369,15 +369,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new DoseAreaProduct(value: 1, unit: DoseAreaProduct.BaseUnit); + var expectedUnit = DoseAreaProduct.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -392,13 +399,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new DoseAreaProduct(value: 1, unit: DoseAreaProduct.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new DoseAreaProduct(value: 1, unit: DoseAreaProduct.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new DoseAreaProduct(value: 1, unit: DoseAreaProduct.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -411,13 +422,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new DoseAreaProduct(value: 1, unit: DoseAreaProduct.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new DoseAreaProduct(value: 1, unit: DoseAreaProduct.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new DoseAreaProduct(value: 1, unit: DoseAreaProduct.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cGy·cm²", DoseAreaProductUnit.CentigraySquareCentimeter, 4.2)] [InlineData("en-US", "4.2 cGy·dm²", DoseAreaProductUnit.CentigraySquareDecimeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index f83d33989b..1e77b4db99 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -297,15 +297,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Duration(value: 1, unit: Duration.BaseUnit); + var expectedUnit = Duration.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -320,13 +327,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Duration(value: 1, unit: Duration.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Duration(value: 1, unit: Duration.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Duration(value: 1, unit: Duration.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -339,13 +350,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Duration(value: 1, unit: Duration.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Duration(value: 1, unit: Duration.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Duration(value: 1, unit: Duration.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 d", DurationUnit.Day, 4.2)] [InlineData("en-US", "4.2 day", DurationUnit.Day, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index 7632d103bf..483cff37e8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -279,15 +279,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new DynamicViscosity(value: 1, unit: DynamicViscosity.BaseUnit); + var expectedUnit = DynamicViscosity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -302,13 +309,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new DynamicViscosity(value: 1, unit: DynamicViscosity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new DynamicViscosity(value: 1, unit: DynamicViscosity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new DynamicViscosity(value: 1, unit: DynamicViscosity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -321,13 +332,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new DynamicViscosity(value: 1, unit: DynamicViscosity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new DynamicViscosity(value: 1, unit: DynamicViscosity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new DynamicViscosity(value: 1, unit: DynamicViscosity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cP", DynamicViscosityUnit.Centipoise, 4.2)] [InlineData("en-US", "4.2 µPa·s", DynamicViscosityUnit.MicropascalSecond, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index 55ee5df321..5e8754b5ee 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -315,15 +315,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricAdmittance(value: 1, unit: ElectricAdmittance.BaseUnit); + var expectedUnit = ElectricAdmittance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -338,13 +345,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricAdmittance(value: 1, unit: ElectricAdmittance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricAdmittance(value: 1, unit: ElectricAdmittance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricAdmittance(value: 1, unit: ElectricAdmittance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -357,13 +368,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricAdmittance(value: 1, unit: ElectricAdmittance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricAdmittance(value: 1, unit: ElectricAdmittance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricAdmittance(value: 1, unit: ElectricAdmittance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 G℧", ElectricAdmittanceUnit.Gigamho, 4.2)] [InlineData("en-US", "4.2 GS", ElectricAdmittanceUnit.Gigasiemens, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentEnergyTestsBase.g.cs index 8dd6c53fe7..79f5ea0993 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentEnergyTestsBase.g.cs @@ -237,15 +237,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricApparentEnergy(value: 1, unit: ElectricApparentEnergy.BaseUnit); + var expectedUnit = ElectricApparentEnergy.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -260,13 +267,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricApparentEnergy(value: 1, unit: ElectricApparentEnergy.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricApparentEnergy(value: 1, unit: ElectricApparentEnergy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricApparentEnergy(value: 1, unit: ElectricApparentEnergy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -279,13 +290,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricApparentEnergy(value: 1, unit: ElectricApparentEnergy.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricApparentEnergy(value: 1, unit: ElectricApparentEnergy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricApparentEnergy(value: 1, unit: ElectricApparentEnergy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 kVAh", ElectricApparentEnergyUnit.KilovoltampereHour, 4.2)] [InlineData("en-US", "4.2 MVAh", ElectricApparentEnergyUnit.MegavoltampereHour, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentPowerTestsBase.g.cs index 21f3870bd0..8572daa8ff 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricApparentPowerTestsBase.g.cs @@ -255,15 +255,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricApparentPower(value: 1, unit: ElectricApparentPower.BaseUnit); + var expectedUnit = ElectricApparentPower.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -278,13 +285,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricApparentPower(value: 1, unit: ElectricApparentPower.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricApparentPower(value: 1, unit: ElectricApparentPower.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricApparentPower(value: 1, unit: ElectricApparentPower.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -297,13 +308,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricApparentPower(value: 1, unit: ElectricApparentPower.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricApparentPower(value: 1, unit: ElectricApparentPower.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricApparentPower(value: 1, unit: ElectricApparentPower.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 GVA", ElectricApparentPowerUnit.Gigavoltampere, 4.2)] [InlineData("en-US", "4.2 kVA", ElectricApparentPowerUnit.Kilovoltampere, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCapacitanceTestsBase.g.cs index f2d4863228..f6c32ffea9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCapacitanceTestsBase.g.cs @@ -261,15 +261,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricCapacitance(value: 1, unit: ElectricCapacitance.BaseUnit); + var expectedUnit = ElectricCapacitance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -284,13 +291,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricCapacitance(value: 1, unit: ElectricCapacitance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricCapacitance(value: 1, unit: ElectricCapacitance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricCapacitance(value: 1, unit: ElectricCapacitance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -303,13 +314,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricCapacitance(value: 1, unit: ElectricCapacitance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricCapacitance(value: 1, unit: ElectricCapacitance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricCapacitance(value: 1, unit: ElectricCapacitance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 F", ElectricCapacitanceUnit.Farad, 4.2)] [InlineData("en-US", "4.2 kF", ElectricCapacitanceUnit.Kilofarad, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index d40904ba05..ef3f5777ae 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -225,15 +225,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricChargeDensity(value: 1, unit: ElectricChargeDensity.BaseUnit); + var expectedUnit = ElectricChargeDensity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -248,13 +255,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricChargeDensity(value: 1, unit: ElectricChargeDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricChargeDensity(value: 1, unit: ElectricChargeDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricChargeDensity(value: 1, unit: ElectricChargeDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -267,13 +278,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricChargeDensity(value: 1, unit: ElectricChargeDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricChargeDensity(value: 1, unit: ElectricChargeDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricChargeDensity(value: 1, unit: ElectricChargeDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 C/m³", ElectricChargeDensityUnit.CoulombPerCubicMeter, 4.2)] public void Parse(string culture, string quantityString, ElectricChargeDensityUnit expectedUnit, double expectedValue) diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index 76accb87a1..5d53b09e3e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -285,15 +285,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricCharge(value: 1, unit: ElectricCharge.BaseUnit); + var expectedUnit = ElectricCharge.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -308,13 +315,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricCharge(value: 1, unit: ElectricCharge.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricCharge(value: 1, unit: ElectricCharge.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricCharge(value: 1, unit: ElectricCharge.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -327,13 +338,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricCharge(value: 1, unit: ElectricCharge.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricCharge(value: 1, unit: ElectricCharge.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricCharge(value: 1, unit: ElectricCharge.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 A-h", ElectricChargeUnit.AmpereHour, 4.2)] [InlineData("en-US", "4.2 Ah", ElectricChargeUnit.AmpereHour, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index efdd4279e4..74df3bb25a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -315,15 +315,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricConductance(value: 1, unit: ElectricConductance.BaseUnit); + var expectedUnit = ElectricConductance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -338,13 +345,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricConductance(value: 1, unit: ElectricConductance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricConductance(value: 1, unit: ElectricConductance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricConductance(value: 1, unit: ElectricConductance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -357,13 +368,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricConductance(value: 1, unit: ElectricConductance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricConductance(value: 1, unit: ElectricConductance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricConductance(value: 1, unit: ElectricConductance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 G℧", ElectricConductanceUnit.Gigamho, 4.2)] [InlineData("en-US", "4.2 GS", ElectricConductanceUnit.Gigasiemens, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 713642f804..2eb01bb833 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -255,15 +255,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricConductivity(value: 1, unit: ElectricConductivity.BaseUnit); + var expectedUnit = ElectricConductivity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -278,13 +285,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricConductivity(value: 1, unit: ElectricConductivity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricConductivity(value: 1, unit: ElectricConductivity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricConductivity(value: 1, unit: ElectricConductivity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -297,13 +308,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricConductivity(value: 1, unit: ElectricConductivity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricConductivity(value: 1, unit: ElectricConductivity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricConductivity(value: 1, unit: ElectricConductivity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 µS/cm", ElectricConductivityUnit.MicrosiemensPerCentimeter, 4.2)] [InlineData("en-US", "4.2 mS/cm", ElectricConductivityUnit.MillisiemensPerCentimeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index c6bf55548a..63824a627e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -237,15 +237,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricCurrentDensity(value: 1, unit: ElectricCurrentDensity.BaseUnit); + var expectedUnit = ElectricCurrentDensity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -260,13 +267,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricCurrentDensity(value: 1, unit: ElectricCurrentDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricCurrentDensity(value: 1, unit: ElectricCurrentDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricCurrentDensity(value: 1, unit: ElectricCurrentDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -279,13 +290,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricCurrentDensity(value: 1, unit: ElectricCurrentDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricCurrentDensity(value: 1, unit: ElectricCurrentDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricCurrentDensity(value: 1, unit: ElectricCurrentDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 A/ft²", ElectricCurrentDensityUnit.AmperePerSquareFoot, 4.2)] [InlineData("en-US", "4.2 A/in²", ElectricCurrentDensityUnit.AmperePerSquareInch, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 7187e3e17e..d1bb6aef40 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -261,15 +261,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricCurrentGradient(value: 1, unit: ElectricCurrentGradient.BaseUnit); + var expectedUnit = ElectricCurrentGradient.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -284,13 +291,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricCurrentGradient(value: 1, unit: ElectricCurrentGradient.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricCurrentGradient(value: 1, unit: ElectricCurrentGradient.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricCurrentGradient(value: 1, unit: ElectricCurrentGradient.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -303,13 +314,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricCurrentGradient(value: 1, unit: ElectricCurrentGradient.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricCurrentGradient(value: 1, unit: ElectricCurrentGradient.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricCurrentGradient(value: 1, unit: ElectricCurrentGradient.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 A/μs", ElectricCurrentGradientUnit.AmperePerMicrosecond, 4.2)] [InlineData("en-US", "4.2 A/ms", ElectricCurrentGradientUnit.AmperePerMillisecond, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 5bd54a9db6..ae61a05fce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -273,15 +273,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricCurrent(value: 1, unit: ElectricCurrent.BaseUnit); + var expectedUnit = ElectricCurrent.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -296,13 +303,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricCurrent(value: 1, unit: ElectricCurrent.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricCurrent(value: 1, unit: ElectricCurrent.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricCurrent(value: 1, unit: ElectricCurrent.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -315,13 +326,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricCurrent(value: 1, unit: ElectricCurrent.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricCurrent(value: 1, unit: ElectricCurrent.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricCurrent(value: 1, unit: ElectricCurrent.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 A", ElectricCurrentUnit.Ampere, 4.2)] [InlineData("en-US", "4.2 cA", ElectricCurrentUnit.Centiampere, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index 33a9457355..4871795759 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -225,15 +225,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricField(value: 1, unit: ElectricField.BaseUnit); + var expectedUnit = ElectricField.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -248,13 +255,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricField(value: 1, unit: ElectricField.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricField(value: 1, unit: ElectricField.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricField(value: 1, unit: ElectricField.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -267,13 +278,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricField(value: 1, unit: ElectricField.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricField(value: 1, unit: ElectricField.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricField(value: 1, unit: ElectricField.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 V/m", ElectricFieldUnit.VoltPerMeter, 4.2)] public void Parse(string culture, string quantityString, ElectricFieldUnit expectedUnit, double expectedValue) diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricImpedanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricImpedanceTestsBase.g.cs index a27ea66477..61b4092eda 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricImpedanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricImpedanceTestsBase.g.cs @@ -267,15 +267,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricImpedance(value: 1, unit: ElectricImpedance.BaseUnit); + var expectedUnit = ElectricImpedance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -290,13 +297,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricImpedance(value: 1, unit: ElectricImpedance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricImpedance(value: 1, unit: ElectricImpedance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricImpedance(value: 1, unit: ElectricImpedance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -309,13 +320,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricImpedance(value: 1, unit: ElectricImpedance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricImpedance(value: 1, unit: ElectricImpedance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricImpedance(value: 1, unit: ElectricImpedance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 GΩ", ElectricImpedanceUnit.Gigaohm, 4.2)] [InlineData("en-US", "4.2 kΩ", ElectricImpedanceUnit.Kiloohm, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index 88f5bb2386..c52256b465 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -249,15 +249,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricInductance(value: 1, unit: ElectricInductance.BaseUnit); + var expectedUnit = ElectricInductance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -272,13 +279,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricInductance(value: 1, unit: ElectricInductance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricInductance(value: 1, unit: ElectricInductance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricInductance(value: 1, unit: ElectricInductance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -291,13 +302,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricInductance(value: 1, unit: ElectricInductance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricInductance(value: 1, unit: ElectricInductance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricInductance(value: 1, unit: ElectricInductance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 H", ElectricInductanceUnit.Henry, 4.2)] [InlineData("en-US", "4.2 µH", ElectricInductanceUnit.Microhenry, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index c2362a019b..dadaac73d6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -339,15 +339,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricPotentialChangeRate(value: 1, unit: ElectricPotentialChangeRate.BaseUnit); + var expectedUnit = ElectricPotentialChangeRate.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -362,13 +369,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricPotentialChangeRate(value: 1, unit: ElectricPotentialChangeRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricPotentialChangeRate(value: 1, unit: ElectricPotentialChangeRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricPotentialChangeRate(value: 1, unit: ElectricPotentialChangeRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -381,13 +392,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricPotentialChangeRate(value: 1, unit: ElectricPotentialChangeRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricPotentialChangeRate(value: 1, unit: ElectricPotentialChangeRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricPotentialChangeRate(value: 1, unit: ElectricPotentialChangeRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 kV/h", ElectricPotentialChangeRateUnit.KilovoltPerHour, 4.2)] [InlineData("en-US", "4.2 kV/μs", ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 6a3eada06c..bab3e31985 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -255,15 +255,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricPotential(value: 1, unit: ElectricPotential.BaseUnit); + var expectedUnit = ElectricPotential.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -278,13 +285,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricPotential(value: 1, unit: ElectricPotential.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricPotential(value: 1, unit: ElectricPotential.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricPotential(value: 1, unit: ElectricPotential.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -297,13 +308,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricPotential(value: 1, unit: ElectricPotential.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricPotential(value: 1, unit: ElectricPotential.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricPotential(value: 1, unit: ElectricPotential.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 kV", ElectricPotentialUnit.Kilovolt, 4.2)] [InlineData("en-US", "4.2 MV", ElectricPotentialUnit.Megavolt, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactanceTestsBase.g.cs index 40b501aced..f520d34671 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactanceTestsBase.g.cs @@ -267,15 +267,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricReactance(value: 1, unit: ElectricReactance.BaseUnit); + var expectedUnit = ElectricReactance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -290,13 +297,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricReactance(value: 1, unit: ElectricReactance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricReactance(value: 1, unit: ElectricReactance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricReactance(value: 1, unit: ElectricReactance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -309,13 +320,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricReactance(value: 1, unit: ElectricReactance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricReactance(value: 1, unit: ElectricReactance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricReactance(value: 1, unit: ElectricReactance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 GΩ", ElectricReactanceUnit.Gigaohm, 4.2)] [InlineData("en-US", "4.2 kΩ", ElectricReactanceUnit.Kiloohm, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactiveEnergyTestsBase.g.cs index 4b8ebe25dd..a8c7fbc9e4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactiveEnergyTestsBase.g.cs @@ -237,15 +237,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricReactiveEnergy(value: 1, unit: ElectricReactiveEnergy.BaseUnit); + var expectedUnit = ElectricReactiveEnergy.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -260,13 +267,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricReactiveEnergy(value: 1, unit: ElectricReactiveEnergy.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricReactiveEnergy(value: 1, unit: ElectricReactiveEnergy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricReactiveEnergy(value: 1, unit: ElectricReactiveEnergy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -279,13 +290,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricReactiveEnergy(value: 1, unit: ElectricReactiveEnergy.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricReactiveEnergy(value: 1, unit: ElectricReactiveEnergy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricReactiveEnergy(value: 1, unit: ElectricReactiveEnergy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 kvarh", ElectricReactiveEnergyUnit.KilovoltampereReactiveHour, 4.2)] [InlineData("en-US", "4.2 Mvarh", ElectricReactiveEnergyUnit.MegavoltampereReactiveHour, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactivePowerTestsBase.g.cs index e9530a1d0b..9252b9e59e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricReactivePowerTestsBase.g.cs @@ -243,15 +243,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricReactivePower(value: 1, unit: ElectricReactivePower.BaseUnit); + var expectedUnit = ElectricReactivePower.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -266,13 +273,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricReactivePower(value: 1, unit: ElectricReactivePower.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricReactivePower(value: 1, unit: ElectricReactivePower.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricReactivePower(value: 1, unit: ElectricReactivePower.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -285,13 +296,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricReactivePower(value: 1, unit: ElectricReactivePower.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricReactivePower(value: 1, unit: ElectricReactivePower.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricReactivePower(value: 1, unit: ElectricReactivePower.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 Gvar", ElectricReactivePowerUnit.GigavoltampereReactive, 4.2)] [InlineData("en-US", "4.2 kvar", ElectricReactivePowerUnit.KilovoltampereReactive, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 4e4beec69b..5d3f5c9cf0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -267,15 +267,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricResistance(value: 1, unit: ElectricResistance.BaseUnit); + var expectedUnit = ElectricResistance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -290,13 +297,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricResistance(value: 1, unit: ElectricResistance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricResistance(value: 1, unit: ElectricResistance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricResistance(value: 1, unit: ElectricResistance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -309,13 +320,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricResistance(value: 1, unit: ElectricResistance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricResistance(value: 1, unit: ElectricResistance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricResistance(value: 1, unit: ElectricResistance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 GΩ", ElectricResistanceUnit.Gigaohm, 4.2)] [InlineData("en-US", "4.2 kΩ", ElectricResistanceUnit.Kiloohm, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index bab1a72fb1..c4a30f8349 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -303,15 +303,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricResistivity(value: 1, unit: ElectricResistivity.BaseUnit); + var expectedUnit = ElectricResistivity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -326,13 +333,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricResistivity(value: 1, unit: ElectricResistivity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricResistivity(value: 1, unit: ElectricResistivity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricResistivity(value: 1, unit: ElectricResistivity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -345,13 +356,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricResistivity(value: 1, unit: ElectricResistivity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricResistivity(value: 1, unit: ElectricResistivity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricResistivity(value: 1, unit: ElectricResistivity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 kΩ·cm", ElectricResistivityUnit.KiloohmCentimeter, 4.2)] [InlineData("en-US", "4.2 kΩ·m", ElectricResistivityUnit.KiloohmMeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 360ae1f993..d39dba513b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -237,15 +237,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricSurfaceChargeDensity(value: 1, unit: ElectricSurfaceChargeDensity.BaseUnit); + var expectedUnit = ElectricSurfaceChargeDensity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -260,13 +267,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricSurfaceChargeDensity(value: 1, unit: ElectricSurfaceChargeDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricSurfaceChargeDensity(value: 1, unit: ElectricSurfaceChargeDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricSurfaceChargeDensity(value: 1, unit: ElectricSurfaceChargeDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -279,13 +290,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricSurfaceChargeDensity(value: 1, unit: ElectricSurfaceChargeDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricSurfaceChargeDensity(value: 1, unit: ElectricSurfaceChargeDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricSurfaceChargeDensity(value: 1, unit: ElectricSurfaceChargeDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 C/cm²", ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, 4.2)] [InlineData("en-US", "4.2 C/in²", ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSusceptanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSusceptanceTestsBase.g.cs index ea9ccf0786..2b66a0de39 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSusceptanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSusceptanceTestsBase.g.cs @@ -315,15 +315,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ElectricSusceptance(value: 1, unit: ElectricSusceptance.BaseUnit); + var expectedUnit = ElectricSusceptance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -338,13 +345,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ElectricSusceptance(value: 1, unit: ElectricSusceptance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricSusceptance(value: 1, unit: ElectricSusceptance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ElectricSusceptance(value: 1, unit: ElectricSusceptance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -357,13 +368,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ElectricSusceptance(value: 1, unit: ElectricSusceptance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ElectricSusceptance(value: 1, unit: ElectricSusceptance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ElectricSusceptance(value: 1, unit: ElectricSusceptance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 G℧", ElectricSusceptanceUnit.Gigamho, 4.2)] [InlineData("en-US", "4.2 GS", ElectricSusceptanceUnit.Gigasiemens, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs index de46b29630..f63fc68783 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs @@ -291,15 +291,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new EnergyDensity(value: 1, unit: EnergyDensity.BaseUnit); + var expectedUnit = EnergyDensity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -314,13 +321,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new EnergyDensity(value: 1, unit: EnergyDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new EnergyDensity(value: 1, unit: EnergyDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new EnergyDensity(value: 1, unit: EnergyDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -333,13 +344,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new EnergyDensity(value: 1, unit: EnergyDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new EnergyDensity(value: 1, unit: EnergyDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new EnergyDensity(value: 1, unit: EnergyDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 GJ/m³", EnergyDensityUnit.GigajoulePerCubicMeter, 4.2)] [InlineData("en-US", "4.2 GWh/m³", EnergyDensityUnit.GigawattHourPerCubicMeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index 46342e0dd5..6b68f3ec28 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -459,15 +459,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Energy(value: 1, unit: Energy.BaseUnit); + var expectedUnit = Energy.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -482,13 +489,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Energy(value: 1, unit: Energy.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Energy(value: 1, unit: Energy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Energy(value: 1, unit: Energy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -501,13 +512,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Energy(value: 1, unit: Energy.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Energy(value: 1, unit: Energy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Energy(value: 1, unit: Energy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 BTU", EnergyUnit.BritishThermalUnit, 4.2)] [InlineData("en-US", "4.2 cal", EnergyUnit.Calorie, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index b0bd82c725..5be6549b6c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -261,15 +261,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Entropy(value: 1, unit: Entropy.BaseUnit); + var expectedUnit = Entropy.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -284,13 +291,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Entropy(value: 1, unit: Entropy.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Entropy(value: 1, unit: Entropy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Entropy(value: 1, unit: Entropy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -303,13 +314,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Entropy(value: 1, unit: Entropy.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Entropy(value: 1, unit: Entropy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Entropy(value: 1, unit: Entropy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cal/K", EntropyUnit.CaloriePerKelvin, 4.2)] [InlineData("en-US", "4.2 J/°C", EntropyUnit.JoulePerDegreeCelsius, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs index 504647f596..c65c410d75 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs @@ -333,15 +333,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new FluidResistance(value: 1, unit: FluidResistance.BaseUnit); + var expectedUnit = FluidResistance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -356,13 +363,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new FluidResistance(value: 1, unit: FluidResistance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new FluidResistance(value: 1, unit: FluidResistance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new FluidResistance(value: 1, unit: FluidResistance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -375,13 +386,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new FluidResistance(value: 1, unit: FluidResistance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new FluidResistance(value: 1, unit: FluidResistance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new FluidResistance(value: 1, unit: FluidResistance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 dyn·s/cm⁵", FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, 4.2)] [InlineData("en-US", "4.2 dyn·s·cm⁻⁵", FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index e7b5a2a0d2..71b1df898f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -309,15 +309,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ForceChangeRate(value: 1, unit: ForceChangeRate.BaseUnit); + var expectedUnit = ForceChangeRate.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -332,13 +339,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ForceChangeRate(value: 1, unit: ForceChangeRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ForceChangeRate(value: 1, unit: ForceChangeRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ForceChangeRate(value: 1, unit: ForceChangeRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -351,13 +362,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ForceChangeRate(value: 1, unit: ForceChangeRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ForceChangeRate(value: 1, unit: ForceChangeRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ForceChangeRate(value: 1, unit: ForceChangeRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cN/s", ForceChangeRateUnit.CentinewtonPerSecond, 4.2)] [InlineData("en-US", "4.2 daN/min", ForceChangeRateUnit.DecanewtonPerMinute, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 79a120348d..b9bd16c3a1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -447,15 +447,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ForcePerLength(value: 1, unit: ForcePerLength.BaseUnit); + var expectedUnit = ForcePerLength.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -470,13 +477,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ForcePerLength(value: 1, unit: ForcePerLength.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ForcePerLength(value: 1, unit: ForcePerLength.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ForcePerLength(value: 1, unit: ForcePerLength.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -489,13 +500,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ForcePerLength(value: 1, unit: ForcePerLength.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ForcePerLength(value: 1, unit: ForcePerLength.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ForcePerLength(value: 1, unit: ForcePerLength.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cN/cm", ForcePerLengthUnit.CentinewtonPerCentimeter, 4.2)] [InlineData("en-US", "4.2 cN/m", ForcePerLengthUnit.CentinewtonPerMeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index 7684d4657a..b1196a7cf8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -309,15 +309,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Force(value: 1, unit: Force.BaseUnit); + var expectedUnit = Force.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -332,13 +339,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Force(value: 1, unit: Force.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Force(value: 1, unit: Force.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Force(value: 1, unit: Force.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -351,13 +362,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Force(value: 1, unit: Force.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Force(value: 1, unit: Force.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Force(value: 1, unit: Force.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 daN", ForceUnit.Decanewton, 4.2)] [InlineData("en-US", "4.2 dyn", ForceUnit.Dyn, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index d99d688de3..516f83da0b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -291,15 +291,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Frequency(value: 1, unit: Frequency.BaseUnit); + var expectedUnit = Frequency.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -314,13 +321,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Frequency(value: 1, unit: Frequency.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Frequency(value: 1, unit: Frequency.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Frequency(value: 1, unit: Frequency.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -333,13 +344,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Frequency(value: 1, unit: Frequency.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Frequency(value: 1, unit: Frequency.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Frequency(value: 1, unit: Frequency.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 bpm", FrequencyUnit.BeatPerMinute, 4.2)] [InlineData("en-US", "4.2 cph", FrequencyUnit.CyclePerHour, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 909a78875c..d9c6c56302 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -243,15 +243,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new FuelEfficiency(value: 1, unit: FuelEfficiency.BaseUnit); + var expectedUnit = FuelEfficiency.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -266,13 +273,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new FuelEfficiency(value: 1, unit: FuelEfficiency.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new FuelEfficiency(value: 1, unit: FuelEfficiency.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new FuelEfficiency(value: 1, unit: FuelEfficiency.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -285,13 +296,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new FuelEfficiency(value: 1, unit: FuelEfficiency.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new FuelEfficiency(value: 1, unit: FuelEfficiency.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new FuelEfficiency(value: 1, unit: FuelEfficiency.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 km/l", FuelEfficiencyUnit.KilometerPerLiter, 4.2)] [InlineData("en-US", "4.2 l/100km", FuelEfficiencyUnit.LiterPer100Kilometers, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index bb4c95a230..c8e08b7beb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -327,15 +327,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new HeatFlux(value: 1, unit: HeatFlux.BaseUnit); + var expectedUnit = HeatFlux.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -350,13 +357,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new HeatFlux(value: 1, unit: HeatFlux.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new HeatFlux(value: 1, unit: HeatFlux.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new HeatFlux(value: 1, unit: HeatFlux.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -369,13 +380,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new HeatFlux(value: 1, unit: HeatFlux.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new HeatFlux(value: 1, unit: HeatFlux.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new HeatFlux(value: 1, unit: HeatFlux.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 BTU/(h·ft²)", HeatFluxUnit.BtuPerHourSquareFoot, 4.2)] [InlineData("en-US", "4.2 BTU/(min·ft²)", HeatFluxUnit.BtuPerMinuteSquareFoot, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index c9c8df3fe6..60694c3d86 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -249,15 +249,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new HeatTransferCoefficient(value: 1, unit: HeatTransferCoefficient.BaseUnit); + var expectedUnit = HeatTransferCoefficient.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -272,13 +279,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new HeatTransferCoefficient(value: 1, unit: HeatTransferCoefficient.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new HeatTransferCoefficient(value: 1, unit: HeatTransferCoefficient.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new HeatTransferCoefficient(value: 1, unit: HeatTransferCoefficient.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -291,13 +302,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new HeatTransferCoefficient(value: 1, unit: HeatTransferCoefficient.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new HeatTransferCoefficient(value: 1, unit: HeatTransferCoefficient.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new HeatTransferCoefficient(value: 1, unit: HeatTransferCoefficient.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 Btu/(h·ft²·°F)", HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit, 4.2)] [InlineData("en-US", "4.2 Btu/(ft²·h·°F)", HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index c0123246dd..0d21c5fe14 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -243,15 +243,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Illuminance(value: 1, unit: Illuminance.BaseUnit); + var expectedUnit = Illuminance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -266,13 +273,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Illuminance(value: 1, unit: Illuminance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Illuminance(value: 1, unit: Illuminance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Illuminance(value: 1, unit: Illuminance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -285,13 +296,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Illuminance(value: 1, unit: Illuminance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Illuminance(value: 1, unit: Illuminance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Illuminance(value: 1, unit: Illuminance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 klx", IlluminanceUnit.Kilolux, 4.2)] [InlineData("en-US", "4.2 lx", IlluminanceUnit.Lux, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs index 588adbe83c..66e6a5974e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs @@ -297,15 +297,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Impulse(value: 1, unit: Impulse.BaseUnit); + var expectedUnit = Impulse.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -320,13 +327,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Impulse(value: 1, unit: Impulse.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Impulse(value: 1, unit: Impulse.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Impulse(value: 1, unit: Impulse.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -339,13 +350,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Impulse(value: 1, unit: Impulse.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Impulse(value: 1, unit: Impulse.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Impulse(value: 1, unit: Impulse.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cN·s", ImpulseUnit.CentinewtonSecond, 4.2)] [InlineData("en-US", "4.2 daN·s", ImpulseUnit.DecanewtonSecond, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index b13a344d02..c42b7a0489 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -394,7 +394,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -412,17 +412,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(InformationUnit.Bit, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new Information(value: 1, unit: InformationUnit.Bit); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new Information(value: 1, unit: InformationUnit.Bit); - Assert.Equal(InformationUnit.Bit, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(InformationUnit.Bit, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -430,15 +434,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new Information(value: 1, unit: Information.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new Information(value: 1, unit: Information.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new Information(value: 1, unit: Information.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index b7a99a9b51..b672a3b7cc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -303,15 +303,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Irradiance(value: 1, unit: Irradiance.BaseUnit); + var expectedUnit = Irradiance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -326,13 +333,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Irradiance(value: 1, unit: Irradiance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Irradiance(value: 1, unit: Irradiance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Irradiance(value: 1, unit: Irradiance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -345,13 +356,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Irradiance(value: 1, unit: Irradiance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Irradiance(value: 1, unit: Irradiance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Irradiance(value: 1, unit: Irradiance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 kW/cm²", IrradianceUnit.KilowattPerSquareCentimeter, 4.2)] [InlineData("en-US", "4.2 kW/m²", IrradianceUnit.KilowattPerSquareMeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index 3eadeb7bce..8b513e1156 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -273,15 +273,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Irradiation(value: 1, unit: Irradiation.BaseUnit); + var expectedUnit = Irradiation.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -296,13 +303,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Irradiation(value: 1, unit: Irradiation.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Irradiation(value: 1, unit: Irradiation.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Irradiation(value: 1, unit: Irradiation.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -315,13 +326,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Irradiation(value: 1, unit: Irradiation.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Irradiation(value: 1, unit: Irradiation.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Irradiation(value: 1, unit: Irradiation.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 Btu/ft²", IrradiationUnit.BtuPerSquareFoot, 4.2)] [InlineData("en-US", "4.2 J/cm²", IrradiationUnit.JoulePerSquareCentimeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs index c7d8e65294..5c6a2cda5b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs @@ -285,15 +285,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Jerk(value: 1, unit: Jerk.BaseUnit); + var expectedUnit = Jerk.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -308,13 +315,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Jerk(value: 1, unit: Jerk.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Jerk(value: 1, unit: Jerk.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Jerk(value: 1, unit: Jerk.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -327,13 +338,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Jerk(value: 1, unit: Jerk.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Jerk(value: 1, unit: Jerk.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Jerk(value: 1, unit: Jerk.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cm/s³", JerkUnit.CentimeterPerSecondCubed, 4.2)] [InlineData("en-US", "4.2 dm/s³", JerkUnit.DecimeterPerSecondCubed, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 08eb436500..4b500c381f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -273,15 +273,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new KinematicViscosity(value: 1, unit: KinematicViscosity.BaseUnit); + var expectedUnit = KinematicViscosity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -296,13 +303,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new KinematicViscosity(value: 1, unit: KinematicViscosity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new KinematicViscosity(value: 1, unit: KinematicViscosity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new KinematicViscosity(value: 1, unit: KinematicViscosity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -315,13 +326,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new KinematicViscosity(value: 1, unit: KinematicViscosity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new KinematicViscosity(value: 1, unit: KinematicViscosity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new KinematicViscosity(value: 1, unit: KinematicViscosity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cSt", KinematicViscosityUnit.Centistokes, 4.2)] [InlineData("en-US", "4.2 dSt", KinematicViscosityUnit.Decistokes, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs index 7f69da4fd0..94a6edf1a4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs @@ -243,15 +243,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new LeakRate(value: 1, unit: LeakRate.BaseUnit); + var expectedUnit = LeakRate.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -266,13 +273,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new LeakRate(value: 1, unit: LeakRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new LeakRate(value: 1, unit: LeakRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new LeakRate(value: 1, unit: LeakRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -285,13 +296,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new LeakRate(value: 1, unit: LeakRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new LeakRate(value: 1, unit: LeakRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new LeakRate(value: 1, unit: LeakRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 atm·cm³/s", LeakRateUnit.AtmCubicCentimeterPerSecond, 4.2)] [InlineData("en-US", "4.2 mbar·l/s", LeakRateUnit.MillibarLiterPerSecond, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 9784633fef..c69a0a0fe8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -471,15 +471,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Length(value: 1, unit: Length.BaseUnit); + var expectedUnit = Length.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -494,13 +501,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Length(value: 1, unit: Length.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Length(value: 1, unit: Length.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Length(value: 1, unit: Length.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -513,13 +524,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Length(value: 1, unit: Length.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Length(value: 1, unit: Length.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Length(value: 1, unit: Length.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 Å", LengthUnit.Angstrom, 4.2)] [InlineData("en-US", "4.2 A", LengthUnit.Angstrom, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index fab610762b..62060ed89a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -172,7 +172,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -190,17 +190,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(LevelUnit.Decibel, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new Level(value: 1, unit: LevelUnit.Decibel); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new Level(value: 1, unit: LevelUnit.Decibel); - Assert.Equal(LevelUnit.Decibel, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(LevelUnit.Decibel, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -208,15 +212,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new Level(value: 1, unit: Level.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new Level(value: 1, unit: Level.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new Level(value: 1, unit: Level.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index 78188e9796..cc57a73bcd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -327,15 +327,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new LinearDensity(value: 1, unit: LinearDensity.BaseUnit); + var expectedUnit = LinearDensity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -350,13 +357,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new LinearDensity(value: 1, unit: LinearDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new LinearDensity(value: 1, unit: LinearDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new LinearDensity(value: 1, unit: LinearDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -369,13 +380,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new LinearDensity(value: 1, unit: LinearDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new LinearDensity(value: 1, unit: LinearDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new LinearDensity(value: 1, unit: LinearDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 g/cm", LinearDensityUnit.GramPerCentimeter, 4.2)] [InlineData("en-US", "4.2 g/ft", LinearDensityUnit.GramPerFoot, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index a2e7d7efeb..f923eb7d3a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -369,15 +369,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new LinearPowerDensity(value: 1, unit: LinearPowerDensity.BaseUnit); + var expectedUnit = LinearPowerDensity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -392,13 +399,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new LinearPowerDensity(value: 1, unit: LinearPowerDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new LinearPowerDensity(value: 1, unit: LinearPowerDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new LinearPowerDensity(value: 1, unit: LinearPowerDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -411,13 +422,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new LinearPowerDensity(value: 1, unit: LinearPowerDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new LinearPowerDensity(value: 1, unit: LinearPowerDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new LinearPowerDensity(value: 1, unit: LinearPowerDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 GW/cm", LinearPowerDensityUnit.GigawattPerCentimeter, 4.2)] [InlineData("en-US", "4.2 GW/ft", LinearPowerDensityUnit.GigawattPerFoot, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs index 1bb3f898d1..486f7febff 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs @@ -279,15 +279,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Luminance(value: 1, unit: Luminance.BaseUnit); + var expectedUnit = Luminance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -302,13 +309,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Luminance(value: 1, unit: Luminance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Luminance(value: 1, unit: Luminance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Luminance(value: 1, unit: Luminance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -321,13 +332,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Luminance(value: 1, unit: Luminance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Luminance(value: 1, unit: Luminance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Luminance(value: 1, unit: Luminance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 Cd/ft²", LuminanceUnit.CandelaPerSquareFoot, 4.2)] [InlineData("en-US", "4.2 Cd/in²", LuminanceUnit.CandelaPerSquareInch, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index ac90ce43dc..ce10be03ec 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -303,15 +303,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Luminosity(value: 1, unit: Luminosity.BaseUnit); + var expectedUnit = Luminosity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -326,13 +333,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Luminosity(value: 1, unit: Luminosity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Luminosity(value: 1, unit: Luminosity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Luminosity(value: 1, unit: Luminosity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -345,13 +356,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Luminosity(value: 1, unit: Luminosity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Luminosity(value: 1, unit: Luminosity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Luminosity(value: 1, unit: Luminosity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 daW", LuminosityUnit.Decawatt, 4.2)] [InlineData("en-US", "4.2 dW", LuminosityUnit.Deciwatt, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index 15ae63e01b..69e75babc7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -225,15 +225,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new LuminousFlux(value: 1, unit: LuminousFlux.BaseUnit); + var expectedUnit = LuminousFlux.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -248,13 +255,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new LuminousFlux(value: 1, unit: LuminousFlux.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new LuminousFlux(value: 1, unit: LuminousFlux.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new LuminousFlux(value: 1, unit: LuminousFlux.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -267,13 +278,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new LuminousFlux(value: 1, unit: LuminousFlux.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new LuminousFlux(value: 1, unit: LuminousFlux.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new LuminousFlux(value: 1, unit: LuminousFlux.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 lm", LuminousFluxUnit.Lumen, 4.2)] public void Parse(string culture, string quantityString, LuminousFluxUnit expectedUnit, double expectedValue) diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index 1371cfae9b..6257383d39 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -225,15 +225,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new LuminousIntensity(value: 1, unit: LuminousIntensity.BaseUnit); + var expectedUnit = LuminousIntensity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -248,13 +255,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new LuminousIntensity(value: 1, unit: LuminousIntensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new LuminousIntensity(value: 1, unit: LuminousIntensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new LuminousIntensity(value: 1, unit: LuminousIntensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -267,13 +278,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new LuminousIntensity(value: 1, unit: LuminousIntensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new LuminousIntensity(value: 1, unit: LuminousIntensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new LuminousIntensity(value: 1, unit: LuminousIntensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cd", LuminousIntensityUnit.Candela, 4.2)] public void Parse(string culture, string quantityString, LuminousIntensityUnit expectedUnit, double expectedValue) diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index 8162379133..9b8c34a6d4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -255,15 +255,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new MagneticField(value: 1, unit: MagneticField.BaseUnit); + var expectedUnit = MagneticField.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -278,13 +285,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new MagneticField(value: 1, unit: MagneticField.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new MagneticField(value: 1, unit: MagneticField.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new MagneticField(value: 1, unit: MagneticField.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -297,13 +308,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new MagneticField(value: 1, unit: MagneticField.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new MagneticField(value: 1, unit: MagneticField.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new MagneticField(value: 1, unit: MagneticField.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 G", MagneticFieldUnit.Gauss, 4.2)] [InlineData("en-US", "4.2 µT", MagneticFieldUnit.Microtesla, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index 9a3d929f9f..1ed30187de 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -225,15 +225,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new MagneticFlux(value: 1, unit: MagneticFlux.BaseUnit); + var expectedUnit = MagneticFlux.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -248,13 +255,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new MagneticFlux(value: 1, unit: MagneticFlux.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new MagneticFlux(value: 1, unit: MagneticFlux.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new MagneticFlux(value: 1, unit: MagneticFlux.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -267,13 +278,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new MagneticFlux(value: 1, unit: MagneticFlux.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new MagneticFlux(value: 1, unit: MagneticFlux.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new MagneticFlux(value: 1, unit: MagneticFlux.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 Wb", MagneticFluxUnit.Weber, 4.2)] public void Parse(string culture, string quantityString, MagneticFluxUnit expectedUnit, double expectedValue) diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index 927192c114..fcb8e82192 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -225,15 +225,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Magnetization(value: 1, unit: Magnetization.BaseUnit); + var expectedUnit = Magnetization.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -248,13 +255,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Magnetization(value: 1, unit: Magnetization.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Magnetization(value: 1, unit: Magnetization.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Magnetization(value: 1, unit: Magnetization.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -267,13 +278,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Magnetization(value: 1, unit: Magnetization.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Magnetization(value: 1, unit: Magnetization.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Magnetization(value: 1, unit: Magnetization.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 A/m", MagnetizationUnit.AmperePerMeter, 4.2)] public void Parse(string culture, string quantityString, MagnetizationUnit expectedUnit, double expectedValue) diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 20f0728a09..b4ea373245 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -513,15 +513,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new MassConcentration(value: 1, unit: MassConcentration.BaseUnit); + var expectedUnit = MassConcentration.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -536,13 +543,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new MassConcentration(value: 1, unit: MassConcentration.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new MassConcentration(value: 1, unit: MassConcentration.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new MassConcentration(value: 1, unit: MassConcentration.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -555,13 +566,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new MassConcentration(value: 1, unit: MassConcentration.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new MassConcentration(value: 1, unit: MassConcentration.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new MassConcentration(value: 1, unit: MassConcentration.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cg/dl", MassConcentrationUnit.CentigramPerDeciliter, 4.2)] [InlineData("en-US", "4.2 cg/l", MassConcentrationUnit.CentigramPerLiter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 62d5a28dc6..1007bedb84 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -417,15 +417,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new MassFlow(value: 1, unit: MassFlow.BaseUnit); + var expectedUnit = MassFlow.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -440,13 +447,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new MassFlow(value: 1, unit: MassFlow.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new MassFlow(value: 1, unit: MassFlow.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new MassFlow(value: 1, unit: MassFlow.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -459,13 +470,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new MassFlow(value: 1, unit: MassFlow.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new MassFlow(value: 1, unit: MassFlow.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new MassFlow(value: 1, unit: MassFlow.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cg/d", MassFlowUnit.CentigramPerDay, 4.2)] [InlineData("en-US", "4.2 cg/s", MassFlowUnit.CentigramPerSecond, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index 0a66cff4b7..ecd9b4a0c0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -291,15 +291,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new MassFlux(value: 1, unit: MassFlux.BaseUnit); + var expectedUnit = MassFlux.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -314,13 +321,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new MassFlux(value: 1, unit: MassFlux.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new MassFlux(value: 1, unit: MassFlux.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new MassFlux(value: 1, unit: MassFlux.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -333,13 +344,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new MassFlux(value: 1, unit: MassFlux.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new MassFlux(value: 1, unit: MassFlux.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new MassFlux(value: 1, unit: MassFlux.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 g·h⁻¹·cm⁻²", MassFluxUnit.GramPerHourPerSquareCentimeter, 4.2)] [InlineData("en-US", "4.2 g·h⁻¹·m⁻²", MassFluxUnit.GramPerHourPerSquareMeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index c70b729cb8..d957c538c8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -304,7 +304,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -322,17 +322,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(MassFractionUnit.DecimalFraction, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new MassFraction(value: 1, unit: MassFractionUnit.DecimalFraction); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new MassFraction(value: 1, unit: MassFractionUnit.DecimalFraction); - Assert.Equal(MassFractionUnit.DecimalFraction, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(MassFractionUnit.DecimalFraction, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -340,15 +344,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new MassFraction(value: 1, unit: MassFraction.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new MassFraction(value: 1, unit: MassFraction.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new MassFraction(value: 1, unit: MassFraction.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index efe36ce8e8..cbcc1f622e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -387,15 +387,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new MassMomentOfInertia(value: 1, unit: MassMomentOfInertia.BaseUnit); + var expectedUnit = MassMomentOfInertia.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -410,13 +417,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new MassMomentOfInertia(value: 1, unit: MassMomentOfInertia.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new MassMomentOfInertia(value: 1, unit: MassMomentOfInertia.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new MassMomentOfInertia(value: 1, unit: MassMomentOfInertia.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -429,13 +440,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new MassMomentOfInertia(value: 1, unit: MassMomentOfInertia.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new MassMomentOfInertia(value: 1, unit: MassMomentOfInertia.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new MassMomentOfInertia(value: 1, unit: MassMomentOfInertia.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 g·cm²", MassMomentOfInertiaUnit.GramSquareCentimeter, 4.2)] [InlineData("en-US", "4.2 g·dm²", MassMomentOfInertiaUnit.GramSquareDecimeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index df85889f01..b2c238a2d4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -381,15 +381,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Mass(value: 1, unit: Mass.BaseUnit); + var expectedUnit = Mass.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -404,13 +411,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Mass(value: 1, unit: Mass.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Mass(value: 1, unit: Mass.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Mass(value: 1, unit: Mass.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -423,13 +434,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Mass(value: 1, unit: Mass.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Mass(value: 1, unit: Mass.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Mass(value: 1, unit: Mass.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cg", MassUnit.Centigram, 4.2)] [InlineData("en-US", "4.2 dag", MassUnit.Decagram, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs index 646479bfbb..5443d12d23 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs @@ -237,15 +237,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Molality(value: 1, unit: Molality.BaseUnit); + var expectedUnit = Molality.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -260,13 +267,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Molality(value: 1, unit: Molality.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Molality(value: 1, unit: Molality.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Molality(value: 1, unit: Molality.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -279,13 +290,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Molality(value: 1, unit: Molality.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Molality(value: 1, unit: Molality.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Molality(value: 1, unit: Molality.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 mmol/kg", MolalityUnit.MillimolePerKilogram, 4.2)] [InlineData("en-US", "4.2 mol/g", MolalityUnit.MolePerGram, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 7abe276628..332fabe6b6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -237,15 +237,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new MolarEnergy(value: 1, unit: MolarEnergy.BaseUnit); + var expectedUnit = MolarEnergy.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -260,13 +267,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new MolarEnergy(value: 1, unit: MolarEnergy.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new MolarEnergy(value: 1, unit: MolarEnergy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new MolarEnergy(value: 1, unit: MolarEnergy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -279,13 +290,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new MolarEnergy(value: 1, unit: MolarEnergy.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new MolarEnergy(value: 1, unit: MolarEnergy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new MolarEnergy(value: 1, unit: MolarEnergy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 J/mol", MolarEnergyUnit.JoulePerMole, 4.2)] [InlineData("en-US", "4.2 kJ/mol", MolarEnergyUnit.KilojoulePerMole, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 263ac67342..5c36626f22 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -237,15 +237,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new MolarEntropy(value: 1, unit: MolarEntropy.BaseUnit); + var expectedUnit = MolarEntropy.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -260,13 +267,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new MolarEntropy(value: 1, unit: MolarEntropy.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new MolarEntropy(value: 1, unit: MolarEntropy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new MolarEntropy(value: 1, unit: MolarEntropy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -279,13 +290,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new MolarEntropy(value: 1, unit: MolarEntropy.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new MolarEntropy(value: 1, unit: MolarEntropy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new MolarEntropy(value: 1, unit: MolarEntropy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 J/(mol·K)", MolarEntropyUnit.JoulePerMoleKelvin, 4.2)] [InlineData("en-US", "4.2 kJ/(mol·K)", MolarEntropyUnit.KilojoulePerMoleKelvin, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs index a33abc8053..987cde502d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs @@ -273,15 +273,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new MolarFlow(value: 1, unit: MolarFlow.BaseUnit); + var expectedUnit = MolarFlow.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -296,13 +303,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new MolarFlow(value: 1, unit: MolarFlow.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new MolarFlow(value: 1, unit: MolarFlow.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new MolarFlow(value: 1, unit: MolarFlow.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -315,13 +326,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new MolarFlow(value: 1, unit: MolarFlow.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new MolarFlow(value: 1, unit: MolarFlow.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new MolarFlow(value: 1, unit: MolarFlow.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 kkmol/h", MolarFlowUnit.KilomolePerHour, 4.2)] [InlineData("en-US", "4.2 kmol/min", MolarFlowUnit.KilomolePerMinute, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index 48851541c0..851833d560 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -297,15 +297,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new MolarMass(value: 1, unit: MolarMass.BaseUnit); + var expectedUnit = MolarMass.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -320,13 +327,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new MolarMass(value: 1, unit: MolarMass.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new MolarMass(value: 1, unit: MolarMass.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new MolarMass(value: 1, unit: MolarMass.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -339,13 +350,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new MolarMass(value: 1, unit: MolarMass.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new MolarMass(value: 1, unit: MolarMass.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new MolarMass(value: 1, unit: MolarMass.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cg/mol", MolarMassUnit.CentigramPerMole, 4.2)] [InlineData("en-US", "4.2 dag/mol", MolarMassUnit.DecagramPerMole, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index a9e6108ad1..4d8333fed7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -285,15 +285,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Molarity(value: 1, unit: Molarity.BaseUnit); + var expectedUnit = Molarity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -308,13 +315,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Molarity(value: 1, unit: Molarity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Molarity(value: 1, unit: Molarity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Molarity(value: 1, unit: Molarity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -327,13 +338,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Molarity(value: 1, unit: Molarity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Molarity(value: 1, unit: Molarity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Molarity(value: 1, unit: Molarity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cmol/l", MolarityUnit.CentimolePerLiter, 4.2)] [InlineData("en-US", "4.2 cM", MolarityUnit.CentimolePerLiter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index 2988c541d2..cb65b5b9e8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -225,15 +225,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Permeability(value: 1, unit: Permeability.BaseUnit); + var expectedUnit = Permeability.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -248,13 +255,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Permeability(value: 1, unit: Permeability.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Permeability(value: 1, unit: Permeability.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Permeability(value: 1, unit: Permeability.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -267,13 +278,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Permeability(value: 1, unit: Permeability.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Permeability(value: 1, unit: Permeability.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Permeability(value: 1, unit: Permeability.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 H/m", PermeabilityUnit.HenryPerMeter, 4.2)] public void Parse(string culture, string quantityString, PermeabilityUnit expectedUnit, double expectedValue) diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 8d6148c19a..fee87ec3aa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -225,15 +225,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Permittivity(value: 1, unit: Permittivity.BaseUnit); + var expectedUnit = Permittivity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -248,13 +255,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Permittivity(value: 1, unit: Permittivity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Permittivity(value: 1, unit: Permittivity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Permittivity(value: 1, unit: Permittivity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -267,13 +278,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Permittivity(value: 1, unit: Permittivity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Permittivity(value: 1, unit: Permittivity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Permittivity(value: 1, unit: Permittivity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 F/m", PermittivityUnit.FaradPerMeter, 4.2)] public void Parse(string culture, string quantityString, PermittivityUnit expectedUnit, double expectedValue) diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs index 3c097c6022..65c890210b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs @@ -249,15 +249,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new PorousMediumPermeability(value: 1, unit: PorousMediumPermeability.BaseUnit); + var expectedUnit = PorousMediumPermeability.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -272,13 +279,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new PorousMediumPermeability(value: 1, unit: PorousMediumPermeability.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new PorousMediumPermeability(value: 1, unit: PorousMediumPermeability.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new PorousMediumPermeability(value: 1, unit: PorousMediumPermeability.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -291,13 +302,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new PorousMediumPermeability(value: 1, unit: PorousMediumPermeability.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new PorousMediumPermeability(value: 1, unit: PorousMediumPermeability.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new PorousMediumPermeability(value: 1, unit: PorousMediumPermeability.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 D", PorousMediumPermeabilityUnit.Darcy, 4.2)] [InlineData("en-US", "4.2 µD", PorousMediumPermeabilityUnit.Microdarcy, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index d2a8f328aa..bc8898263b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -483,15 +483,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new PowerDensity(value: 1, unit: PowerDensity.BaseUnit); + var expectedUnit = PowerDensity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -506,13 +513,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new PowerDensity(value: 1, unit: PowerDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new PowerDensity(value: 1, unit: PowerDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new PowerDensity(value: 1, unit: PowerDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -525,13 +536,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new PowerDensity(value: 1, unit: PowerDensity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new PowerDensity(value: 1, unit: PowerDensity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new PowerDensity(value: 1, unit: PowerDensity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 daW/ft³", PowerDensityUnit.DecawattPerCubicFoot, 4.2)] [InlineData("en-US", "4.2 daW/in³", PowerDensityUnit.DecawattPerCubicInch, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 92ea6d4337..5aef0f93c7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -172,7 +172,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -190,17 +190,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(PowerRatioUnit.DecibelWatt, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new PowerRatio(value: 1, unit: PowerRatioUnit.DecibelWatt); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new PowerRatio(value: 1, unit: PowerRatioUnit.DecibelWatt); - Assert.Equal(PowerRatioUnit.DecibelWatt, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(PowerRatioUnit.DecibelWatt, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -208,15 +212,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new PowerRatio(value: 1, unit: PowerRatio.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new PowerRatio(value: 1, unit: PowerRatio.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new PowerRatio(value: 1, unit: PowerRatio.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index eedd6abe74..9475ce2578 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -381,15 +381,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Power(value: 1, unit: Power.BaseUnit); + var expectedUnit = Power.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -404,13 +411,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Power(value: 1, unit: Power.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Power(value: 1, unit: Power.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Power(value: 1, unit: Power.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -423,13 +434,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Power(value: 1, unit: Power.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Power(value: 1, unit: Power.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Power(value: 1, unit: Power.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 hp(S)", PowerUnit.BoilerHorsepower, 4.2)] [InlineData("en-US", "4.2 Btu/h", PowerUnit.BritishThermalUnitPerHour, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index add5669a40..c74e46c776 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -327,15 +327,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new PressureChangeRate(value: 1, unit: PressureChangeRate.BaseUnit); + var expectedUnit = PressureChangeRate.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -350,13 +357,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new PressureChangeRate(value: 1, unit: PressureChangeRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new PressureChangeRate(value: 1, unit: PressureChangeRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new PressureChangeRate(value: 1, unit: PressureChangeRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -369,13 +380,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new PressureChangeRate(value: 1, unit: PressureChangeRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new PressureChangeRate(value: 1, unit: PressureChangeRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new PressureChangeRate(value: 1, unit: PressureChangeRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 atm/s", PressureChangeRateUnit.AtmospherePerSecond, 4.2)] [InlineData("en-US", "4.2 bar/min", PressureChangeRateUnit.BarPerMinute, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index d366d4d450..2e76518d12 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -507,15 +507,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Pressure(value: 1, unit: Pressure.BaseUnit); + var expectedUnit = Pressure.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -530,13 +537,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Pressure(value: 1, unit: Pressure.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Pressure(value: 1, unit: Pressure.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Pressure(value: 1, unit: Pressure.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -549,13 +560,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Pressure(value: 1, unit: Pressure.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Pressure(value: 1, unit: Pressure.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Pressure(value: 1, unit: Pressure.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 atm", PressureUnit.Atmosphere, 4.2)] [InlineData("en-US", "4.2 bar", PressureUnit.Bar, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs index 8d37a23dea..4d4672a5ff 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs @@ -279,15 +279,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new RadiationEquivalentDoseRate(value: 1, unit: RadiationEquivalentDoseRate.BaseUnit); + var expectedUnit = RadiationEquivalentDoseRate.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -302,13 +309,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new RadiationEquivalentDoseRate(value: 1, unit: RadiationEquivalentDoseRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new RadiationEquivalentDoseRate(value: 1, unit: RadiationEquivalentDoseRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new RadiationEquivalentDoseRate(value: 1, unit: RadiationEquivalentDoseRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -321,13 +332,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new RadiationEquivalentDoseRate(value: 1, unit: RadiationEquivalentDoseRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new RadiationEquivalentDoseRate(value: 1, unit: RadiationEquivalentDoseRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new RadiationEquivalentDoseRate(value: 1, unit: RadiationEquivalentDoseRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 µSv/h", RadiationEquivalentDoseRateUnit.MicrosievertPerHour, 4.2)] [InlineData("en-US", "4.2 µSv/s", RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs index 9ad579fa36..f7557c5d79 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs @@ -255,15 +255,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new RadiationEquivalentDose(value: 1, unit: RadiationEquivalentDose.BaseUnit); + var expectedUnit = RadiationEquivalentDose.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -278,13 +285,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new RadiationEquivalentDose(value: 1, unit: RadiationEquivalentDose.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new RadiationEquivalentDose(value: 1, unit: RadiationEquivalentDose.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new RadiationEquivalentDose(value: 1, unit: RadiationEquivalentDose.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -297,13 +308,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new RadiationEquivalentDose(value: 1, unit: RadiationEquivalentDose.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new RadiationEquivalentDose(value: 1, unit: RadiationEquivalentDose.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new RadiationEquivalentDose(value: 1, unit: RadiationEquivalentDose.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 µSv", RadiationEquivalentDoseUnit.Microsievert, 4.2)] [InlineData("en-US", "4.2 mrem", RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs index fd94570653..e6424e2e13 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs @@ -267,15 +267,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new RadiationExposure(value: 1, unit: RadiationExposure.BaseUnit); + var expectedUnit = RadiationExposure.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -290,13 +297,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new RadiationExposure(value: 1, unit: RadiationExposure.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new RadiationExposure(value: 1, unit: RadiationExposure.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new RadiationExposure(value: 1, unit: RadiationExposure.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -309,13 +320,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new RadiationExposure(value: 1, unit: RadiationExposure.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new RadiationExposure(value: 1, unit: RadiationExposure.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new RadiationExposure(value: 1, unit: RadiationExposure.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 C/kg", RadiationExposureUnit.CoulombPerKilogram, 4.2)] [InlineData("en-US", "4.2 µC/kg", RadiationExposureUnit.MicrocoulombPerKilogram, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs index bc77719229..5eed4f3d92 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs @@ -393,15 +393,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Radioactivity(value: 1, unit: Radioactivity.BaseUnit); + var expectedUnit = Radioactivity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -416,13 +423,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Radioactivity(value: 1, unit: Radioactivity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Radioactivity(value: 1, unit: Radioactivity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Radioactivity(value: 1, unit: Radioactivity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -435,13 +446,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Radioactivity(value: 1, unit: Radioactivity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Radioactivity(value: 1, unit: Radioactivity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Radioactivity(value: 1, unit: Radioactivity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 Bq", RadioactivityUnit.Becquerel, 4.2)] [InlineData("en-US", "4.2 Ci", RadioactivityUnit.Curie, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index a6613f7118..bd18e90323 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -231,15 +231,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new RatioChangeRate(value: 1, unit: RatioChangeRate.BaseUnit); + var expectedUnit = RatioChangeRate.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -254,13 +261,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new RatioChangeRate(value: 1, unit: RatioChangeRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new RatioChangeRate(value: 1, unit: RatioChangeRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new RatioChangeRate(value: 1, unit: RatioChangeRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -273,13 +284,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new RatioChangeRate(value: 1, unit: RatioChangeRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new RatioChangeRate(value: 1, unit: RatioChangeRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new RatioChangeRate(value: 1, unit: RatioChangeRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 /s", RatioChangeRateUnit.DecimalFractionPerSecond, 4.2)] [InlineData("en-US", "4.2 %/s", RatioChangeRateUnit.PercentPerSecond, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index edc87a9a0e..49e44d12e1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -196,7 +196,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -214,17 +214,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(RatioUnit.DecimalFraction, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new Ratio(value: 1, unit: RatioUnit.DecimalFraction); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new Ratio(value: 1, unit: RatioUnit.DecimalFraction); - Assert.Equal(RatioUnit.DecimalFraction, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(RatioUnit.DecimalFraction, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -232,15 +236,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new Ratio(value: 1, unit: Ratio.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new Ratio(value: 1, unit: Ratio.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new Ratio(value: 1, unit: Ratio.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 7808d5d397..598bf4bc3c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -285,15 +285,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ReciprocalArea(value: 1, unit: ReciprocalArea.BaseUnit); + var expectedUnit = ReciprocalArea.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -308,13 +315,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ReciprocalArea(value: 1, unit: ReciprocalArea.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ReciprocalArea(value: 1, unit: ReciprocalArea.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ReciprocalArea(value: 1, unit: ReciprocalArea.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -327,13 +338,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ReciprocalArea(value: 1, unit: ReciprocalArea.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ReciprocalArea(value: 1, unit: ReciprocalArea.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ReciprocalArea(value: 1, unit: ReciprocalArea.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cm⁻²", ReciprocalAreaUnit.InverseSquareCentimeter, 4.2)] [InlineData("en-US", "4.2 dm⁻²", ReciprocalAreaUnit.InverseSquareDecimeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index d20ff6da22..5f8950c3a6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -279,15 +279,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ReciprocalLength(value: 1, unit: ReciprocalLength.BaseUnit); + var expectedUnit = ReciprocalLength.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -302,13 +309,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ReciprocalLength(value: 1, unit: ReciprocalLength.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ReciprocalLength(value: 1, unit: ReciprocalLength.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ReciprocalLength(value: 1, unit: ReciprocalLength.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -321,13 +332,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ReciprocalLength(value: 1, unit: ReciprocalLength.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ReciprocalLength(value: 1, unit: ReciprocalLength.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ReciprocalLength(value: 1, unit: ReciprocalLength.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cm⁻¹", ReciprocalLengthUnit.InverseCentimeter, 4.2)] [InlineData("en-US", "4.2 1/cm", ReciprocalLengthUnit.InverseCentimeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index 5fded5f2a9..adcd7bbb99 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -166,7 +166,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -184,17 +184,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(RelativeHumidityUnit.Percent, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new RelativeHumidity(value: 1, unit: RelativeHumidityUnit.Percent); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new RelativeHumidity(value: 1, unit: RelativeHumidityUnit.Percent); - Assert.Equal(RelativeHumidityUnit.Percent, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(RelativeHumidityUnit.Percent, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -202,15 +206,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new RelativeHumidity(value: 1, unit: RelativeHumidity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new RelativeHumidity(value: 1, unit: RelativeHumidity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new RelativeHumidity(value: 1, unit: RelativeHumidity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 60588811f8..678c977c33 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -243,15 +243,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new RotationalAcceleration(value: 1, unit: RotationalAcceleration.BaseUnit); + var expectedUnit = RotationalAcceleration.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -266,13 +273,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new RotationalAcceleration(value: 1, unit: RotationalAcceleration.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new RotationalAcceleration(value: 1, unit: RotationalAcceleration.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new RotationalAcceleration(value: 1, unit: RotationalAcceleration.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -285,13 +296,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new RotationalAcceleration(value: 1, unit: RotationalAcceleration.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new RotationalAcceleration(value: 1, unit: RotationalAcceleration.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new RotationalAcceleration(value: 1, unit: RotationalAcceleration.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 °/s²", RotationalAccelerationUnit.DegreePerSecondSquared, 4.2)] [InlineData("en-US", "4.2 deg/s²", RotationalAccelerationUnit.DegreePerSecondSquared, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index cf103de422..fa5ef846e2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -297,15 +297,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new RotationalSpeed(value: 1, unit: RotationalSpeed.BaseUnit); + var expectedUnit = RotationalSpeed.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -320,13 +327,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new RotationalSpeed(value: 1, unit: RotationalSpeed.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new RotationalSpeed(value: 1, unit: RotationalSpeed.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new RotationalSpeed(value: 1, unit: RotationalSpeed.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -339,13 +350,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new RotationalSpeed(value: 1, unit: RotationalSpeed.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new RotationalSpeed(value: 1, unit: RotationalSpeed.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new RotationalSpeed(value: 1, unit: RotationalSpeed.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 crad/s", RotationalSpeedUnit.CentiradianPerSecond, 4.2)] [InlineData("en-US", "4.2 drad/s", RotationalSpeedUnit.DeciradianPerSecond, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index 0014931af0..3e0a660659 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -249,15 +249,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new RotationalStiffnessPerLength(value: 1, unit: RotationalStiffnessPerLength.BaseUnit); + var expectedUnit = RotationalStiffnessPerLength.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -272,13 +279,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new RotationalStiffnessPerLength(value: 1, unit: RotationalStiffnessPerLength.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new RotationalStiffnessPerLength(value: 1, unit: RotationalStiffnessPerLength.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new RotationalStiffnessPerLength(value: 1, unit: RotationalStiffnessPerLength.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -291,13 +302,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new RotationalStiffnessPerLength(value: 1, unit: RotationalStiffnessPerLength.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new RotationalStiffnessPerLength(value: 1, unit: RotationalStiffnessPerLength.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new RotationalStiffnessPerLength(value: 1, unit: RotationalStiffnessPerLength.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 kN·m/rad/m", RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, 4.2)] [InlineData("en-US", "4.2 kNm/rad/m", RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index fc45c09cdb..b827277f41 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -417,15 +417,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new RotationalStiffness(value: 1, unit: RotationalStiffness.BaseUnit); + var expectedUnit = RotationalStiffness.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -440,13 +447,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new RotationalStiffness(value: 1, unit: RotationalStiffness.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new RotationalStiffness(value: 1, unit: RotationalStiffness.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new RotationalStiffness(value: 1, unit: RotationalStiffness.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -459,13 +470,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new RotationalStiffness(value: 1, unit: RotationalStiffness.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new RotationalStiffness(value: 1, unit: RotationalStiffness.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new RotationalStiffness(value: 1, unit: RotationalStiffness.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cN·m/deg", RotationalStiffnessUnit.CentinewtonMeterPerDegree, 4.2)] [InlineData("en-US", "4.2 cNm/deg", RotationalStiffnessUnit.CentinewtonMeterPerDegree, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index d30402b194..a483f5954e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -166,7 +166,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -184,17 +184,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(ScalarUnit.Amount, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new Scalar(value: 1, unit: ScalarUnit.Amount); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new Scalar(value: 1, unit: ScalarUnit.Amount); - Assert.Equal(ScalarUnit.Amount, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(ScalarUnit.Amount, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -202,15 +206,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new Scalar(value: 1, unit: Scalar.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new Scalar(value: 1, unit: Scalar.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new Scalar(value: 1, unit: Scalar.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 1e81e68c02..410e851faa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -166,7 +166,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -184,17 +184,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(SolidAngleUnit.Steradian, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new SolidAngle(value: 1, unit: SolidAngleUnit.Steradian); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new SolidAngle(value: 1, unit: SolidAngleUnit.Steradian); - Assert.Equal(SolidAngleUnit.Steradian, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(SolidAngleUnit.Steradian, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -202,15 +206,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new SolidAngle(value: 1, unit: SolidAngle.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new SolidAngle(value: 1, unit: SolidAngle.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new SolidAngle(value: 1, unit: SolidAngle.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 0d396006a4..e796178a68 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -399,15 +399,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new SpecificEnergy(value: 1, unit: SpecificEnergy.BaseUnit); + var expectedUnit = SpecificEnergy.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -422,13 +429,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new SpecificEnergy(value: 1, unit: SpecificEnergy.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new SpecificEnergy(value: 1, unit: SpecificEnergy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new SpecificEnergy(value: 1, unit: SpecificEnergy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -441,13 +452,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new SpecificEnergy(value: 1, unit: SpecificEnergy.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new SpecificEnergy(value: 1, unit: SpecificEnergy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new SpecificEnergy(value: 1, unit: SpecificEnergy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 btu/lb", SpecificEnergyUnit.BtuPerPound, 4.2)] [InlineData("en-US", "4.2 cal/g", SpecificEnergyUnit.CaloriePerGram, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index 194c471823..06596157f7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -273,15 +273,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new SpecificEntropy(value: 1, unit: SpecificEntropy.BaseUnit); + var expectedUnit = SpecificEntropy.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -296,13 +303,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new SpecificEntropy(value: 1, unit: SpecificEntropy.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new SpecificEntropy(value: 1, unit: SpecificEntropy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new SpecificEntropy(value: 1, unit: SpecificEntropy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -315,13 +326,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new SpecificEntropy(value: 1, unit: SpecificEntropy.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new SpecificEntropy(value: 1, unit: SpecificEntropy.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new SpecificEntropy(value: 1, unit: SpecificEntropy.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 BTU/(lb·°F)", SpecificEntropyUnit.BtuPerPoundFahrenheit, 4.2)] [InlineData("en-US", "4.2 BTU/(lbm·°F)", SpecificEntropyUnit.BtuPerPoundFahrenheit, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index 7aa5c77d22..9af48365b7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -243,15 +243,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new SpecificFuelConsumption(value: 1, unit: SpecificFuelConsumption.BaseUnit); + var expectedUnit = SpecificFuelConsumption.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -266,13 +273,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new SpecificFuelConsumption(value: 1, unit: SpecificFuelConsumption.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new SpecificFuelConsumption(value: 1, unit: SpecificFuelConsumption.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new SpecificFuelConsumption(value: 1, unit: SpecificFuelConsumption.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -285,13 +296,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new SpecificFuelConsumption(value: 1, unit: SpecificFuelConsumption.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new SpecificFuelConsumption(value: 1, unit: SpecificFuelConsumption.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new SpecificFuelConsumption(value: 1, unit: SpecificFuelConsumption.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 g/(kN·s)", SpecificFuelConsumptionUnit.GramPerKilonewtonSecond, 4.2)] [InlineData("en-US", "4.2 kg/(kgf·h)", SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 3838e6bbb1..0233cd2c17 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -237,15 +237,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new SpecificVolume(value: 1, unit: SpecificVolume.BaseUnit); + var expectedUnit = SpecificVolume.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -260,13 +267,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new SpecificVolume(value: 1, unit: SpecificVolume.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new SpecificVolume(value: 1, unit: SpecificVolume.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new SpecificVolume(value: 1, unit: SpecificVolume.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -279,13 +290,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new SpecificVolume(value: 1, unit: SpecificVolume.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new SpecificVolume(value: 1, unit: SpecificVolume.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new SpecificVolume(value: 1, unit: SpecificVolume.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 ft³/lb", SpecificVolumeUnit.CubicFootPerPound, 4.2)] [InlineData("en-US", "4.2 m³/kg", SpecificVolumeUnit.CubicMeterPerKilogram, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 7098c0ef5b..5ca94af9d2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -321,15 +321,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new SpecificWeight(value: 1, unit: SpecificWeight.BaseUnit); + var expectedUnit = SpecificWeight.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -344,13 +351,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new SpecificWeight(value: 1, unit: SpecificWeight.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new SpecificWeight(value: 1, unit: SpecificWeight.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new SpecificWeight(value: 1, unit: SpecificWeight.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -363,13 +374,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new SpecificWeight(value: 1, unit: SpecificWeight.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new SpecificWeight(value: 1, unit: SpecificWeight.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new SpecificWeight(value: 1, unit: SpecificWeight.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 kgf/cm³", SpecificWeightUnit.KilogramForcePerCubicCentimeter, 4.2)] [InlineData("en-US", "4.2 kgf/m³", SpecificWeightUnit.KilogramForcePerCubicMeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index 3640020921..0861b0207e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -417,15 +417,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Speed(value: 1, unit: Speed.BaseUnit); + var expectedUnit = Speed.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -440,13 +447,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Speed(value: 1, unit: Speed.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Speed(value: 1, unit: Speed.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Speed(value: 1, unit: Speed.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -459,13 +470,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Speed(value: 1, unit: Speed.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Speed(value: 1, unit: Speed.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Speed(value: 1, unit: Speed.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cm/h", SpeedUnit.CentimeterPerHour, 4.2)] [InlineData("en-US", "4.2 cm/min", SpeedUnit.CentimeterPerMinute, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index b8fc574603..9793fa684d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -273,15 +273,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new StandardVolumeFlow(value: 1, unit: StandardVolumeFlow.BaseUnit); + var expectedUnit = StandardVolumeFlow.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -296,13 +303,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new StandardVolumeFlow(value: 1, unit: StandardVolumeFlow.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new StandardVolumeFlow(value: 1, unit: StandardVolumeFlow.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new StandardVolumeFlow(value: 1, unit: StandardVolumeFlow.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -315,13 +326,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new StandardVolumeFlow(value: 1, unit: StandardVolumeFlow.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new StandardVolumeFlow(value: 1, unit: StandardVolumeFlow.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new StandardVolumeFlow(value: 1, unit: StandardVolumeFlow.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 sccm", StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute, 4.2)] [InlineData("en-US", "4.2 scfh", StandardVolumeFlowUnit.StandardCubicFootPerHour, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 1e5328b84d..680c47a200 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -321,15 +321,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new TemperatureChangeRate(value: 1, unit: TemperatureChangeRate.BaseUnit); + var expectedUnit = TemperatureChangeRate.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -344,13 +351,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new TemperatureChangeRate(value: 1, unit: TemperatureChangeRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new TemperatureChangeRate(value: 1, unit: TemperatureChangeRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new TemperatureChangeRate(value: 1, unit: TemperatureChangeRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -363,13 +374,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new TemperatureChangeRate(value: 1, unit: TemperatureChangeRate.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new TemperatureChangeRate(value: 1, unit: TemperatureChangeRate.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new TemperatureChangeRate(value: 1, unit: TemperatureChangeRate.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 c°C/s", TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, 4.2)] [InlineData("en-US", "4.2 da°C/s", TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 77211549ca..8be36bb55b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -273,15 +273,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new TemperatureDelta(value: 1, unit: TemperatureDelta.BaseUnit); + var expectedUnit = TemperatureDelta.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -296,13 +303,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new TemperatureDelta(value: 1, unit: TemperatureDelta.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new TemperatureDelta(value: 1, unit: TemperatureDelta.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new TemperatureDelta(value: 1, unit: TemperatureDelta.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -315,13 +326,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new TemperatureDelta(value: 1, unit: TemperatureDelta.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new TemperatureDelta(value: 1, unit: TemperatureDelta.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new TemperatureDelta(value: 1, unit: TemperatureDelta.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 ∆°C", TemperatureDeltaUnit.DegreeCelsius, 4.2)] [InlineData("en-US", "4.2 ∆°De", TemperatureDeltaUnit.DegreeDelisle, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs index b5c667680f..d0f91b13dc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs @@ -243,15 +243,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new TemperatureGradient(value: 1, unit: TemperatureGradient.BaseUnit); + var expectedUnit = TemperatureGradient.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -266,13 +273,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new TemperatureGradient(value: 1, unit: TemperatureGradient.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new TemperatureGradient(value: 1, unit: TemperatureGradient.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new TemperatureGradient(value: 1, unit: TemperatureGradient.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -285,13 +296,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new TemperatureGradient(value: 1, unit: TemperatureGradient.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new TemperatureGradient(value: 1, unit: TemperatureGradient.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new TemperatureGradient(value: 1, unit: TemperatureGradient.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 ∆°C/km", TemperatureGradientUnit.DegreeCelsiusPerKilometer, 4.2)] [InlineData("en-US", "4.2 ∆°C/m", TemperatureGradientUnit.DegreeCelsiusPerMeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index 6582eee93e..adb6da15f3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -279,15 +279,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Temperature(value: 1, unit: Temperature.BaseUnit); + var expectedUnit = Temperature.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -302,13 +309,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Temperature(value: 1, unit: Temperature.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Temperature(value: 1, unit: Temperature.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Temperature(value: 1, unit: Temperature.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -321,13 +332,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Temperature(value: 1, unit: Temperature.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Temperature(value: 1, unit: Temperature.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Temperature(value: 1, unit: Temperature.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 °C", TemperatureUnit.DegreeCelsius, 4.2)] [InlineData("en-US", "4.2 °De", TemperatureUnit.DegreeDelisle, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index d8b933f7ce..7e7d035f05 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -231,15 +231,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ThermalConductivity(value: 1, unit: ThermalConductivity.BaseUnit); + var expectedUnit = ThermalConductivity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -254,13 +261,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ThermalConductivity(value: 1, unit: ThermalConductivity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ThermalConductivity(value: 1, unit: ThermalConductivity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ThermalConductivity(value: 1, unit: ThermalConductivity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -273,13 +284,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ThermalConductivity(value: 1, unit: ThermalConductivity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ThermalConductivity(value: 1, unit: ThermalConductivity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ThermalConductivity(value: 1, unit: ThermalConductivity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 BTU/(h·ft·°F)", ThermalConductivityUnit.BtuPerHourFootFahrenheit, 4.2)] [InlineData("en-US", "4.2 W/(m·K)", ThermalConductivityUnit.WattPerMeterKelvin, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalInsulanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalInsulanceTestsBase.g.cs index 245ecb251d..a84982777f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalInsulanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalInsulanceTestsBase.g.cs @@ -261,15 +261,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ThermalInsulance(value: 1, unit: ThermalInsulance.BaseUnit); + var expectedUnit = ThermalInsulance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -284,13 +291,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ThermalInsulance(value: 1, unit: ThermalInsulance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ThermalInsulance(value: 1, unit: ThermalInsulance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ThermalInsulance(value: 1, unit: ThermalInsulance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -303,13 +314,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ThermalInsulance(value: 1, unit: ThermalInsulance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ThermalInsulance(value: 1, unit: ThermalInsulance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ThermalInsulance(value: 1, unit: ThermalInsulance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 Hrft²°F/Btu", ThermalInsulanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, 4.2)] [InlineData("en-US", "4.2 cm²Hr°C/kcal", ThermalInsulanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index ca4cdfa9fa..14d6a11532 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -231,15 +231,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new ThermalResistance(value: 1, unit: ThermalResistance.BaseUnit); + var expectedUnit = ThermalResistance.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -254,13 +261,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new ThermalResistance(value: 1, unit: ThermalResistance.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new ThermalResistance(value: 1, unit: ThermalResistance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new ThermalResistance(value: 1, unit: ThermalResistance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -273,13 +284,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new ThermalResistance(value: 1, unit: ThermalResistance.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new ThermalResistance(value: 1, unit: ThermalResistance.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new ThermalResistance(value: 1, unit: ThermalResistance.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 °C/W", ThermalResistanceUnit.DegreeCelsiusPerWatt, 4.2)] [InlineData("en-US", "4.2 K/W", ThermalResistanceUnit.KelvinPerWatt, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 1781a30eb0..28ab736f99 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -369,15 +369,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Torque(value: 1, unit: Torque.BaseUnit); + var expectedUnit = Torque.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -392,13 +399,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Torque(value: 1, unit: Torque.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Torque(value: 1, unit: Torque.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Torque(value: 1, unit: Torque.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -411,13 +422,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Torque(value: 1, unit: Torque.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Torque(value: 1, unit: Torque.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Torque(value: 1, unit: Torque.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 gf·cm", TorqueUnit.GramForceCentimeter, 4.2)] [InlineData("en-US", "4.2 gf·m", TorqueUnit.GramForceMeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 6ba7cf420a..d47b86d277 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -166,7 +166,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -184,17 +184,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(TurbidityUnit.NTU, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new Turbidity(value: 1, unit: TurbidityUnit.NTU); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new Turbidity(value: 1, unit: TurbidityUnit.NTU); - Assert.Equal(TurbidityUnit.NTU, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(TurbidityUnit.NTU, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -202,15 +206,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new Turbidity(value: 1, unit: Turbidity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new Turbidity(value: 1, unit: Turbidity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new Turbidity(value: 1, unit: Turbidity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 0881562e61..ebac154544 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -166,7 +166,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -184,17 +184,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(VitaminAUnit.InternationalUnit, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new VitaminA(value: 1, unit: VitaminAUnit.InternationalUnit); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new VitaminA(value: 1, unit: VitaminAUnit.InternationalUnit); - Assert.Equal(VitaminAUnit.InternationalUnit, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(VitaminAUnit.InternationalUnit, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -202,15 +206,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new VitaminA(value: 1, unit: VitaminA.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new VitaminA(value: 1, unit: VitaminA.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new VitaminA(value: 1, unit: VitaminA.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index 4483d20376..f782bfb5be 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -280,7 +280,7 @@ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() } [Fact] - public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + public void ToUnit_UnitSystem_ReturnsValueInDimensionlessUnit() { Assert.Multiple(() => { @@ -298,17 +298,21 @@ public void ToUnitSystem_ReturnsValueInDimensionlessUnit() Assert.Equal(VolumeConcentrationUnit.DecimalFraction, convertedQuantity.Unit); Assert.Equal(quantity.Value, convertedQuantity.Value); - }, () => - { - IQuantity quantity = new VolumeConcentration(value: 1, unit: VolumeConcentrationUnit.DecimalFraction); + }); + } - IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + [Fact] + public void ToUnitUntyped_UnitSystem_ReturnsValueInDimensionlessUnit() + { + IQuantity quantity = new VolumeConcentration(value: 1, unit: VolumeConcentrationUnit.DecimalFraction); - Assert.Equal(VolumeConcentrationUnit.DecimalFraction, convertedQuantity.Unit); - Assert.Equal(quantity.Value, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantity.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(VolumeConcentrationUnit.DecimalFraction, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { @@ -316,15 +320,15 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() Assert.Multiple(() => { var quantity = new VolumeConcentration(value: 1, unit: VolumeConcentration.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new VolumeConcentration(value: 1, unit: VolumeConcentration.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }, () => { IQuantity quantity = new VolumeConcentration(value: 1, unit: VolumeConcentration.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); }); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs index 22c5812c67..d90fb45e01 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs @@ -231,15 +231,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new VolumeFlowPerArea(value: 1, unit: VolumeFlowPerArea.BaseUnit); + var expectedUnit = VolumeFlowPerArea.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -254,13 +261,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new VolumeFlowPerArea(value: 1, unit: VolumeFlowPerArea.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new VolumeFlowPerArea(value: 1, unit: VolumeFlowPerArea.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new VolumeFlowPerArea(value: 1, unit: VolumeFlowPerArea.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -273,13 +284,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new VolumeFlowPerArea(value: 1, unit: VolumeFlowPerArea.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new VolumeFlowPerArea(value: 1, unit: VolumeFlowPerArea.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new VolumeFlowPerArea(value: 1, unit: VolumeFlowPerArea.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 CFM/ft²", VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot, 4.2)] [InlineData("en-US", "4.2 m³/(s·m²)", VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index 93b7e5f542..86e87fd581 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -669,15 +669,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new VolumeFlow(value: 1, unit: VolumeFlow.BaseUnit); + var expectedUnit = VolumeFlow.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -692,13 +699,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new VolumeFlow(value: 1, unit: VolumeFlow.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new VolumeFlow(value: 1, unit: VolumeFlow.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new VolumeFlow(value: 1, unit: VolumeFlow.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -711,13 +722,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new VolumeFlow(value: 1, unit: VolumeFlow.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new VolumeFlow(value: 1, unit: VolumeFlow.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new VolumeFlow(value: 1, unit: VolumeFlow.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 af/d", VolumeFlowUnit.AcreFootPerDay, 4.2)] [InlineData("en-US", "4.2 af/h", VolumeFlowUnit.AcreFootPerHour, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index bd8ad7442d..f9cada501c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -273,15 +273,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new VolumePerLength(value: 1, unit: VolumePerLength.BaseUnit); + var expectedUnit = VolumePerLength.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -296,13 +303,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new VolumePerLength(value: 1, unit: VolumePerLength.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new VolumePerLength(value: 1, unit: VolumePerLength.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new VolumePerLength(value: 1, unit: VolumePerLength.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -315,13 +326,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new VolumePerLength(value: 1, unit: VolumePerLength.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new VolumePerLength(value: 1, unit: VolumePerLength.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new VolumePerLength(value: 1, unit: VolumePerLength.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 m³/m", VolumePerLengthUnit.CubicMeterPerMeter, 4.2)] [InlineData("en-US", "4.2 yd³/ft", VolumePerLengthUnit.CubicYardPerFoot, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index a8ebd6d2e6..8def0e2cb0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -543,15 +543,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new Volume(value: 1, unit: Volume.BaseUnit); + var expectedUnit = Volume.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -566,13 +573,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new Volume(value: 1, unit: Volume.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new Volume(value: 1, unit: Volume.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new Volume(value: 1, unit: Volume.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -585,13 +596,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new Volume(value: 1, unit: Volume.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new Volume(value: 1, unit: Volume.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new Volume(value: 1, unit: Volume.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 ac-ft", VolumeUnit.AcreFoot, 4.2)] [InlineData("en-US", "4.2 acre-foot", VolumeUnit.AcreFoot, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 0d2d6149f9..b90ce99335 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -273,15 +273,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new VolumetricHeatCapacity(value: 1, unit: VolumetricHeatCapacity.BaseUnit); + var expectedUnit = VolumetricHeatCapacity.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -296,13 +303,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new VolumetricHeatCapacity(value: 1, unit: VolumetricHeatCapacity.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new VolumetricHeatCapacity(value: 1, unit: VolumetricHeatCapacity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new VolumetricHeatCapacity(value: 1, unit: VolumetricHeatCapacity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -315,13 +326,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new VolumetricHeatCapacity(value: 1, unit: VolumetricHeatCapacity.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new VolumetricHeatCapacity(value: 1, unit: VolumetricHeatCapacity.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new VolumetricHeatCapacity(value: 1, unit: VolumetricHeatCapacity.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 BTU/(ft³·°F)", VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit, 4.2)] [InlineData("en-US", "4.2 cal/(cm³·°C)", VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius, 4.2)] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 9a5a9076c8..86348b2cc0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -255,15 +255,22 @@ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() Assert.Equal(expectedUnit, convertedQuantity.Unit); Assert.Equal(expectedValue, convertedQuantity.Value); - }, () => - { - IQuantity quantityToConvert = quantity; + }); + } + + [Fact] + public virtual void ToUnitUntyped_UnitSystem_SI_ReturnsQuantityInSIUnits() + { + var quantity = new WarpingMomentOfInertia(value: 1, unit: WarpingMomentOfInertia.BaseUnit); + var expectedUnit = WarpingMomentOfInertia.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); - IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + IQuantity quantityToConvert = quantity; - Assert.Equal(expectedUnit, convertedQuantity.Unit); - Assert.Equal(expectedValue, convertedQuantity.Value); - }); + IQuantity convertedQuantity = quantityToConvert.ToUnitUntyped(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); } [Fact] @@ -278,13 +285,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() { IQuantity quantity = new WarpingMomentOfInertia(value: 1, unit: WarpingMomentOfInertia.BaseUnit); Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); - }, () => - { - IQuantity quantity = new WarpingMomentOfInertia(value: 1, unit: WarpingMomentOfInertia.BaseUnit); - Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentNullExceptionIfNull() + { + UnitSystem nullUnitSystem = null!; + IQuantity quantity = new WarpingMomentOfInertia(value: 1, unit: WarpingMomentOfInertia.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(nullUnitSystem)); + } + [Fact] public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { @@ -297,13 +308,17 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { IQuantity quantity = new WarpingMomentOfInertia(value: 1, unit: WarpingMomentOfInertia.BaseUnit); Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); - }, () => - { - IQuantity quantity = new WarpingMomentOfInertia(value: 1, unit: WarpingMomentOfInertia.BaseUnit); - Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); }); } + [Fact] + public void ToUnitUntyped_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + IQuantity quantity = new WarpingMomentOfInertia(value: 1, unit: WarpingMomentOfInertia.BaseUnit); + Assert.Throws(() => quantity.ToUnitUntyped(unsupportedUnitSystem)); + } + [Theory] [InlineData("en-US", "4.2 cm⁶", WarpingMomentOfInertiaUnit.CentimeterToTheSixth, 4.2)] [InlineData("en-US", "4.2 dm⁶", WarpingMomentOfInertiaUnit.DecimeterToTheSixth, 4.2)] diff --git a/UnitsNet/CustomCode/QuantityInfo/QuantityInfoExtensions.cs b/UnitsNet/CustomCode/QuantityInfo/QuantityInfoExtensions.cs index e12ffc0226..19642cd76f 100644 --- a/UnitsNet/CustomCode/QuantityInfo/QuantityInfoExtensions.cs +++ b/UnitsNet/CustomCode/QuantityInfo/QuantityInfoExtensions.cs @@ -64,4 +64,38 @@ internal static TUnit GetDefaultUnit(this QuantityInfo quantityInf return firstUnitInfo.Value; } + + /// + /// Retrieves the default unit for a specified quantity and unit system. + /// + /// + /// The instance containing information about the + /// quantity. + /// + /// The for which the default unit is to be retrieved. + /// The default unit information for the specified quantity and unit system. + /// Thrown when is null. + /// Thrown when no units are found for the given . + internal static UnitInfo GetDefaultUnit(this QuantityInfo quantityInfo, UnitSystem unitSystem) + { + if (unitSystem is null) + { + throw new ArgumentNullException(nameof(unitSystem)); + } + + if (quantityInfo.BaseDimensions.IsDimensionless()) + { + return quantityInfo.BaseUnitInfo; + } + + IEnumerable unitInfos = quantityInfo.GetUnitInfosFor(unitSystem.BaseUnits); + + UnitInfo? firstUnitInfo = unitInfos.FirstOrDefault(); + if (firstUnitInfo == null) + { + throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); + } + + return firstUnitInfo; + } } diff --git a/UnitsNet/Extensions/QuantityExtensions.cs b/UnitsNet/Extensions/QuantityExtensions.cs index 41f2ace803..f17e8ef477 100644 --- a/UnitsNet/Extensions/QuantityExtensions.cs +++ b/UnitsNet/Extensions/QuantityExtensions.cs @@ -3,6 +3,7 @@ using System.Globalization; +// ReSharper disable once CheckNamespace namespace UnitsNet; /// @@ -17,7 +18,86 @@ internal static double GetValue(this TQuantity quantity, UnitKey toUn { return quantity.As(toUnit); } - + + /// + /// Converts the quantity to a value in the unit determined by the specified . + /// If multiple units are found for the given , the first match will be used. + /// + /// The type of the quantity being converted. + /// The quantity to convert. + /// The to which the quantity value should be converted. + /// The value of the quantity in the specified unit system. + /// + /// Thrown if is null. + /// + /// + /// Thrown if no matching unit is found for the given . + /// + public static double As(this TQuantity quantity, UnitSystem unitSystem) + where TQuantity : IQuantity + { + return quantity.GetValue(quantity.QuantityInfo.GetDefaultUnit(unitSystem).UnitKey); + } + + /// + /// Converts the specified quantity to a new quantity with a unit determined by the given . + /// + /// + /// The type of the quantity to be converted. Must implement . + /// + /// The quantity to convert. + /// The used to determine the target unit. + /// + /// A new quantity of type with the unit determined by the specified + /// . + /// + /// + /// If multiple units are associated with the given , the first matching unit will be used. + /// + /// + /// Thrown if is null. + /// + /// + /// Thrown if no matching unit is found for the specified . + /// + public static TQuantity ToUnit(this TQuantity quantity, UnitSystem unitSystem) + where TQuantity : IQuantityOfType + { +#if NET + QuantityInfo quantityInfo = quantity.QuantityInfo; + UnitKey unitKey = quantityInfo.GetDefaultUnit(unitSystem).UnitKey; + return TQuantity.Create(quantity.As(unitKey), unitKey); +#else + QuantityInfo quantityInfo = ((IQuantity)quantity).QuantityInfo; + UnitKey unitKey = quantityInfo.GetDefaultUnit(unitSystem).UnitKey; + return quantity.QuantityInfo.Create(quantity.As(unitKey), unitKey); +#endif + } + + /// + /// Converts the specified quantity to a new quantity with a unit determined by the given . + /// + /// The quantity to convert. + /// The used to determine the target unit. + /// + /// A new quantity of the same type with the unit determined by the specified . + /// + /// + /// If multiple units are associated with the given , the first matching unit will be used. + /// + /// + /// Thrown if is null. + /// + /// + /// Thrown if no matching unit is found for the specified . + /// + public static IQuantity ToUnitUntyped(this IQuantity quantity, UnitSystem unitSystem) + { + QuantityInfo quantityInfo = quantity.QuantityInfo; + UnitKey unitKey = quantityInfo.GetDefaultUnit(unitSystem).UnitKey; + return quantityInfo.From(quantity.As(unitKey), unitKey); + } + /// /// Returns the string representation of the specified quantity using the provided format provider. /// @@ -71,7 +151,7 @@ internal static TQuantity ArithmeticMean(this IEnumerable { throw new ArgumentNullException(nameof(quantities)); } - + using IEnumerator enumerator = quantities.GetEnumerator(); if (!enumerator.MoveNext()) { @@ -117,7 +197,7 @@ internal static TQuantity ArithmeticMean(this IEnumerable enumerator = quantities.GetEnumerator(); if (!enumerator.MoveNext()) { diff --git a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs index fbe9d3a4d5..001be237b1 100644 --- a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs @@ -877,12 +877,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this AbsorbedDoseOfIonizingRadiation to another AbsorbedDoseOfIonizingRadiation with the unit representation . /// @@ -989,12 +983,6 @@ private bool TryToUnit(AbsorbedDoseOfIonizingRadiationUnit unit, [NotNullWhen(tr return true; } - /// - public AbsorbedDoseOfIonizingRadiation ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1014,14 +1002,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(AbsorbedDoseOfIonizingRadiationUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index f6a9d49a5c..ba539ba7ef 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -867,12 +867,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Acceleration to another Acceleration with the unit representation . /// @@ -973,12 +967,6 @@ private bool TryToUnit(AccelerationUnit unit, [NotNullWhen(true)] out Accelerati return true; } - /// - public Acceleration ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -998,14 +986,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(AccelerationUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 5fa15becd6..cc1e09c9e8 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -922,12 +922,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this AmountOfSubstance to another AmountOfSubstance with the unit representation . /// @@ -1034,12 +1028,6 @@ private bool TryToUnit(AmountOfSubstanceUnit unit, [NotNullWhen(true)] out Amoun return true; } - /// - public AmountOfSubstance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1059,14 +1047,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(AmountOfSubstanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 41bf9b836d..d10321d1ca 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -667,12 +667,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this AmplitudeRatio to another AmplitudeRatio with the unit representation . /// @@ -753,12 +747,6 @@ private bool TryToUnit(AmplitudeRatioUnit unit, [NotNullWhen(true)] out Amplitud return true; } - /// - public AmplitudeRatio ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -778,14 +766,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(AmplitudeRatioUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 846af3096f..ba36f7726d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -855,12 +855,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Angle to another Angle with the unit representation . /// @@ -963,12 +957,6 @@ private bool TryToUnit(AngleUnit unit, [NotNullWhen(true)] out Angle? converted) return true; } - /// - public Angle ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -988,14 +976,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(AngleUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index c9bbcf6329..38be3f47cb 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -951,12 +951,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Area to another Area with the unit representation . /// @@ -1057,12 +1051,6 @@ private bool TryToUnit(AreaUnit unit, [NotNullWhen(true)] out Area? converted) return true; } - /// - public Area ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1082,14 +1070,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(AreaUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index b0e4e1bbf9..c3d63ffdfe 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -663,12 +663,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this AreaDensity to another AreaDensity with the unit representation . /// @@ -747,12 +741,6 @@ private bool TryToUnit(AreaDensityUnit unit, [NotNullWhen(true)] out AreaDensity return true; } - /// - public AreaDensity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -772,14 +760,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(AreaDensityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 9d9f232be4..86f0a2a5f8 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -718,12 +718,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this AreaMomentOfInertia to another AreaMomentOfInertia with the unit representation . /// @@ -808,12 +802,6 @@ private bool TryToUnit(AreaMomentOfInertiaUnit unit, [NotNullWhen(true)] out Are return true; } - /// - public AreaMomentOfInertia ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -833,14 +821,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(AreaMomentOfInertiaUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index fc62a899a3..795dfc5db0 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -1229,12 +1229,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this BitRate to another BitRate with the unit representation . /// @@ -1385,12 +1379,6 @@ private bool TryToUnit(BitRateUnit unit, [NotNullWhen(true)] out BitRate? conver return true; } - /// - public BitRate ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1410,14 +1398,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(BitRateUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 6a44e29235..a290e0bbdc 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -676,12 +676,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this BrakeSpecificFuelConsumption to another BrakeSpecificFuelConsumption with the unit representation . /// @@ -760,12 +754,6 @@ private bool TryToUnit(BrakeSpecificFuelConsumptionUnit unit, [NotNullWhen(true) return true; } - /// - public BrakeSpecificFuelConsumption ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -785,14 +773,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(BrakeSpecificFuelConsumptionUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 8f732c9f77..3be0e767c6 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -711,12 +711,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this CoefficientOfThermalExpansion to another CoefficientOfThermalExpansion with the unit representation . /// @@ -801,12 +795,6 @@ private bool TryToUnit(CoefficientOfThermalExpansionUnit unit, [NotNullWhen(true return true; } - /// - public CoefficientOfThermalExpansion ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -826,14 +814,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(CoefficientOfThermalExpansionUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index 737627da9a..f55993a95b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -714,12 +714,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Compressibility to another Compressibility with the unit representation . /// @@ -806,12 +800,6 @@ private bool TryToUnit(CompressibilityUnit unit, [NotNullWhen(true)] out Compres return true; } - /// - public Compressibility ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -831,14 +819,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(CompressibilityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 69c65a4a4b..92032a6b04 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -1563,12 +1563,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Density to another Density with the unit representation . /// @@ -1753,12 +1747,6 @@ private bool TryToUnit(DensityUnit unit, [NotNullWhen(true)] out Density? conver return true; } - /// - public Density ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1778,14 +1766,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(DensityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs b/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs index 0be48a838c..b3818d1786 100644 --- a/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DoseAreaProduct.g.cs @@ -1005,12 +1005,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this DoseAreaProduct to another DoseAreaProduct with the unit representation . /// @@ -1133,12 +1127,6 @@ private bool TryToUnit(DoseAreaProductUnit unit, [NotNullWhen(true)] out DoseAre return true; } - /// - public DoseAreaProduct ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1158,14 +1146,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(DoseAreaProductUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 177523e824..3a06fd2756 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -921,12 +921,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Duration to another Duration with the unit representation . /// @@ -1025,12 +1019,6 @@ private bool TryToUnit(DurationUnit unit, [NotNullWhen(true)] out Duration? conv return true; } - /// - public Duration ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1050,14 +1038,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(DurationUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index e30c0a0a43..449dd43c7a 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -785,12 +785,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this DynamicViscosity to another DynamicViscosity with the unit representation . /// @@ -883,12 +877,6 @@ private bool TryToUnit(DynamicViscosityUnit unit, [NotNullWhen(true)] out Dynami return true; } - /// - public DynamicViscosity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -908,14 +896,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(DynamicViscosityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 30e7fa91cc..1da7b7e4b5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -862,12 +862,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricAdmittance to another ElectricAdmittance with the unit representation . /// @@ -972,12 +966,6 @@ private bool TryToUnit(ElectricAdmittanceUnit unit, [NotNullWhen(true)] out Elec return true; } - /// - public ElectricAdmittance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -997,14 +985,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricAdmittanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs index 914f9d6380..05afc2e869 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricApparentEnergy.g.cs @@ -650,12 +650,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricApparentEnergy to another ElectricApparentEnergy with the unit representation . /// @@ -734,12 +728,6 @@ private bool TryToUnit(ElectricApparentEnergyUnit unit, [NotNullWhen(true)] out return true; } - /// - public ElectricApparentEnergy ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -759,14 +747,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricApparentEnergyUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs index 6a23a7aa8f..52bfed06d4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricApparentPower.g.cs @@ -701,12 +701,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricApparentPower to another ElectricApparentPower with the unit representation . /// @@ -791,12 +785,6 @@ private bool TryToUnit(ElectricApparentPowerUnit unit, [NotNullWhen(true)] out E return true; } - /// - public ElectricApparentPower ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -816,14 +804,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricApparentPowerUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs index d3b195abdd..93cb706165 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCapacitance.g.cs @@ -717,12 +717,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricCapacitance to another ElectricCapacitance with the unit representation . /// @@ -809,12 +803,6 @@ private bool TryToUnit(ElectricCapacitanceUnit unit, [NotNullWhen(true)] out Ele return true; } - /// - public ElectricCapacitance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -834,14 +822,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricCapacitanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index 6334ba710e..e49f08f671 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -808,12 +808,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricCharge to another ElectricCharge with the unit representation . /// @@ -908,12 +902,6 @@ private bool TryToUnit(ElectricChargeUnit unit, [NotNullWhen(true)] out Electric return true; } - /// - public ElectricCharge ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -933,14 +921,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricChargeUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index faa3420561..a32ba0df62 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -621,12 +621,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricChargeDensity to another ElectricChargeDensity with the unit representation . /// @@ -701,12 +695,6 @@ private bool TryToUnit(ElectricChargeDensityUnit unit, [NotNullWhen(true)] out E return true; } - /// - public ElectricChargeDensity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -726,14 +714,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricChargeDensityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index 908ee65ca4..9741bc4ace 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -861,12 +861,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricConductance to another ElectricConductance with the unit representation . /// @@ -971,12 +965,6 @@ private bool TryToUnit(ElectricConductanceUnit unit, [NotNullWhen(true)] out Ele return true; } - /// - public ElectricConductance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -996,14 +984,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricConductanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 92f96fd430..f585cdff22 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -712,12 +712,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricConductivity to another ElectricConductivity with the unit representation . /// @@ -802,12 +796,6 @@ private bool TryToUnit(ElectricConductivityUnit unit, [NotNullWhen(true)] out El return true; } - /// - public ElectricConductivity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -827,14 +815,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricConductivityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 8c80e4fa27..6773f97ffc 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -790,12 +790,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricCurrent to another ElectricCurrent with the unit representation . /// @@ -886,12 +880,6 @@ private bool TryToUnit(ElectricCurrentUnit unit, [NotNullWhen(true)] out Electri return true; } - /// - public ElectricCurrent ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -911,14 +899,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricCurrentUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index ed55047ef8..617f60cfb0 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -653,12 +653,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricCurrentDensity to another ElectricCurrentDensity with the unit representation . /// @@ -737,12 +731,6 @@ private bool TryToUnit(ElectricCurrentDensityUnit unit, [NotNullWhen(true)] out return true; } - /// - public ElectricCurrentDensity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -762,14 +750,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricCurrentDensityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index fa857f5d19..c191919dc9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -727,12 +727,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricCurrentGradient to another ElectricCurrentGradient with the unit representation . /// @@ -819,12 +813,6 @@ private bool TryToUnit(ElectricCurrentGradientUnit unit, [NotNullWhen(true)] out return true; } - /// - public ElectricCurrentGradient ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -844,14 +832,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricCurrentGradientUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index 2eeb140dad..07001c7f41 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -621,12 +621,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricField to another ElectricField with the unit representation . /// @@ -701,12 +695,6 @@ private bool TryToUnit(ElectricFieldUnit unit, [NotNullWhen(true)] out ElectricF return true; } - /// - public ElectricField ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -726,14 +714,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricFieldUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs index ea8007ea55..4ab1778c5d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricImpedance.g.cs @@ -734,12 +734,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricImpedance to another ElectricImpedance with the unit representation . /// @@ -828,12 +822,6 @@ private bool TryToUnit(ElectricImpedanceUnit unit, [NotNullWhen(true)] out Elect return true; } - /// - public ElectricImpedance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -853,14 +841,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricImpedanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 23b73bf158..90401e091a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -685,12 +685,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricInductance to another ElectricInductance with the unit representation . /// @@ -773,12 +767,6 @@ private bool TryToUnit(ElectricInductanceUnit unit, [NotNullWhen(true)] out Elec return true; } - /// - public ElectricInductance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -798,14 +786,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricInductanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 5b34019916..414a7dea5b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -735,12 +735,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricPotential to another ElectricPotential with the unit representation . /// @@ -825,12 +819,6 @@ private bool TryToUnit(ElectricPotentialUnit unit, [NotNullWhen(true)] out Elect return true; } - /// - public ElectricPotential ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -850,14 +838,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricPotentialUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 981f293340..3a6eb7c47c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -922,12 +922,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricPotentialChangeRate to another ElectricPotentialChangeRate with the unit representation . /// @@ -1040,12 +1034,6 @@ private bool TryToUnit(ElectricPotentialChangeRateUnit unit, [NotNullWhen(true)] return true; } - /// - public ElectricPotentialChangeRate ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1065,14 +1053,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricPotentialChangeRateUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs index a51174dc90..1227e7683a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactance.g.cs @@ -733,12 +733,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricReactance to another ElectricReactance with the unit representation . /// @@ -827,12 +821,6 @@ private bool TryToUnit(ElectricReactanceUnit unit, [NotNullWhen(true)] out Elect return true; } - /// - public ElectricReactance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -852,14 +840,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricReactanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs index 0cd9922292..f8bf99c1e2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactiveEnergy.g.cs @@ -650,12 +650,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricReactiveEnergy to another ElectricReactiveEnergy with the unit representation . /// @@ -734,12 +728,6 @@ private bool TryToUnit(ElectricReactiveEnergyUnit unit, [NotNullWhen(true)] out return true; } - /// - public ElectricReactiveEnergy ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -759,14 +747,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricReactiveEnergyUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs index 79a161038a..f3dc6e12bc 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricReactivePower.g.cs @@ -669,12 +669,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricReactivePower to another ElectricReactivePower with the unit representation . /// @@ -755,12 +749,6 @@ private bool TryToUnit(ElectricReactivePowerUnit unit, [NotNullWhen(true)] out E return true; } - /// - public ElectricReactivePower ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -780,14 +768,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricReactivePowerUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 63394c6b68..df61ed438c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -746,12 +746,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricResistance to another ElectricResistance with the unit representation . /// @@ -840,12 +834,6 @@ private bool TryToUnit(ElectricResistanceUnit unit, [NotNullWhen(true)] out Elec return true; } - /// - public ElectricResistance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -865,14 +853,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricResistanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index e36ec8fe98..f9b39ce80c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -840,12 +840,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricResistivity to another ElectricResistivity with the unit representation . /// @@ -946,12 +940,6 @@ private bool TryToUnit(ElectricResistivityUnit unit, [NotNullWhen(true)] out Ele return true; } - /// - public ElectricResistivity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -971,14 +959,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricResistivityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index ad8aedf6ff..67e721b3ae 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -653,12 +653,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricSurfaceChargeDensity to another ElectricSurfaceChargeDensity with the unit representation . /// @@ -737,12 +731,6 @@ private bool TryToUnit(ElectricSurfaceChargeDensityUnit unit, [NotNullWhen(true) return true; } - /// - public ElectricSurfaceChargeDensity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -762,14 +750,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricSurfaceChargeDensityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs index 28a289d017..89d8a47c92 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSusceptance.g.cs @@ -861,12 +861,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ElectricSusceptance to another ElectricSusceptance with the unit representation . /// @@ -971,12 +965,6 @@ private bool TryToUnit(ElectricSusceptanceUnit unit, [NotNullWhen(true)] out Ele return true; } - /// - public ElectricSusceptance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -996,14 +984,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ElectricSusceptanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 461c050225..0d4cc2c05d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -1339,12 +1339,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Energy to another Energy with the unit representation . /// @@ -1497,12 +1491,6 @@ private bool TryToUnit(EnergyUnit unit, [NotNullWhen(true)] out Energy? converte return true; } - /// - public Energy ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1522,14 +1510,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(EnergyUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs index fa89880d5e..ef1da91623 100644 --- a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs @@ -807,12 +807,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this EnergyDensity to another EnergyDensity with the unit representation . /// @@ -909,12 +903,6 @@ private bool TryToUnit(EnergyDensityUnit unit, [NotNullWhen(true)] out EnergyDen return true; } - /// - public EnergyDensity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -934,14 +922,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(EnergyDensityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 9d856cac66..886b33b959 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -741,12 +741,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Entropy to another Entropy with the unit representation . /// @@ -833,12 +827,6 @@ private bool TryToUnit(EntropyUnit unit, [NotNullWhen(true)] out Entropy? conver return true; } - /// - public Entropy ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -858,14 +846,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(EntropyUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs index 636f440c35..1f78c35804 100644 --- a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs @@ -909,12 +909,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this FluidResistance to another FluidResistance with the unit representation . /// @@ -1025,12 +1019,6 @@ private bool TryToUnit(FluidResistanceUnit unit, [NotNullWhen(true)] out FluidRe return true; } - /// - public FluidResistance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1050,14 +1038,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(FluidResistanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 31d82a5595..88acce85ab 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -932,12 +932,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Force to another Force with the unit representation . /// @@ -1040,12 +1034,6 @@ private bool TryToUnit(ForceUnit unit, [NotNullWhen(true)] out Force? converted) return true; } - /// - public Force ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1065,14 +1053,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ForceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index badcaca9b7..6881c7e022 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -855,12 +855,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ForceChangeRate to another ForceChangeRate with the unit representation . /// @@ -963,12 +957,6 @@ private bool TryToUnit(ForceChangeRateUnit unit, [NotNullWhen(true)] out ForceCh return true; } - /// - public ForceChangeRate ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -988,14 +976,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ForceChangeRateUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 18e744827b..bb7d3f0173 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -1279,12 +1279,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ForcePerLength to another ForcePerLength with the unit representation . /// @@ -1433,12 +1427,6 @@ private bool TryToUnit(ForcePerLengthUnit unit, [NotNullWhen(true)] out ForcePer return true; } - /// - public ForcePerLength ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1458,14 +1446,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ForcePerLengthUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 0fafe817fc..39c84b07d3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -807,12 +807,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Frequency to another Frequency with the unit representation . /// @@ -909,12 +903,6 @@ private bool TryToUnit(FrequencyUnit unit, [NotNullWhen(true)] out Frequency? co return true; } - /// - public Frequency ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -934,14 +922,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(FrequencyUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index 7c334103a9..91a8398037 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -669,12 +669,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this FuelEfficiency to another FuelEfficiency with the unit representation . /// @@ -755,12 +749,6 @@ private bool TryToUnit(FuelEfficiencyUnit unit, [NotNullWhen(true)] out FuelEffi return true; } - /// - public FuelEfficiency ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -780,14 +768,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(FuelEfficiencyUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 8631b86a9b..9db4261a4c 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -903,12 +903,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this HeatFlux to another HeatFlux with the unit representation . /// @@ -1017,12 +1011,6 @@ private bool TryToUnit(HeatFluxUnit unit, [NotNullWhen(true)] out HeatFlux? conv return true; } - /// - public HeatFlux ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1042,14 +1030,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(HeatFluxUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index d12fe17f67..403e1341c2 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -682,12 +682,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this HeatTransferCoefficient to another HeatTransferCoefficient with the unit representation . /// @@ -770,12 +764,6 @@ private bool TryToUnit(HeatTransferCoefficientUnit unit, [NotNullWhen(true)] out return true; } - /// - public HeatTransferCoefficient ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -795,14 +783,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(HeatTransferCoefficientUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 9ee5838445..e77177bbda 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -682,12 +682,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Illuminance to another Illuminance with the unit representation . /// @@ -768,12 +762,6 @@ private bool TryToUnit(IlluminanceUnit unit, [NotNullWhen(true)] out Illuminance return true; } - /// - public Illuminance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -793,14 +781,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(IlluminanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs index 5af1def28a..9b65b90484 100644 --- a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs @@ -810,12 +810,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Impulse to another Impulse with the unit representation . /// @@ -914,12 +908,6 @@ private bool TryToUnit(ImpulseUnit unit, [NotNullWhen(true)] out Impulse? conver return true; } - /// - public Impulse ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -939,14 +927,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ImpulseUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index dfc2c6d0b0..f47576504e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -1212,12 +1212,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Information to another Information with the unit representation . /// @@ -1368,12 +1362,6 @@ private bool TryToUnit(InformationUnit unit, [NotNullWhen(true)] out Information return true; } - /// - public Information ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1393,14 +1381,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(InformationUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index f34428a664..bf99979ee6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -826,12 +826,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Irradiance to another Irradiance with the unit representation . /// @@ -932,12 +926,6 @@ private bool TryToUnit(IrradianceUnit unit, [NotNullWhen(true)] out Irradiance? return true; } - /// - public Irradiance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -957,14 +945,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(IrradianceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index c541e7e6f2..f175b32ed2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -749,12 +749,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Irradiation to another Irradiation with the unit representation . /// @@ -845,12 +839,6 @@ private bool TryToUnit(IrradiationUnit unit, [NotNullWhen(true)] out Irradiation return true; } - /// - public Irradiation ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -870,14 +858,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(IrradiationUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index 27aad7836e..8393dc142b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -791,12 +791,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Jerk to another Jerk with the unit representation . /// @@ -891,12 +885,6 @@ private bool TryToUnit(JerkUnit unit, [NotNullWhen(true)] out Jerk? converted) return true; } - /// - public Jerk ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -916,14 +904,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(JerkUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index dfd1dc8da2..e5e220d1e4 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -783,12 +783,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this KinematicViscosity to another KinematicViscosity with the unit representation . /// @@ -879,12 +873,6 @@ private bool TryToUnit(KinematicViscosityUnit unit, [NotNullWhen(true)] out Kine return true; } - /// - public KinematicViscosity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -904,14 +892,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(KinematicViscosityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs index 31aedbb04b..87992b7d3b 100644 --- a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs @@ -669,12 +669,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this LeakRate to another LeakRate with the unit representation . /// @@ -755,12 +749,6 @@ private bool TryToUnit(LeakRateUnit unit, [NotNullWhen(true)] out LeakRate? conv return true; } - /// - public LeakRate ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -780,14 +768,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(LeakRateUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 114aa9369d..7adab6f10a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -1413,12 +1413,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Length to another Length with the unit representation . /// @@ -1575,12 +1569,6 @@ private bool TryToUnit(LengthUnit unit, [NotNullWhen(true)] out Length? converte return true; } - /// - public Length ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1600,14 +1588,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(LengthUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index a3756f2b3e..c586867d22 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -635,12 +635,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Level to another Level with the unit representation . /// @@ -717,12 +711,6 @@ private bool TryToUnit(LevelUnit unit, [NotNullWhen(true)] out Level? converted) return true; } - /// - public Level ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -742,14 +730,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(LevelUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 772d18adc0..29c791fd2a 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -920,12 +920,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this LinearDensity to another LinearDensity with the unit representation . /// @@ -1034,12 +1028,6 @@ private bool TryToUnit(LinearDensityUnit unit, [NotNullWhen(true)] out LinearDen return true; } - /// - public LinearDensity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1059,14 +1047,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(LinearDensityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 49c885310f..e2cca5d859 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -1005,12 +1005,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this LinearPowerDensity to another LinearPowerDensity with the unit representation . /// @@ -1133,12 +1127,6 @@ private bool TryToUnit(LinearPowerDensityUnit unit, [NotNullWhen(true)] out Line return true; } - /// - public LinearPowerDensity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1158,14 +1146,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(LinearPowerDensityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs index d7abbb4fa8..794ed1c79a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs @@ -778,12 +778,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Luminance to another Luminance with the unit representation . /// @@ -876,12 +870,6 @@ private bool TryToUnit(LuminanceUnit unit, [NotNullWhen(true)] out Luminance? co return true; } - /// - public Luminance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -901,14 +889,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(LuminanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index fc52c77bf5..dc75f0bffb 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -829,12 +829,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Luminosity to another Luminosity with the unit representation . /// @@ -935,12 +929,6 @@ private bool TryToUnit(LuminosityUnit unit, [NotNullWhen(true)] out Luminosity? return true; } - /// - public Luminosity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -960,14 +948,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(LuminosityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 397551e87c..52ce518c02 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -641,12 +641,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this LuminousFlux to another LuminousFlux with the unit representation . /// @@ -721,12 +715,6 @@ private bool TryToUnit(LuminousFluxUnit unit, [NotNullWhen(true)] out LuminousFl return true; } - /// - public LuminousFlux ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -746,14 +734,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(LuminousFluxUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index e6115ea875..2050f82496 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -641,12 +641,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this LuminousIntensity to another LuminousIntensity with the unit representation . /// @@ -721,12 +715,6 @@ private bool TryToUnit(LuminousIntensityUnit unit, [NotNullWhen(true)] out Lumin return true; } - /// - public LuminousIntensity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -746,14 +734,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(LuminousIntensityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 1d96df089a..631f7c005f 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -701,12 +701,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this MagneticField to another MagneticField with the unit representation . /// @@ -791,12 +785,6 @@ private bool TryToUnit(MagneticFieldUnit unit, [NotNullWhen(true)] out MagneticF return true; } - /// - public MagneticField ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -816,14 +804,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MagneticFieldUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 3d38034988..2170ca4925 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -621,12 +621,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this MagneticFlux to another MagneticFlux with the unit representation . /// @@ -701,12 +695,6 @@ private bool TryToUnit(MagneticFluxUnit unit, [NotNullWhen(true)] out MagneticFl return true; } - /// - public MagneticFlux ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -726,14 +714,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MagneticFluxUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 9e0db4c8ee..79e53b7363 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -621,12 +621,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Magnetization to another Magnetization with the unit representation . /// @@ -701,12 +695,6 @@ private bool TryToUnit(MagnetizationUnit unit, [NotNullWhen(true)] out Magnetiza return true; } - /// - public Magnetization ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -726,14 +714,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MagnetizationUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index b334caf182..190d8de426 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -1152,12 +1152,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Mass to another Mass with the unit representation . /// @@ -1284,12 +1278,6 @@ private bool TryToUnit(MassUnit unit, [NotNullWhen(true)] out Mass? converted) return true; } - /// - public Mass ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1309,14 +1297,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MassUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index fd87c94d15..2622e9bf12 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -1430,12 +1430,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this MassConcentration to another MassConcentration with the unit representation . /// @@ -1606,12 +1600,6 @@ private bool TryToUnit(MassConcentrationUnit unit, [NotNullWhen(true)] out MassC return true; } - /// - public MassConcentration ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1631,14 +1619,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MassConcentrationUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 6bee66571e..f65a0dd0fa 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -1206,12 +1206,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this MassFlow to another MassFlow with the unit representation . /// @@ -1350,12 +1344,6 @@ private bool TryToUnit(MassFlowUnit unit, [NotNullWhen(true)] out MassFlow? conv return true; } - /// - public MassFlow ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1375,14 +1363,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MassFlowUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 2c5916a9ec..0343804338 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -821,12 +821,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this MassFlux to another MassFlux with the unit representation . /// @@ -923,12 +917,6 @@ private bool TryToUnit(MassFluxUnit unit, [NotNullWhen(true)] out MassFlux? conv return true; } - /// - public MassFlux ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -948,14 +936,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MassFluxUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 29f4fecb97..e72b83638e 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -988,12 +988,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this MassFraction to another MassFraction with the unit representation . /// @@ -1114,12 +1108,6 @@ private bool TryToUnit(MassFractionUnit unit, [NotNullWhen(true)] out MassFracti return true; } - /// - public MassFraction ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1139,14 +1127,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MassFractionUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index dc91d1b23b..ba7ddc4e24 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -1050,12 +1050,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this MassMomentOfInertia to another MassMomentOfInertia with the unit representation . /// @@ -1184,12 +1178,6 @@ private bool TryToUnit(MassMomentOfInertiaUnit unit, [NotNullWhen(true)] out Mas return true; } - /// - public MassMomentOfInertia ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1209,14 +1197,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MassMomentOfInertiaUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs index 332dcbb159..0399c8a662 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs @@ -653,12 +653,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Molality to another Molality with the unit representation . /// @@ -737,12 +731,6 @@ private bool TryToUnit(MolalityUnit unit, [NotNullWhen(true)] out Molality? conv return true; } - /// - public Molality ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -762,14 +750,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MolalityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 441c570f1d..e1f0831ca7 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -663,12 +663,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this MolarEnergy to another MolarEnergy with the unit representation . /// @@ -747,12 +741,6 @@ private bool TryToUnit(MolarEnergyUnit unit, [NotNullWhen(true)] out MolarEnergy return true; } - /// - public MolarEnergy ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -772,14 +760,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MolarEnergyUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index c25e244cc8..a02fd67c37 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -650,12 +650,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this MolarEntropy to another MolarEntropy with the unit representation . /// @@ -734,12 +728,6 @@ private bool TryToUnit(MolarEntropyUnit unit, [NotNullWhen(true)] out MolarEntro return true; } - /// - public MolarEntropy ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -759,14 +747,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MolarEntropyUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index ebd3e62887..fa0a5c176c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -780,12 +780,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this MolarFlow to another MolarFlow with the unit representation . /// @@ -876,12 +870,6 @@ private bool TryToUnit(MolarFlowUnit unit, [NotNullWhen(true)] out MolarFlow? co return true; } - /// - public MolarFlow ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -901,14 +889,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MolarFlowUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 010b9d74f9..1f48fd423c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -837,12 +837,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this MolarMass to another MolarMass with the unit representation . /// @@ -941,12 +935,6 @@ private bool TryToUnit(MolarMassUnit unit, [NotNullWhen(true)] out MolarMass? co return true; } - /// - public MolarMass ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -966,14 +954,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MolarMassUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 1782635893..ad05e52da6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -822,12 +822,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Molarity to another Molarity with the unit representation . /// @@ -922,12 +916,6 @@ private bool TryToUnit(MolarityUnit unit, [NotNullWhen(true)] out Molarity? conv return true; } - /// - public Molarity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -947,14 +935,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(MolarityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index dc5f8837d6..096a5f2191 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -621,12 +621,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Permeability to another Permeability with the unit representation . /// @@ -701,12 +695,6 @@ private bool TryToUnit(PermeabilityUnit unit, [NotNullWhen(true)] out Permeabili return true; } - /// - public Permeability ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -726,14 +714,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(PermeabilityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index a28939c50e..184c14ca91 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -621,12 +621,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Permittivity to another Permittivity with the unit representation . /// @@ -701,12 +695,6 @@ private bool TryToUnit(PermittivityUnit unit, [NotNullWhen(true)] out Permittivi return true; } - /// - public Permittivity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -726,14 +714,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(PermittivityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index 87a5c54c1b..87b128ffc3 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -685,12 +685,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this PorousMediumPermeability to another PorousMediumPermeability with the unit representation . /// @@ -773,12 +767,6 @@ private bool TryToUnit(PorousMediumPermeabilityUnit unit, [NotNullWhen(true)] ou return true; } - /// - public PorousMediumPermeability ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -798,14 +786,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(PorousMediumPermeabilityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 43145c28ef..196db5eb4e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -1138,12 +1138,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Power to another Power with the unit representation . /// @@ -1270,12 +1264,6 @@ private bool TryToUnit(PowerUnit unit, [NotNullWhen(true)] out Power? converted) return true; } - /// - public Power ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1295,14 +1283,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(PowerUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 69c0b71d3b..bf180fb682 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -1306,12 +1306,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this PowerDensity to another PowerDensity with the unit representation . /// @@ -1472,12 +1466,6 @@ private bool TryToUnit(PowerDensityUnit unit, [NotNullWhen(true)] out PowerDensi return true; } - /// - public PowerDensity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1497,14 +1485,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(PowerDensityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index 8d1093e2d5..96a8e8921b 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -635,12 +635,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this PowerRatio to another PowerRatio with the unit representation . /// @@ -717,12 +711,6 @@ private bool TryToUnit(PowerRatioUnit unit, [NotNullWhen(true)] out PowerRatio? return true; } - /// - public PowerRatio ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -742,14 +730,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(PowerRatioUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 9f10ec036f..33c3f7ab44 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -1446,12 +1446,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Pressure to another Pressure with the unit representation . /// @@ -1620,12 +1614,6 @@ private bool TryToUnit(PressureUnit unit, [NotNullWhen(true)] out Pressure? conv return true; } - /// - public Pressure ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1645,14 +1633,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(PressureUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 3a92170c4d..2b16d091c7 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -903,12 +903,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this PressureChangeRate to another PressureChangeRate with the unit representation . /// @@ -1017,12 +1011,6 @@ private bool TryToUnit(PressureChangeRateUnit unit, [NotNullWhen(true)] out Pres return true; } - /// - public PressureChangeRate ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1042,14 +1030,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(PressureChangeRateUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs index deffb18848..338276b611 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs @@ -718,12 +718,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this RadiationEquivalentDose to another RadiationEquivalentDose with the unit representation . /// @@ -808,12 +802,6 @@ private bool TryToUnit(RadiationEquivalentDoseUnit unit, [NotNullWhen(true)] out return true; } - /// - public RadiationEquivalentDose ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -833,14 +821,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(RadiationEquivalentDoseUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs index a87acf0ce1..6dd8144f3b 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs @@ -775,12 +775,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this RadiationEquivalentDoseRate to another RadiationEquivalentDoseRate with the unit representation . /// @@ -873,12 +867,6 @@ private bool TryToUnit(RadiationEquivalentDoseRateUnit unit, [NotNullWhen(true)] return true; } - /// - public RadiationEquivalentDoseRate ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -898,14 +886,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(RadiationEquivalentDoseRateUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs index 5b847e40a9..cce72958a5 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs @@ -730,12 +730,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this RadiationExposure to another RadiationExposure with the unit representation . /// @@ -824,12 +818,6 @@ private bool TryToUnit(RadiationExposureUnit unit, [NotNullWhen(true)] out Radia return true; } - /// - public RadiationExposure ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -849,14 +837,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(RadiationExposureUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs index 751d486e5f..4bd2a51ff2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs @@ -1066,12 +1066,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Radioactivity to another Radioactivity with the unit representation . /// @@ -1202,12 +1196,6 @@ private bool TryToUnit(RadioactivityUnit unit, [NotNullWhen(true)] out Radioacti return true; } - /// - public Radioactivity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1227,14 +1215,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(RadioactivityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index de18d006b5..a3e9b4e4cd 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -684,12 +684,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Ratio to another Ratio with the unit representation . /// @@ -774,12 +768,6 @@ private bool TryToUnit(RatioUnit unit, [NotNullWhen(true)] out Ratio? converted) return true; } - /// - public Ratio ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -799,14 +787,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(RatioUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index a8c1f5e4ce..d16395509a 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -634,12 +634,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this RatioChangeRate to another RatioChangeRate with the unit representation . /// @@ -716,12 +710,6 @@ private bool TryToUnit(RatioChangeRateUnit unit, [NotNullWhen(true)] out RatioCh return true; } - /// - public RatioChangeRate ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -741,14 +729,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(RatioChangeRateUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 8141b31adf..4fef663397 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -829,12 +829,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ReciprocalArea to another ReciprocalArea with the unit representation . /// @@ -929,12 +923,6 @@ private bool TryToUnit(ReciprocalAreaUnit unit, [NotNullWhen(true)] out Reciproc return true; } - /// - public ReciprocalArea ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -954,14 +942,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ReciprocalAreaUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 9dae1bcbe1..161b87a7ab 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -827,12 +827,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ReciprocalLength to another ReciprocalLength with the unit representation . /// @@ -925,12 +919,6 @@ private bool TryToUnit(ReciprocalLengthUnit unit, [NotNullWhen(true)] out Recipr return true; } - /// - public ReciprocalLength ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -950,14 +938,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ReciprocalLengthUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 48f4a44b03..55cdaaee00 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -604,12 +604,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this RelativeHumidity to another RelativeHumidity with the unit representation . /// @@ -684,12 +678,6 @@ private bool TryToUnit(RelativeHumidityUnit unit, [NotNullWhen(true)] out Relati return true; } - /// - public RelativeHumidity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -709,14 +697,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(RelativeHumidityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 766ccebbf7..5ba067111b 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -666,12 +666,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this RotationalAcceleration to another RotationalAcceleration with the unit representation . /// @@ -752,12 +746,6 @@ private bool TryToUnit(RotationalAccelerationUnit unit, [NotNullWhen(true)] out return true; } - /// - public RotationalAcceleration ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -777,14 +765,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(RotationalAccelerationUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index e236d4a261..a04323c8aa 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -830,12 +830,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this RotationalSpeed to another RotationalSpeed with the unit representation . /// @@ -934,12 +928,6 @@ private bool TryToUnit(RotationalSpeedUnit unit, [NotNullWhen(true)] out Rotatio return true; } - /// - public RotationalSpeed ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -959,14 +947,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(RotationalSpeedUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index c6d1e7d459..47779ade24 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -1157,12 +1157,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this RotationalStiffness to another RotationalStiffness with the unit representation . /// @@ -1301,12 +1295,6 @@ private bool TryToUnit(RotationalStiffnessUnit unit, [NotNullWhen(true)] out Rot return true; } - /// - public RotationalStiffness ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1326,14 +1314,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(RotationalStiffnessUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 36615225ff..861a13dead 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -695,12 +695,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this RotationalStiffnessPerLength to another RotationalStiffnessPerLength with the unit representation . /// @@ -783,12 +777,6 @@ private bool TryToUnit(RotationalStiffnessPerLengthUnit unit, [NotNullWhen(true) return true; } - /// - public RotationalStiffnessPerLength ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -808,14 +796,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(RotationalStiffnessPerLengthUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index d6eb7d764c..e309f8400f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -604,12 +604,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Scalar to another Scalar with the unit representation . /// @@ -684,12 +678,6 @@ private bool TryToUnit(ScalarUnit unit, [NotNullWhen(true)] out Scalar? converte return true; } - /// - public Scalar ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -709,14 +697,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ScalarUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 64edbe9778..426c2a52e9 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -607,12 +607,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this SolidAngle to another SolidAngle with the unit representation . /// @@ -687,12 +681,6 @@ private bool TryToUnit(SolidAngleUnit unit, [NotNullWhen(true)] out SolidAngle? return true; } - /// - public SolidAngle ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -712,14 +700,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(SolidAngleUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index cd59a55d27..f3f9977bd3 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -1139,12 +1139,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this SpecificEnergy to another SpecificEnergy with the unit representation . /// @@ -1277,12 +1271,6 @@ private bool TryToUnit(SpecificEnergyUnit unit, [NotNullWhen(true)] out Specific return true; } - /// - public SpecificEnergy ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1302,14 +1290,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(SpecificEnergyUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 254787637e..71a59b0be8 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -766,12 +766,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this SpecificEntropy to another SpecificEntropy with the unit representation . /// @@ -862,12 +856,6 @@ private bool TryToUnit(SpecificEntropyUnit unit, [NotNullWhen(true)] out Specifi return true; } - /// - public SpecificEntropy ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -887,14 +875,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(SpecificEntropyUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 3deb82ea42..61f36c7143 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -669,12 +669,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this SpecificFuelConsumption to another SpecificFuelConsumption with the unit representation . /// @@ -755,12 +749,6 @@ private bool TryToUnit(SpecificFuelConsumptionUnit unit, [NotNullWhen(true)] out return true; } - /// - public SpecificFuelConsumption ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -780,14 +768,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(SpecificFuelConsumptionUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 3b3fbf3487..24bbd73d60 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -670,12 +670,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this SpecificVolume to another SpecificVolume with the unit representation . /// @@ -754,12 +748,6 @@ private bool TryToUnit(SpecificVolumeUnit unit, [NotNullWhen(true)] out Specific return true; } - /// - public SpecificVolume ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -779,14 +767,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(SpecificVolumeUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 612dbcfcb3..3ecb62d133 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -911,12 +911,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this SpecificWeight to another SpecificWeight with the unit representation . /// @@ -1023,12 +1017,6 @@ private bool TryToUnit(SpecificWeightUnit unit, [NotNullWhen(true)] out Specific return true; } - /// - public SpecificWeight ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1048,14 +1036,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(SpecificWeightUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 6e46faf02b..f719b9eed4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -1192,12 +1192,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Speed to another Speed with the unit representation . /// @@ -1336,12 +1330,6 @@ private bool TryToUnit(SpeedUnit unit, [NotNullWhen(true)] out Speed? converted) return true; } - /// - public Speed ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1361,14 +1349,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(SpeedUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 0269d9f0a6..f582fed9d0 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -746,12 +746,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this StandardVolumeFlow to another StandardVolumeFlow with the unit representation . /// @@ -842,12 +836,6 @@ private bool TryToUnit(StandardVolumeFlowUnit unit, [NotNullWhen(true)] out Stan return true; } - /// - public StandardVolumeFlow ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -867,14 +855,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(StandardVolumeFlowUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index f33a79d09a..c281eba1da 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -716,12 +716,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Temperature to another Temperature with the unit representation . /// @@ -814,12 +808,6 @@ private bool TryToUnit(TemperatureUnit unit, [NotNullWhen(true)] out Temperature return true; } - /// - public Temperature ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -839,14 +827,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(TemperatureUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 899b060c28..c1d2090eec 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -887,12 +887,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this TemperatureChangeRate to another TemperatureChangeRate with the unit representation . /// @@ -999,12 +993,6 @@ private bool TryToUnit(TemperatureChangeRateUnit unit, [NotNullWhen(true)] out T return true; } - /// - public TemperatureChangeRate ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1024,14 +1012,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(TemperatureChangeRateUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 203b2b2e4c..dce0b0bad3 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -801,12 +801,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this TemperatureDelta to another TemperatureDelta with the unit representation . /// @@ -897,12 +891,6 @@ private bool TryToUnit(TemperatureDeltaUnit unit, [NotNullWhen(true)] out Temper return true; } - /// - public TemperatureDelta ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -922,14 +910,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(TemperatureDeltaUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index 1379e6b593..c1dd1c4e56 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -679,12 +679,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this TemperatureGradient to another TemperatureGradient with the unit representation . /// @@ -765,12 +759,6 @@ private bool TryToUnit(TemperatureGradientUnit unit, [NotNullWhen(true)] out Tem return true; } - /// - public TemperatureGradient ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -790,14 +778,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(TemperatureGradientUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index b584b84bcd..35fe6bea6e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -637,12 +637,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ThermalConductivity to another ThermalConductivity with the unit representation . /// @@ -719,12 +713,6 @@ private bool TryToUnit(ThermalConductivityUnit unit, [NotNullWhen(true)] out The return true; } - /// - public ThermalConductivity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -744,14 +732,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ThermalConductivityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs index 7932ae77a2..b972f8f404 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalInsulance.g.cs @@ -714,12 +714,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ThermalInsulance to another ThermalInsulance with the unit representation . /// @@ -806,12 +800,6 @@ private bool TryToUnit(ThermalInsulanceUnit unit, [NotNullWhen(true)] out Therma return true; } - /// - public ThermalInsulance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -831,14 +819,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ThermalInsulanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index a3964742d8..8bb30547b5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -634,12 +634,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this ThermalResistance to another ThermalResistance with the unit representation . /// @@ -716,12 +710,6 @@ private bool TryToUnit(ThermalResistanceUnit unit, [NotNullWhen(true)] out Therm return true; } - /// - public ThermalResistance ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -741,14 +729,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(ThermalResistanceUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index e0b2e3a3ac..74f003fc0b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -1057,12 +1057,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Torque to another Torque with the unit representation . /// @@ -1185,12 +1179,6 @@ private bool TryToUnit(TorqueUnit unit, [NotNullWhen(true)] out Torque? converte return true; } - /// - public Torque ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1210,14 +1198,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(TorqueUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index b200c36028..4a490bf27e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -607,12 +607,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Turbidity to another Turbidity with the unit representation . /// @@ -687,12 +681,6 @@ private bool TryToUnit(TurbidityUnit unit, [NotNullWhen(true)] out Turbidity? co return true; } - /// - public Turbidity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -712,14 +700,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(TurbidityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index fdb0ba3fa4..d2f6ae907d 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -604,12 +604,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this VitaminA to another VitaminA with the unit representation . /// @@ -684,12 +678,6 @@ private bool TryToUnit(VitaminAUnit unit, [NotNullWhen(true)] out VitaminA? conv return true; } - /// - public VitaminA ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -709,14 +697,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(VitaminAUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 5d02cc4e84..a0ad2c8736 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -1563,12 +1563,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this Volume to another Volume with the unit representation . /// @@ -1749,12 +1743,6 @@ private bool TryToUnit(VolumeUnit unit, [NotNullWhen(true)] out Volume? converte return true; } - /// - public Volume ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1774,14 +1762,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(VolumeUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index a59b8f8639..ab94ebcd43 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -931,12 +931,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this VolumeConcentration to another VolumeConcentration with the unit representation . /// @@ -1049,12 +1043,6 @@ private bool TryToUnit(VolumeConcentrationUnit unit, [NotNullWhen(true)] out Vol return true; } - /// - public VolumeConcentration ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -1074,14 +1062,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(VolumeConcentrationUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 97bdfe23d4..91f4b2eb17 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -1843,12 +1843,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this VolumeFlow to another VolumeFlow with the unit representation . /// @@ -2071,12 +2065,6 @@ private bool TryToUnit(VolumeFlowUnit unit, [NotNullWhen(true)] out VolumeFlow? return true; } - /// - public VolumeFlow ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -2096,14 +2084,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(VolumeFlowUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 3631b331ce..0bbcbc9baf 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -634,12 +634,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this VolumeFlowPerArea to another VolumeFlowPerArea with the unit representation . /// @@ -716,12 +710,6 @@ private bool TryToUnit(VolumeFlowPerAreaUnit unit, [NotNullWhen(true)] out Volum return true; } - /// - public VolumeFlowPerArea ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -741,14 +729,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(VolumeFlowPerAreaUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index f167382e54..60efd67bec 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -746,12 +746,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this VolumePerLength to another VolumePerLength with the unit representation . /// @@ -842,12 +836,6 @@ private bool TryToUnit(VolumePerLengthUnit unit, [NotNullWhen(true)] out VolumeP return true; } - /// - public VolumePerLength ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -867,14 +855,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(VolumePerLengthUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 56184e2c08..9f628eed18 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -749,12 +749,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this VolumetricHeatCapacity to another VolumetricHeatCapacity with the unit representation . /// @@ -845,12 +839,6 @@ private bool TryToUnit(VolumetricHeatCapacityUnit unit, [NotNullWhen(true)] out return true; } - /// - public VolumetricHeatCapacity ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -870,14 +858,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(VolumetricHeatCapacityUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 50c81deecf..3f89bfa93f 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -698,12 +698,6 @@ public double As(UnitKey unitKey) return As(unitKey.ToUnit()); } - /// - public double As(UnitSystem unitSystem) - { - return As(Info.GetDefaultUnit(unitSystem)); - } - /// /// Converts this WarpingMomentOfInertia to another WarpingMomentOfInertia with the unit representation . /// @@ -788,12 +782,6 @@ private bool TryToUnit(WarpingMomentOfInertiaUnit unit, [NotNullWhen(true)] out return true; } - /// - public WarpingMomentOfInertia ToUnit(UnitSystem unitSystem) - { - return ToUnit(Info.GetDefaultUnit(unitSystem)); - } - #region Explicit implementations double IQuantity.As(Enum unit) @@ -813,14 +801,11 @@ IQuantity IQuantity.ToUnit(Enum unit) return ToUnit(typedUnit, DefaultConversionFunctions); } - /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// IQuantity IQuantity.ToUnit(WarpingMomentOfInertiaUnit unit) => ToUnit(unit); /// - IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => this.ToUnit(unitSystem); #endregion diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 42debad321..7dd7e7b232 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -34,14 +34,6 @@ public interface IQuantity : IFormattable /// Wrong unit enum type was given. double As(UnitKey unitKey); - /// - /// Gets the value in the unit determined by the given . If multiple units were found for the given , - /// the first match will be used. - /// - /// The to convert the quantity value to. - /// The converted value. - double As(UnitSystem unitSystem); - /// /// The unit this quantity was constructed with -or- BaseUnit if default ctor was used. /// @@ -63,14 +55,6 @@ public interface IQuantity : IFormattable /// A new in the given . IQuantity ToUnit(Enum unit); - /// - /// Converts to a quantity with a unit determined by the given . - /// If multiple units were found for the given , the first match will be used. - /// - /// The to convert the quantity to. - /// A new quantity with the determined unit. - IQuantity ToUnit(UnitSystem unitSystem); - /// /// Gets the unique key for the unit type and its corresponding value. /// @@ -112,9 +96,14 @@ public interface IQuantity : IQuantity /// Conversion was not possible from this to . /// A new in the given . IQuantity ToUnit(TUnitType unit); - - /// - new IQuantity ToUnit(UnitSystem unitSystem); + + /// + /// Converts to a quantity with a unit determined by the given . + /// If multiple units were found for the given , the first match will be used. + /// + /// The to convert the quantity to. + /// A new quantity with the determined unit. + IQuantity ToUnit(UnitSystem unitSystem); #if NET