diff --git a/UnitsNet.Tests/GeneratedCode/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AccelerationTestsBase.g.cs
index f7b4a7548d..1354f39b38 100644
--- a/UnitsNet.Tests/GeneratedCode/AccelerationTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/AccelerationTestsBase.g.cs
@@ -138,6 +138,64 @@ public void As()
AssertEx.EqualTolerance(StandardGravityInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.StandardGravity), StandardGravityTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
+
+ var centimeterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.CentimeterPerSecondSquared);
+ AssertEx.EqualTolerance(CentimetersPerSecondSquaredInOneMeterPerSecondSquared, (double)centimeterpersecondsquaredQuantity.Value, CentimetersPerSecondSquaredTolerance);
+ Assert.Equal(AccelerationUnit.CentimeterPerSecondSquared, centimeterpersecondsquaredQuantity.Unit);
+
+ var decimeterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.DecimeterPerSecondSquared);
+ AssertEx.EqualTolerance(DecimetersPerSecondSquaredInOneMeterPerSecondSquared, (double)decimeterpersecondsquaredQuantity.Value, DecimetersPerSecondSquaredTolerance);
+ Assert.Equal(AccelerationUnit.DecimeterPerSecondSquared, decimeterpersecondsquaredQuantity.Unit);
+
+ var footpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.FootPerSecondSquared);
+ AssertEx.EqualTolerance(FeetPerSecondSquaredInOneMeterPerSecondSquared, (double)footpersecondsquaredQuantity.Value, FeetPerSecondSquaredTolerance);
+ Assert.Equal(AccelerationUnit.FootPerSecondSquared, footpersecondsquaredQuantity.Unit);
+
+ var inchpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.InchPerSecondSquared);
+ AssertEx.EqualTolerance(InchesPerSecondSquaredInOneMeterPerSecondSquared, (double)inchpersecondsquaredQuantity.Value, InchesPerSecondSquaredTolerance);
+ Assert.Equal(AccelerationUnit.InchPerSecondSquared, inchpersecondsquaredQuantity.Unit);
+
+ var kilometerpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.KilometerPerSecondSquared);
+ AssertEx.EqualTolerance(KilometersPerSecondSquaredInOneMeterPerSecondSquared, (double)kilometerpersecondsquaredQuantity.Value, KilometersPerSecondSquaredTolerance);
+ Assert.Equal(AccelerationUnit.KilometerPerSecondSquared, kilometerpersecondsquaredQuantity.Unit);
+
+ var knotperhourQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.KnotPerHour);
+ AssertEx.EqualTolerance(KnotsPerHourInOneMeterPerSecondSquared, (double)knotperhourQuantity.Value, KnotsPerHourTolerance);
+ Assert.Equal(AccelerationUnit.KnotPerHour, knotperhourQuantity.Unit);
+
+ var knotperminuteQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.KnotPerMinute);
+ AssertEx.EqualTolerance(KnotsPerMinuteInOneMeterPerSecondSquared, (double)knotperminuteQuantity.Value, KnotsPerMinuteTolerance);
+ Assert.Equal(AccelerationUnit.KnotPerMinute, knotperminuteQuantity.Unit);
+
+ var knotpersecondQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.KnotPerSecond);
+ AssertEx.EqualTolerance(KnotsPerSecondInOneMeterPerSecondSquared, (double)knotpersecondQuantity.Value, KnotsPerSecondTolerance);
+ Assert.Equal(AccelerationUnit.KnotPerSecond, knotpersecondQuantity.Unit);
+
+ var meterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.MeterPerSecondSquared);
+ AssertEx.EqualTolerance(MetersPerSecondSquaredInOneMeterPerSecondSquared, (double)meterpersecondsquaredQuantity.Value, MetersPerSecondSquaredTolerance);
+ Assert.Equal(AccelerationUnit.MeterPerSecondSquared, meterpersecondsquaredQuantity.Unit);
+
+ var micrometerpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.MicrometerPerSecondSquared);
+ AssertEx.EqualTolerance(MicrometersPerSecondSquaredInOneMeterPerSecondSquared, (double)micrometerpersecondsquaredQuantity.Value, MicrometersPerSecondSquaredTolerance);
+ Assert.Equal(AccelerationUnit.MicrometerPerSecondSquared, micrometerpersecondsquaredQuantity.Unit);
+
+ var millimeterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.MillimeterPerSecondSquared);
+ AssertEx.EqualTolerance(MillimetersPerSecondSquaredInOneMeterPerSecondSquared, (double)millimeterpersecondsquaredQuantity.Value, MillimetersPerSecondSquaredTolerance);
+ Assert.Equal(AccelerationUnit.MillimeterPerSecondSquared, millimeterpersecondsquaredQuantity.Unit);
+
+ var nanometerpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.NanometerPerSecondSquared);
+ AssertEx.EqualTolerance(NanometersPerSecondSquaredInOneMeterPerSecondSquared, (double)nanometerpersecondsquaredQuantity.Value, NanometersPerSecondSquaredTolerance);
+ Assert.Equal(AccelerationUnit.NanometerPerSecondSquared, nanometerpersecondsquaredQuantity.Unit);
+
+ var standardgravityQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.StandardGravity);
+ AssertEx.EqualTolerance(StandardGravityInOneMeterPerSecondSquared, (double)standardgravityQuantity.Value, StandardGravityTolerance);
+ Assert.Equal(AccelerationUnit.StandardGravity, standardgravityQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs
index 5be3e1b31f..b4e9ab8514 100644
--- a/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs
@@ -143,6 +143,68 @@ public void As()
AssertEx.EqualTolerance(PoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.PoundMole), PoundMolesTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var mole = AmountOfSubstance.FromMoles(1);
+
+ var centimoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Centimole);
+ AssertEx.EqualTolerance(CentimolesInOneMole, (double)centimoleQuantity.Value, CentimolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.Centimole, centimoleQuantity.Unit);
+
+ var centipoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.CentipoundMole);
+ AssertEx.EqualTolerance(CentipoundMolesInOneMole, (double)centipoundmoleQuantity.Value, CentipoundMolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.CentipoundMole, centipoundmoleQuantity.Unit);
+
+ var decimoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Decimole);
+ AssertEx.EqualTolerance(DecimolesInOneMole, (double)decimoleQuantity.Value, DecimolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.Decimole, decimoleQuantity.Unit);
+
+ var decipoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.DecipoundMole);
+ AssertEx.EqualTolerance(DecipoundMolesInOneMole, (double)decipoundmoleQuantity.Value, DecipoundMolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.DecipoundMole, decipoundmoleQuantity.Unit);
+
+ var kilomoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Kilomole);
+ AssertEx.EqualTolerance(KilomolesInOneMole, (double)kilomoleQuantity.Value, KilomolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.Kilomole, kilomoleQuantity.Unit);
+
+ var kilopoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.KilopoundMole);
+ AssertEx.EqualTolerance(KilopoundMolesInOneMole, (double)kilopoundmoleQuantity.Value, KilopoundMolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.KilopoundMole, kilopoundmoleQuantity.Unit);
+
+ var micromoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Micromole);
+ AssertEx.EqualTolerance(MicromolesInOneMole, (double)micromoleQuantity.Value, MicromolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.Micromole, micromoleQuantity.Unit);
+
+ var micropoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.MicropoundMole);
+ AssertEx.EqualTolerance(MicropoundMolesInOneMole, (double)micropoundmoleQuantity.Value, MicropoundMolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.MicropoundMole, micropoundmoleQuantity.Unit);
+
+ var millimoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Millimole);
+ AssertEx.EqualTolerance(MillimolesInOneMole, (double)millimoleQuantity.Value, MillimolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.Millimole, millimoleQuantity.Unit);
+
+ var millipoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.MillipoundMole);
+ AssertEx.EqualTolerance(MillipoundMolesInOneMole, (double)millipoundmoleQuantity.Value, MillipoundMolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.MillipoundMole, millipoundmoleQuantity.Unit);
+
+ var moleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Mole);
+ AssertEx.EqualTolerance(MolesInOneMole, (double)moleQuantity.Value, MolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.Mole, moleQuantity.Unit);
+
+ var nanomoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Nanomole);
+ AssertEx.EqualTolerance(NanomolesInOneMole, (double)nanomoleQuantity.Value, NanomolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.Nanomole, nanomoleQuantity.Unit);
+
+ var nanopoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.NanopoundMole);
+ AssertEx.EqualTolerance(NanopoundMolesInOneMole, (double)nanopoundmoleQuantity.Value, NanopoundMolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.NanopoundMole, nanopoundmoleQuantity.Unit);
+
+ var poundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.PoundMole);
+ AssertEx.EqualTolerance(PoundMolesInOneMole, (double)poundmoleQuantity.Value, PoundMolesTolerance);
+ Assert.Equal(AmountOfSubstanceUnit.PoundMole, poundmoleQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs
index 27ad4e3dc0..df7504b0e2 100644
--- a/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs
@@ -93,6 +93,28 @@ public void As()
AssertEx.EqualTolerance(DecibelVoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelVolt), DecibelVoltsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var decibelvolt = AmplitudeRatio.FromDecibelVolts(1);
+
+ var decibelmicrovoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelMicrovolt);
+ AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, (double)decibelmicrovoltQuantity.Value, DecibelMicrovoltsTolerance);
+ Assert.Equal(AmplitudeRatioUnit.DecibelMicrovolt, decibelmicrovoltQuantity.Unit);
+
+ var decibelmillivoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelMillivolt);
+ AssertEx.EqualTolerance(DecibelMillivoltsInOneDecibelVolt, (double)decibelmillivoltQuantity.Value, DecibelMillivoltsTolerance);
+ Assert.Equal(AmplitudeRatioUnit.DecibelMillivolt, decibelmillivoltQuantity.Unit);
+
+ var decibelunloadedQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelUnloaded);
+ AssertEx.EqualTolerance(DecibelsUnloadedInOneDecibelVolt, (double)decibelunloadedQuantity.Value, DecibelsUnloadedTolerance);
+ Assert.Equal(AmplitudeRatioUnit.DecibelUnloaded, decibelunloadedQuantity.Unit);
+
+ var decibelvoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelVolt);
+ AssertEx.EqualTolerance(DecibelVoltsInOneDecibelVolt, (double)decibelvoltQuantity.Value, DecibelVoltsTolerance);
+ Assert.Equal(AmplitudeRatioUnit.DecibelVolt, decibelvoltQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AngleTestsBase.g.cs
index fe85edc0fd..6da073c6a4 100644
--- a/UnitsNet.Tests/GeneratedCode/AngleTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/AngleTestsBase.g.cs
@@ -143,6 +143,68 @@ public void As()
AssertEx.EqualTolerance(RevolutionsInOneDegree, degree.As(AngleUnit.Revolution), RevolutionsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var degree = Angle.FromDegrees(1);
+
+ var arcminuteQuantity = degree.ToUnit(AngleUnit.Arcminute);
+ AssertEx.EqualTolerance(ArcminutesInOneDegree, (double)arcminuteQuantity.Value, ArcminutesTolerance);
+ Assert.Equal(AngleUnit.Arcminute, arcminuteQuantity.Unit);
+
+ var arcsecondQuantity = degree.ToUnit(AngleUnit.Arcsecond);
+ AssertEx.EqualTolerance(ArcsecondsInOneDegree, (double)arcsecondQuantity.Value, ArcsecondsTolerance);
+ Assert.Equal(AngleUnit.Arcsecond, arcsecondQuantity.Unit);
+
+ var centiradianQuantity = degree.ToUnit(AngleUnit.Centiradian);
+ AssertEx.EqualTolerance(CentiradiansInOneDegree, (double)centiradianQuantity.Value, CentiradiansTolerance);
+ Assert.Equal(AngleUnit.Centiradian, centiradianQuantity.Unit);
+
+ var deciradianQuantity = degree.ToUnit(AngleUnit.Deciradian);
+ AssertEx.EqualTolerance(DeciradiansInOneDegree, (double)deciradianQuantity.Value, DeciradiansTolerance);
+ Assert.Equal(AngleUnit.Deciradian, deciradianQuantity.Unit);
+
+ var degreeQuantity = degree.ToUnit(AngleUnit.Degree);
+ AssertEx.EqualTolerance(DegreesInOneDegree, (double)degreeQuantity.Value, DegreesTolerance);
+ Assert.Equal(AngleUnit.Degree, degreeQuantity.Unit);
+
+ var gradianQuantity = degree.ToUnit(AngleUnit.Gradian);
+ AssertEx.EqualTolerance(GradiansInOneDegree, (double)gradianQuantity.Value, GradiansTolerance);
+ Assert.Equal(AngleUnit.Gradian, gradianQuantity.Unit);
+
+ var microdegreeQuantity = degree.ToUnit(AngleUnit.Microdegree);
+ AssertEx.EqualTolerance(MicrodegreesInOneDegree, (double)microdegreeQuantity.Value, MicrodegreesTolerance);
+ Assert.Equal(AngleUnit.Microdegree, microdegreeQuantity.Unit);
+
+ var microradianQuantity = degree.ToUnit(AngleUnit.Microradian);
+ AssertEx.EqualTolerance(MicroradiansInOneDegree, (double)microradianQuantity.Value, MicroradiansTolerance);
+ Assert.Equal(AngleUnit.Microradian, microradianQuantity.Unit);
+
+ var millidegreeQuantity = degree.ToUnit(AngleUnit.Millidegree);
+ AssertEx.EqualTolerance(MillidegreesInOneDegree, (double)millidegreeQuantity.Value, MillidegreesTolerance);
+ Assert.Equal(AngleUnit.Millidegree, millidegreeQuantity.Unit);
+
+ var milliradianQuantity = degree.ToUnit(AngleUnit.Milliradian);
+ AssertEx.EqualTolerance(MilliradiansInOneDegree, (double)milliradianQuantity.Value, MilliradiansTolerance);
+ Assert.Equal(AngleUnit.Milliradian, milliradianQuantity.Unit);
+
+ var nanodegreeQuantity = degree.ToUnit(AngleUnit.Nanodegree);
+ AssertEx.EqualTolerance(NanodegreesInOneDegree, (double)nanodegreeQuantity.Value, NanodegreesTolerance);
+ Assert.Equal(AngleUnit.Nanodegree, nanodegreeQuantity.Unit);
+
+ var nanoradianQuantity = degree.ToUnit(AngleUnit.Nanoradian);
+ AssertEx.EqualTolerance(NanoradiansInOneDegree, (double)nanoradianQuantity.Value, NanoradiansTolerance);
+ Assert.Equal(AngleUnit.Nanoradian, nanoradianQuantity.Unit);
+
+ var radianQuantity = degree.ToUnit(AngleUnit.Radian);
+ AssertEx.EqualTolerance(RadiansInOneDegree, (double)radianQuantity.Value, RadiansTolerance);
+ Assert.Equal(AngleUnit.Radian, radianQuantity.Unit);
+
+ var revolutionQuantity = degree.ToUnit(AngleUnit.Revolution);
+ AssertEx.EqualTolerance(RevolutionsInOneDegree, (double)revolutionQuantity.Value, RevolutionsTolerance);
+ Assert.Equal(AngleUnit.Revolution, revolutionQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs
index 415a05c51a..07282a5181 100644
--- a/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs
@@ -88,6 +88,24 @@ public void As()
AssertEx.EqualTolerance(VoltampereHoursInOneVoltampereHour, voltamperehour.As(ApparentEnergyUnit.VoltampereHour), VoltampereHoursTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var voltamperehour = ApparentEnergy.FromVoltampereHours(1);
+
+ var kilovoltamperehourQuantity = voltamperehour.ToUnit(ApparentEnergyUnit.KilovoltampereHour);
+ AssertEx.EqualTolerance(KilovoltampereHoursInOneVoltampereHour, (double)kilovoltamperehourQuantity.Value, KilovoltampereHoursTolerance);
+ Assert.Equal(ApparentEnergyUnit.KilovoltampereHour, kilovoltamperehourQuantity.Unit);
+
+ var megavoltamperehourQuantity = voltamperehour.ToUnit(ApparentEnergyUnit.MegavoltampereHour);
+ AssertEx.EqualTolerance(MegavoltampereHoursInOneVoltampereHour, (double)megavoltamperehourQuantity.Value, MegavoltampereHoursTolerance);
+ Assert.Equal(ApparentEnergyUnit.MegavoltampereHour, megavoltamperehourQuantity.Unit);
+
+ var voltamperehourQuantity = voltamperehour.ToUnit(ApparentEnergyUnit.VoltampereHour);
+ AssertEx.EqualTolerance(VoltampereHoursInOneVoltampereHour, (double)voltamperehourQuantity.Value, VoltampereHoursTolerance);
+ Assert.Equal(ApparentEnergyUnit.VoltampereHour, voltamperehourQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs
index 39f40bcd54..74f77c53a8 100644
--- a/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs
@@ -93,6 +93,28 @@ public void As()
AssertEx.EqualTolerance(VoltamperesInOneVoltampere, voltampere.As(ApparentPowerUnit.Voltampere), VoltamperesTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var voltampere = ApparentPower.FromVoltamperes(1);
+
+ var gigavoltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Gigavoltampere);
+ AssertEx.EqualTolerance(GigavoltamperesInOneVoltampere, (double)gigavoltampereQuantity.Value, GigavoltamperesTolerance);
+ Assert.Equal(ApparentPowerUnit.Gigavoltampere, gigavoltampereQuantity.Unit);
+
+ var kilovoltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Kilovoltampere);
+ AssertEx.EqualTolerance(KilovoltamperesInOneVoltampere, (double)kilovoltampereQuantity.Value, KilovoltamperesTolerance);
+ Assert.Equal(ApparentPowerUnit.Kilovoltampere, kilovoltampereQuantity.Unit);
+
+ var megavoltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Megavoltampere);
+ AssertEx.EqualTolerance(MegavoltamperesInOneVoltampere, (double)megavoltampereQuantity.Value, MegavoltamperesTolerance);
+ Assert.Equal(ApparentPowerUnit.Megavoltampere, megavoltampereQuantity.Unit);
+
+ var voltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Voltampere);
+ AssertEx.EqualTolerance(VoltamperesInOneVoltampere, (double)voltampereQuantity.Value, VoltamperesTolerance);
+ Assert.Equal(ApparentPowerUnit.Voltampere, voltampereQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs
index 0ab454792d..a64164ba00 100644
--- a/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.KilogramPerSquareMeter), KilogramsPerSquareMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1);
+
+ var kilogrampersquaremeterQuantity = kilogrampersquaremeter.ToUnit(AreaDensityUnit.KilogramPerSquareMeter);
+ AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, (double)kilogrampersquaremeterQuantity.Value, KilogramsPerSquareMeterTolerance);
+ Assert.Equal(AreaDensityUnit.KilogramPerSquareMeter, kilogrampersquaremeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs
index a25eaff5a4..7eb4949350 100644
--- a/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs
@@ -103,6 +103,36 @@ public void As()
AssertEx.EqualTolerance(MillimetersToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.MillimeterToTheFourth), MillimetersToTheFourthTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1);
+
+ var centimetertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.CentimeterToTheFourth);
+ AssertEx.EqualTolerance(CentimetersToTheFourthInOneMeterToTheFourth, (double)centimetertothefourthQuantity.Value, CentimetersToTheFourthTolerance);
+ Assert.Equal(AreaMomentOfInertiaUnit.CentimeterToTheFourth, centimetertothefourthQuantity.Unit);
+
+ var decimetertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.DecimeterToTheFourth);
+ AssertEx.EqualTolerance(DecimetersToTheFourthInOneMeterToTheFourth, (double)decimetertothefourthQuantity.Value, DecimetersToTheFourthTolerance);
+ Assert.Equal(AreaMomentOfInertiaUnit.DecimeterToTheFourth, decimetertothefourthQuantity.Unit);
+
+ var foottothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.FootToTheFourth);
+ AssertEx.EqualTolerance(FeetToTheFourthInOneMeterToTheFourth, (double)foottothefourthQuantity.Value, FeetToTheFourthTolerance);
+ Assert.Equal(AreaMomentOfInertiaUnit.FootToTheFourth, foottothefourthQuantity.Unit);
+
+ var inchtothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.InchToTheFourth);
+ AssertEx.EqualTolerance(InchesToTheFourthInOneMeterToTheFourth, (double)inchtothefourthQuantity.Value, InchesToTheFourthTolerance);
+ Assert.Equal(AreaMomentOfInertiaUnit.InchToTheFourth, inchtothefourthQuantity.Unit);
+
+ var metertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.MeterToTheFourth);
+ AssertEx.EqualTolerance(MetersToTheFourthInOneMeterToTheFourth, (double)metertothefourthQuantity.Value, MetersToTheFourthTolerance);
+ Assert.Equal(AreaMomentOfInertiaUnit.MeterToTheFourth, metertothefourthQuantity.Unit);
+
+ var millimetertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.MillimeterToTheFourth);
+ AssertEx.EqualTolerance(MillimetersToTheFourthInOneMeterToTheFourth, (double)millimetertothefourthQuantity.Value, MillimetersToTheFourthTolerance);
+ Assert.Equal(AreaMomentOfInertiaUnit.MillimeterToTheFourth, millimetertothefourthQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs
index 0a67464ba4..441cac2e8f 100644
--- a/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs
@@ -138,6 +138,64 @@ public void As()
AssertEx.EqualTolerance(UsSurveySquareFeetInOneSquareMeter, squaremeter.As(AreaUnit.UsSurveySquareFoot), UsSurveySquareFeetTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var squaremeter = Area.FromSquareMeters(1);
+
+ var acreQuantity = squaremeter.ToUnit(AreaUnit.Acre);
+ AssertEx.EqualTolerance(AcresInOneSquareMeter, (double)acreQuantity.Value, AcresTolerance);
+ Assert.Equal(AreaUnit.Acre, acreQuantity.Unit);
+
+ var hectareQuantity = squaremeter.ToUnit(AreaUnit.Hectare);
+ AssertEx.EqualTolerance(HectaresInOneSquareMeter, (double)hectareQuantity.Value, HectaresTolerance);
+ Assert.Equal(AreaUnit.Hectare, hectareQuantity.Unit);
+
+ var squarecentimeterQuantity = squaremeter.ToUnit(AreaUnit.SquareCentimeter);
+ AssertEx.EqualTolerance(SquareCentimetersInOneSquareMeter, (double)squarecentimeterQuantity.Value, SquareCentimetersTolerance);
+ Assert.Equal(AreaUnit.SquareCentimeter, squarecentimeterQuantity.Unit);
+
+ var squaredecimeterQuantity = squaremeter.ToUnit(AreaUnit.SquareDecimeter);
+ AssertEx.EqualTolerance(SquareDecimetersInOneSquareMeter, (double)squaredecimeterQuantity.Value, SquareDecimetersTolerance);
+ Assert.Equal(AreaUnit.SquareDecimeter, squaredecimeterQuantity.Unit);
+
+ var squarefootQuantity = squaremeter.ToUnit(AreaUnit.SquareFoot);
+ AssertEx.EqualTolerance(SquareFeetInOneSquareMeter, (double)squarefootQuantity.Value, SquareFeetTolerance);
+ Assert.Equal(AreaUnit.SquareFoot, squarefootQuantity.Unit);
+
+ var squareinchQuantity = squaremeter.ToUnit(AreaUnit.SquareInch);
+ AssertEx.EqualTolerance(SquareInchesInOneSquareMeter, (double)squareinchQuantity.Value, SquareInchesTolerance);
+ Assert.Equal(AreaUnit.SquareInch, squareinchQuantity.Unit);
+
+ var squarekilometerQuantity = squaremeter.ToUnit(AreaUnit.SquareKilometer);
+ AssertEx.EqualTolerance(SquareKilometersInOneSquareMeter, (double)squarekilometerQuantity.Value, SquareKilometersTolerance);
+ Assert.Equal(AreaUnit.SquareKilometer, squarekilometerQuantity.Unit);
+
+ var squaremeterQuantity = squaremeter.ToUnit(AreaUnit.SquareMeter);
+ AssertEx.EqualTolerance(SquareMetersInOneSquareMeter, (double)squaremeterQuantity.Value, SquareMetersTolerance);
+ Assert.Equal(AreaUnit.SquareMeter, squaremeterQuantity.Unit);
+
+ var squaremicrometerQuantity = squaremeter.ToUnit(AreaUnit.SquareMicrometer);
+ AssertEx.EqualTolerance(SquareMicrometersInOneSquareMeter, (double)squaremicrometerQuantity.Value, SquareMicrometersTolerance);
+ Assert.Equal(AreaUnit.SquareMicrometer, squaremicrometerQuantity.Unit);
+
+ var squaremileQuantity = squaremeter.ToUnit(AreaUnit.SquareMile);
+ AssertEx.EqualTolerance(SquareMilesInOneSquareMeter, (double)squaremileQuantity.Value, SquareMilesTolerance);
+ Assert.Equal(AreaUnit.SquareMile, squaremileQuantity.Unit);
+
+ var squaremillimeterQuantity = squaremeter.ToUnit(AreaUnit.SquareMillimeter);
+ AssertEx.EqualTolerance(SquareMillimetersInOneSquareMeter, (double)squaremillimeterQuantity.Value, SquareMillimetersTolerance);
+ Assert.Equal(AreaUnit.SquareMillimeter, squaremillimeterQuantity.Unit);
+
+ var squareyardQuantity = squaremeter.ToUnit(AreaUnit.SquareYard);
+ AssertEx.EqualTolerance(SquareYardsInOneSquareMeter, (double)squareyardQuantity.Value, SquareYardsTolerance);
+ Assert.Equal(AreaUnit.SquareYard, squareyardQuantity.Unit);
+
+ var ussurveysquarefootQuantity = squaremeter.ToUnit(AreaUnit.UsSurveySquareFoot);
+ AssertEx.EqualTolerance(UsSurveySquareFeetInOneSquareMeter, (double)ussurveysquarefootQuantity.Value, UsSurveySquareFeetTolerance);
+ Assert.Equal(AreaUnit.UsSurveySquareFoot, ussurveysquarefootQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/BitRateTestsBase.g.cs
index 14abec34f8..97b3c7b460 100644
--- a/UnitsNet.Tests/GeneratedCode/BitRateTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/BitRateTestsBase.g.cs
@@ -203,6 +203,116 @@ public void As()
AssertEx.EqualTolerance(TerabytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.TerabytePerSecond), TerabytesPerSecondTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var bitpersecond = BitRate.FromBitsPerSecond(1);
+
+ var bitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.BitPerSecond);
+ AssertEx.EqualTolerance(BitsPerSecondInOneBitPerSecond, (double)bitpersecondQuantity.Value, BitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.BitPerSecond, bitpersecondQuantity.Unit);
+
+ var bytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.BytePerSecond);
+ AssertEx.EqualTolerance(BytesPerSecondInOneBitPerSecond, (double)bytepersecondQuantity.Value, BytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.BytePerSecond, bytepersecondQuantity.Unit);
+
+ var exabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.ExabitPerSecond);
+ AssertEx.EqualTolerance(ExabitsPerSecondInOneBitPerSecond, (double)exabitpersecondQuantity.Value, ExabitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.ExabitPerSecond, exabitpersecondQuantity.Unit);
+
+ var exabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.ExabytePerSecond);
+ AssertEx.EqualTolerance(ExabytesPerSecondInOneBitPerSecond, (double)exabytepersecondQuantity.Value, ExabytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.ExabytePerSecond, exabytepersecondQuantity.Unit);
+
+ var exbibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.ExbibitPerSecond);
+ AssertEx.EqualTolerance(ExbibitsPerSecondInOneBitPerSecond, (double)exbibitpersecondQuantity.Value, ExbibitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.ExbibitPerSecond, exbibitpersecondQuantity.Unit);
+
+ var exbibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.ExbibytePerSecond);
+ AssertEx.EqualTolerance(ExbibytesPerSecondInOneBitPerSecond, (double)exbibytepersecondQuantity.Value, ExbibytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.ExbibytePerSecond, exbibytepersecondQuantity.Unit);
+
+ var gibibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.GibibitPerSecond);
+ AssertEx.EqualTolerance(GibibitsPerSecondInOneBitPerSecond, (double)gibibitpersecondQuantity.Value, GibibitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.GibibitPerSecond, gibibitpersecondQuantity.Unit);
+
+ var gibibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.GibibytePerSecond);
+ AssertEx.EqualTolerance(GibibytesPerSecondInOneBitPerSecond, (double)gibibytepersecondQuantity.Value, GibibytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.GibibytePerSecond, gibibytepersecondQuantity.Unit);
+
+ var gigabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.GigabitPerSecond);
+ AssertEx.EqualTolerance(GigabitsPerSecondInOneBitPerSecond, (double)gigabitpersecondQuantity.Value, GigabitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.GigabitPerSecond, gigabitpersecondQuantity.Unit);
+
+ var gigabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.GigabytePerSecond);
+ AssertEx.EqualTolerance(GigabytesPerSecondInOneBitPerSecond, (double)gigabytepersecondQuantity.Value, GigabytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.GigabytePerSecond, gigabytepersecondQuantity.Unit);
+
+ var kibibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.KibibitPerSecond);
+ AssertEx.EqualTolerance(KibibitsPerSecondInOneBitPerSecond, (double)kibibitpersecondQuantity.Value, KibibitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.KibibitPerSecond, kibibitpersecondQuantity.Unit);
+
+ var kibibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.KibibytePerSecond);
+ AssertEx.EqualTolerance(KibibytesPerSecondInOneBitPerSecond, (double)kibibytepersecondQuantity.Value, KibibytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.KibibytePerSecond, kibibytepersecondQuantity.Unit);
+
+ var kilobitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.KilobitPerSecond);
+ AssertEx.EqualTolerance(KilobitsPerSecondInOneBitPerSecond, (double)kilobitpersecondQuantity.Value, KilobitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.KilobitPerSecond, kilobitpersecondQuantity.Unit);
+
+ var kilobytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.KilobytePerSecond);
+ AssertEx.EqualTolerance(KilobytesPerSecondInOneBitPerSecond, (double)kilobytepersecondQuantity.Value, KilobytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.KilobytePerSecond, kilobytepersecondQuantity.Unit);
+
+ var mebibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.MebibitPerSecond);
+ AssertEx.EqualTolerance(MebibitsPerSecondInOneBitPerSecond, (double)mebibitpersecondQuantity.Value, MebibitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.MebibitPerSecond, mebibitpersecondQuantity.Unit);
+
+ var mebibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.MebibytePerSecond);
+ AssertEx.EqualTolerance(MebibytesPerSecondInOneBitPerSecond, (double)mebibytepersecondQuantity.Value, MebibytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.MebibytePerSecond, mebibytepersecondQuantity.Unit);
+
+ var megabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.MegabitPerSecond);
+ AssertEx.EqualTolerance(MegabitsPerSecondInOneBitPerSecond, (double)megabitpersecondQuantity.Value, MegabitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.MegabitPerSecond, megabitpersecondQuantity.Unit);
+
+ var megabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.MegabytePerSecond);
+ AssertEx.EqualTolerance(MegabytesPerSecondInOneBitPerSecond, (double)megabytepersecondQuantity.Value, MegabytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.MegabytePerSecond, megabytepersecondQuantity.Unit);
+
+ var pebibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.PebibitPerSecond);
+ AssertEx.EqualTolerance(PebibitsPerSecondInOneBitPerSecond, (double)pebibitpersecondQuantity.Value, PebibitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.PebibitPerSecond, pebibitpersecondQuantity.Unit);
+
+ var pebibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.PebibytePerSecond);
+ AssertEx.EqualTolerance(PebibytesPerSecondInOneBitPerSecond, (double)pebibytepersecondQuantity.Value, PebibytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.PebibytePerSecond, pebibytepersecondQuantity.Unit);
+
+ var petabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.PetabitPerSecond);
+ AssertEx.EqualTolerance(PetabitsPerSecondInOneBitPerSecond, (double)petabitpersecondQuantity.Value, PetabitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.PetabitPerSecond, petabitpersecondQuantity.Unit);
+
+ var petabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.PetabytePerSecond);
+ AssertEx.EqualTolerance(PetabytesPerSecondInOneBitPerSecond, (double)petabytepersecondQuantity.Value, PetabytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.PetabytePerSecond, petabytepersecondQuantity.Unit);
+
+ var tebibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.TebibitPerSecond);
+ AssertEx.EqualTolerance(TebibitsPerSecondInOneBitPerSecond, (double)tebibitpersecondQuantity.Value, TebibitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.TebibitPerSecond, tebibitpersecondQuantity.Unit);
+
+ var tebibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.TebibytePerSecond);
+ AssertEx.EqualTolerance(TebibytesPerSecondInOneBitPerSecond, (double)tebibytepersecondQuantity.Value, TebibytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.TebibytePerSecond, tebibytepersecondQuantity.Unit);
+
+ var terabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.TerabitPerSecond);
+ AssertEx.EqualTolerance(TerabitsPerSecondInOneBitPerSecond, (double)terabitpersecondQuantity.Value, TerabitsPerSecondTolerance);
+ Assert.Equal(BitRateUnit.TerabitPerSecond, terabitpersecondQuantity.Unit);
+
+ var terabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.TerabytePerSecond);
+ AssertEx.EqualTolerance(TerabytesPerSecondInOneBitPerSecond, (double)terabytepersecondQuantity.Value, TerabytesPerSecondTolerance);
+ Assert.Equal(BitRateUnit.TerabytePerSecond, terabytepersecondQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs
index 073f489075..f97116eacb 100644
--- a/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs
@@ -88,6 +88,24 @@ public void As()
AssertEx.EqualTolerance(PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule, kilogramperjoule.As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour), PoundsPerMechanicalHorsepowerHourTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);
+
+ var gramperkilowatthourQuantity = kilogramperjoule.ToUnit(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour);
+ AssertEx.EqualTolerance(GramsPerKiloWattHourInOneKilogramPerJoule, (double)gramperkilowatthourQuantity.Value, GramsPerKiloWattHourTolerance);
+ Assert.Equal(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, gramperkilowatthourQuantity.Unit);
+
+ var kilogramperjouleQuantity = kilogramperjoule.ToUnit(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule);
+ AssertEx.EqualTolerance(KilogramsPerJouleInOneKilogramPerJoule, (double)kilogramperjouleQuantity.Value, KilogramsPerJouleTolerance);
+ Assert.Equal(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, kilogramperjouleQuantity.Unit);
+
+ var poundpermechanicalhorsepowerhourQuantity = kilogramperjoule.ToUnit(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour);
+ AssertEx.EqualTolerance(PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule, (double)poundpermechanicalhorsepowerhourQuantity.Value, PoundsPerMechanicalHorsepowerHourTolerance);
+ Assert.Equal(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, poundpermechanicalhorsepowerhourQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs
index 179deb622f..adde8d4a30 100644
--- a/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(FaradsInOneFarad, farad.As(CapacitanceUnit.Farad), FaradsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var farad = Capacitance.FromFarads(1);
+
+ var faradQuantity = farad.ToUnit(CapacitanceUnit.Farad);
+ AssertEx.EqualTolerance(FaradsInOneFarad, (double)faradQuantity.Value, FaradsTolerance);
+ Assert.Equal(CapacitanceUnit.Farad, faradQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/DensityTestsBase.g.cs
index badbe5f30b..2b12c9a71f 100644
--- a/UnitsNet.Tests/GeneratedCode/DensityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/DensityTestsBase.g.cs
@@ -263,6 +263,164 @@ public void As()
AssertEx.EqualTolerance(TonnesPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.TonnePerCubicMillimeter), TonnesPerCubicMillimeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
+
+ var centigramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.CentigramPerDeciliter);
+ AssertEx.EqualTolerance(CentigramsPerDeciLiterInOneKilogramPerCubicMeter, (double)centigramperdeciliterQuantity.Value, CentigramsPerDeciLiterTolerance);
+ Assert.Equal(DensityUnit.CentigramPerDeciliter, centigramperdeciliterQuantity.Unit);
+
+ var centigramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.CentigramPerLiter);
+ AssertEx.EqualTolerance(CentigramsPerLiterInOneKilogramPerCubicMeter, (double)centigramperliterQuantity.Value, CentigramsPerLiterTolerance);
+ Assert.Equal(DensityUnit.CentigramPerLiter, centigramperliterQuantity.Unit);
+
+ var centigrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.CentigramPerMilliliter);
+ AssertEx.EqualTolerance(CentigramsPerMilliliterInOneKilogramPerCubicMeter, (double)centigrampermilliliterQuantity.Value, CentigramsPerMilliliterTolerance);
+ Assert.Equal(DensityUnit.CentigramPerMilliliter, centigrampermilliliterQuantity.Unit);
+
+ var decigramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.DecigramPerDeciliter);
+ AssertEx.EqualTolerance(DecigramsPerDeciLiterInOneKilogramPerCubicMeter, (double)decigramperdeciliterQuantity.Value, DecigramsPerDeciLiterTolerance);
+ Assert.Equal(DensityUnit.DecigramPerDeciliter, decigramperdeciliterQuantity.Unit);
+
+ var decigramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.DecigramPerLiter);
+ AssertEx.EqualTolerance(DecigramsPerLiterInOneKilogramPerCubicMeter, (double)decigramperliterQuantity.Value, DecigramsPerLiterTolerance);
+ Assert.Equal(DensityUnit.DecigramPerLiter, decigramperliterQuantity.Unit);
+
+ var decigrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.DecigramPerMilliliter);
+ AssertEx.EqualTolerance(DecigramsPerMilliliterInOneKilogramPerCubicMeter, (double)decigrampermilliliterQuantity.Value, DecigramsPerMilliliterTolerance);
+ Assert.Equal(DensityUnit.DecigramPerMilliliter, decigrampermilliliterQuantity.Unit);
+
+ var grampercubiccentimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerCubicCentimeter);
+ AssertEx.EqualTolerance(GramsPerCubicCentimeterInOneKilogramPerCubicMeter, (double)grampercubiccentimeterQuantity.Value, GramsPerCubicCentimeterTolerance);
+ Assert.Equal(DensityUnit.GramPerCubicCentimeter, grampercubiccentimeterQuantity.Unit);
+
+ var grampercubicmeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerCubicMeter);
+ AssertEx.EqualTolerance(GramsPerCubicMeterInOneKilogramPerCubicMeter, (double)grampercubicmeterQuantity.Value, GramsPerCubicMeterTolerance);
+ Assert.Equal(DensityUnit.GramPerCubicMeter, grampercubicmeterQuantity.Unit);
+
+ var grampercubicmillimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerCubicMillimeter);
+ AssertEx.EqualTolerance(GramsPerCubicMillimeterInOneKilogramPerCubicMeter, (double)grampercubicmillimeterQuantity.Value, GramsPerCubicMillimeterTolerance);
+ Assert.Equal(DensityUnit.GramPerCubicMillimeter, grampercubicmillimeterQuantity.Unit);
+
+ var gramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerDeciliter);
+ AssertEx.EqualTolerance(GramsPerDeciLiterInOneKilogramPerCubicMeter, (double)gramperdeciliterQuantity.Value, GramsPerDeciLiterTolerance);
+ Assert.Equal(DensityUnit.GramPerDeciliter, gramperdeciliterQuantity.Unit);
+
+ var gramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerLiter);
+ AssertEx.EqualTolerance(GramsPerLiterInOneKilogramPerCubicMeter, (double)gramperliterQuantity.Value, GramsPerLiterTolerance);
+ Assert.Equal(DensityUnit.GramPerLiter, gramperliterQuantity.Unit);
+
+ var grampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerMilliliter);
+ AssertEx.EqualTolerance(GramsPerMilliliterInOneKilogramPerCubicMeter, (double)grampermilliliterQuantity.Value, GramsPerMilliliterTolerance);
+ Assert.Equal(DensityUnit.GramPerMilliliter, grampermilliliterQuantity.Unit);
+
+ var kilogrampercubiccentimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilogramPerCubicCentimeter);
+ AssertEx.EqualTolerance(KilogramsPerCubicCentimeterInOneKilogramPerCubicMeter, (double)kilogrampercubiccentimeterQuantity.Value, KilogramsPerCubicCentimeterTolerance);
+ Assert.Equal(DensityUnit.KilogramPerCubicCentimeter, kilogrampercubiccentimeterQuantity.Unit);
+
+ var kilogrampercubicmeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilogramPerCubicMeter);
+ AssertEx.EqualTolerance(KilogramsPerCubicMeterInOneKilogramPerCubicMeter, (double)kilogrampercubicmeterQuantity.Value, KilogramsPerCubicMeterTolerance);
+ Assert.Equal(DensityUnit.KilogramPerCubicMeter, kilogrampercubicmeterQuantity.Unit);
+
+ var kilogrampercubicmillimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilogramPerCubicMillimeter);
+ AssertEx.EqualTolerance(KilogramsPerCubicMillimeterInOneKilogramPerCubicMeter, (double)kilogrampercubicmillimeterQuantity.Value, KilogramsPerCubicMillimeterTolerance);
+ Assert.Equal(DensityUnit.KilogramPerCubicMillimeter, kilogrampercubicmillimeterQuantity.Unit);
+
+ var kilopoundpercubicfootQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilopoundPerCubicFoot);
+ AssertEx.EqualTolerance(KilopoundsPerCubicFootInOneKilogramPerCubicMeter, (double)kilopoundpercubicfootQuantity.Value, KilopoundsPerCubicFootTolerance);
+ Assert.Equal(DensityUnit.KilopoundPerCubicFoot, kilopoundpercubicfootQuantity.Unit);
+
+ var kilopoundpercubicinchQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilopoundPerCubicInch);
+ AssertEx.EqualTolerance(KilopoundsPerCubicInchInOneKilogramPerCubicMeter, (double)kilopoundpercubicinchQuantity.Value, KilopoundsPerCubicInchTolerance);
+ Assert.Equal(DensityUnit.KilopoundPerCubicInch, kilopoundpercubicinchQuantity.Unit);
+
+ var microgramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MicrogramPerDeciliter);
+ AssertEx.EqualTolerance(MicrogramsPerDeciLiterInOneKilogramPerCubicMeter, (double)microgramperdeciliterQuantity.Value, MicrogramsPerDeciLiterTolerance);
+ Assert.Equal(DensityUnit.MicrogramPerDeciliter, microgramperdeciliterQuantity.Unit);
+
+ var microgramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MicrogramPerLiter);
+ AssertEx.EqualTolerance(MicrogramsPerLiterInOneKilogramPerCubicMeter, (double)microgramperliterQuantity.Value, MicrogramsPerLiterTolerance);
+ Assert.Equal(DensityUnit.MicrogramPerLiter, microgramperliterQuantity.Unit);
+
+ var microgrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MicrogramPerMilliliter);
+ AssertEx.EqualTolerance(MicrogramsPerMilliliterInOneKilogramPerCubicMeter, (double)microgrampermilliliterQuantity.Value, MicrogramsPerMilliliterTolerance);
+ Assert.Equal(DensityUnit.MicrogramPerMilliliter, microgrampermilliliterQuantity.Unit);
+
+ var milligrampercubicmeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MilligramPerCubicMeter);
+ AssertEx.EqualTolerance(MilligramsPerCubicMeterInOneKilogramPerCubicMeter, (double)milligrampercubicmeterQuantity.Value, MilligramsPerCubicMeterTolerance);
+ Assert.Equal(DensityUnit.MilligramPerCubicMeter, milligrampercubicmeterQuantity.Unit);
+
+ var milligramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MilligramPerDeciliter);
+ AssertEx.EqualTolerance(MilligramsPerDeciLiterInOneKilogramPerCubicMeter, (double)milligramperdeciliterQuantity.Value, MilligramsPerDeciLiterTolerance);
+ Assert.Equal(DensityUnit.MilligramPerDeciliter, milligramperdeciliterQuantity.Unit);
+
+ var milligramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MilligramPerLiter);
+ AssertEx.EqualTolerance(MilligramsPerLiterInOneKilogramPerCubicMeter, (double)milligramperliterQuantity.Value, MilligramsPerLiterTolerance);
+ Assert.Equal(DensityUnit.MilligramPerLiter, milligramperliterQuantity.Unit);
+
+ var milligrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MilligramPerMilliliter);
+ AssertEx.EqualTolerance(MilligramsPerMilliliterInOneKilogramPerCubicMeter, (double)milligrampermilliliterQuantity.Value, MilligramsPerMilliliterTolerance);
+ Assert.Equal(DensityUnit.MilligramPerMilliliter, milligrampermilliliterQuantity.Unit);
+
+ var nanogramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.NanogramPerDeciliter);
+ AssertEx.EqualTolerance(NanogramsPerDeciLiterInOneKilogramPerCubicMeter, (double)nanogramperdeciliterQuantity.Value, NanogramsPerDeciLiterTolerance);
+ Assert.Equal(DensityUnit.NanogramPerDeciliter, nanogramperdeciliterQuantity.Unit);
+
+ var nanogramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.NanogramPerLiter);
+ AssertEx.EqualTolerance(NanogramsPerLiterInOneKilogramPerCubicMeter, (double)nanogramperliterQuantity.Value, NanogramsPerLiterTolerance);
+ Assert.Equal(DensityUnit.NanogramPerLiter, nanogramperliterQuantity.Unit);
+
+ var nanogrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.NanogramPerMilliliter);
+ AssertEx.EqualTolerance(NanogramsPerMilliliterInOneKilogramPerCubicMeter, (double)nanogrampermilliliterQuantity.Value, NanogramsPerMilliliterTolerance);
+ Assert.Equal(DensityUnit.NanogramPerMilliliter, nanogrampermilliliterQuantity.Unit);
+
+ var picogramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PicogramPerDeciliter);
+ AssertEx.EqualTolerance(PicogramsPerDeciLiterInOneKilogramPerCubicMeter, (double)picogramperdeciliterQuantity.Value, PicogramsPerDeciLiterTolerance);
+ Assert.Equal(DensityUnit.PicogramPerDeciliter, picogramperdeciliterQuantity.Unit);
+
+ var picogramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PicogramPerLiter);
+ AssertEx.EqualTolerance(PicogramsPerLiterInOneKilogramPerCubicMeter, (double)picogramperliterQuantity.Value, PicogramsPerLiterTolerance);
+ Assert.Equal(DensityUnit.PicogramPerLiter, picogramperliterQuantity.Unit);
+
+ var picogrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PicogramPerMilliliter);
+ AssertEx.EqualTolerance(PicogramsPerMilliliterInOneKilogramPerCubicMeter, (double)picogrampermilliliterQuantity.Value, PicogramsPerMilliliterTolerance);
+ Assert.Equal(DensityUnit.PicogramPerMilliliter, picogrampermilliliterQuantity.Unit);
+
+ var poundpercubicfootQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PoundPerCubicFoot);
+ AssertEx.EqualTolerance(PoundsPerCubicFootInOneKilogramPerCubicMeter, (double)poundpercubicfootQuantity.Value, PoundsPerCubicFootTolerance);
+ Assert.Equal(DensityUnit.PoundPerCubicFoot, poundpercubicfootQuantity.Unit);
+
+ var poundpercubicinchQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PoundPerCubicInch);
+ AssertEx.EqualTolerance(PoundsPerCubicInchInOneKilogramPerCubicMeter, (double)poundpercubicinchQuantity.Value, PoundsPerCubicInchTolerance);
+ Assert.Equal(DensityUnit.PoundPerCubicInch, poundpercubicinchQuantity.Unit);
+
+ var poundperimperialgallonQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PoundPerImperialGallon);
+ AssertEx.EqualTolerance(PoundsPerImperialGallonInOneKilogramPerCubicMeter, (double)poundperimperialgallonQuantity.Value, PoundsPerImperialGallonTolerance);
+ Assert.Equal(DensityUnit.PoundPerImperialGallon, poundperimperialgallonQuantity.Unit);
+
+ var poundperusgallonQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PoundPerUSGallon);
+ AssertEx.EqualTolerance(PoundsPerUSGallonInOneKilogramPerCubicMeter, (double)poundperusgallonQuantity.Value, PoundsPerUSGallonTolerance);
+ Assert.Equal(DensityUnit.PoundPerUSGallon, poundperusgallonQuantity.Unit);
+
+ var slugpercubicfootQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.SlugPerCubicFoot);
+ AssertEx.EqualTolerance(SlugsPerCubicFootInOneKilogramPerCubicMeter, (double)slugpercubicfootQuantity.Value, SlugsPerCubicFootTolerance);
+ Assert.Equal(DensityUnit.SlugPerCubicFoot, slugpercubicfootQuantity.Unit);
+
+ var tonnepercubiccentimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.TonnePerCubicCentimeter);
+ AssertEx.EqualTolerance(TonnesPerCubicCentimeterInOneKilogramPerCubicMeter, (double)tonnepercubiccentimeterQuantity.Value, TonnesPerCubicCentimeterTolerance);
+ Assert.Equal(DensityUnit.TonnePerCubicCentimeter, tonnepercubiccentimeterQuantity.Unit);
+
+ var tonnepercubicmeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.TonnePerCubicMeter);
+ AssertEx.EqualTolerance(TonnesPerCubicMeterInOneKilogramPerCubicMeter, (double)tonnepercubicmeterQuantity.Value, TonnesPerCubicMeterTolerance);
+ Assert.Equal(DensityUnit.TonnePerCubicMeter, tonnepercubicmeterQuantity.Unit);
+
+ var tonnepercubicmillimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.TonnePerCubicMillimeter);
+ AssertEx.EqualTolerance(TonnesPerCubicMillimeterInOneKilogramPerCubicMeter, (double)tonnepercubicmillimeterQuantity.Value, TonnesPerCubicMillimeterTolerance);
+ Assert.Equal(DensityUnit.TonnePerCubicMillimeter, tonnepercubicmillimeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs
index d5361fae92..5ced0d559a 100644
--- a/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs
@@ -133,6 +133,60 @@ public void As()
AssertEx.EqualTolerance(Years365InOneSecond, second.As(DurationUnit.Year365), Years365Tolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var second = Duration.FromSeconds(1);
+
+ var dayQuantity = second.ToUnit(DurationUnit.Day);
+ AssertEx.EqualTolerance(DaysInOneSecond, (double)dayQuantity.Value, DaysTolerance);
+ Assert.Equal(DurationUnit.Day, dayQuantity.Unit);
+
+ var hourQuantity = second.ToUnit(DurationUnit.Hour);
+ AssertEx.EqualTolerance(HoursInOneSecond, (double)hourQuantity.Value, HoursTolerance);
+ Assert.Equal(DurationUnit.Hour, hourQuantity.Unit);
+
+ var microsecondQuantity = second.ToUnit(DurationUnit.Microsecond);
+ AssertEx.EqualTolerance(MicrosecondsInOneSecond, (double)microsecondQuantity.Value, MicrosecondsTolerance);
+ Assert.Equal(DurationUnit.Microsecond, microsecondQuantity.Unit);
+
+ var millisecondQuantity = second.ToUnit(DurationUnit.Millisecond);
+ AssertEx.EqualTolerance(MillisecondsInOneSecond, (double)millisecondQuantity.Value, MillisecondsTolerance);
+ Assert.Equal(DurationUnit.Millisecond, millisecondQuantity.Unit);
+
+ var minuteQuantity = second.ToUnit(DurationUnit.Minute);
+ AssertEx.EqualTolerance(MinutesInOneSecond, (double)minuteQuantity.Value, MinutesTolerance);
+ Assert.Equal(DurationUnit.Minute, minuteQuantity.Unit);
+
+ var monthQuantity = second.ToUnit(DurationUnit.Month);
+ AssertEx.EqualTolerance(MonthsInOneSecond, (double)monthQuantity.Value, MonthsTolerance);
+ Assert.Equal(DurationUnit.Month, monthQuantity.Unit);
+
+ var month30Quantity = second.ToUnit(DurationUnit.Month30);
+ AssertEx.EqualTolerance(Months30InOneSecond, (double)month30Quantity.Value, Months30Tolerance);
+ Assert.Equal(DurationUnit.Month30, month30Quantity.Unit);
+
+ var nanosecondQuantity = second.ToUnit(DurationUnit.Nanosecond);
+ AssertEx.EqualTolerance(NanosecondsInOneSecond, (double)nanosecondQuantity.Value, NanosecondsTolerance);
+ Assert.Equal(DurationUnit.Nanosecond, nanosecondQuantity.Unit);
+
+ var secondQuantity = second.ToUnit(DurationUnit.Second);
+ AssertEx.EqualTolerance(SecondsInOneSecond, (double)secondQuantity.Value, SecondsTolerance);
+ Assert.Equal(DurationUnit.Second, secondQuantity.Unit);
+
+ var weekQuantity = second.ToUnit(DurationUnit.Week);
+ AssertEx.EqualTolerance(WeeksInOneSecond, (double)weekQuantity.Value, WeeksTolerance);
+ Assert.Equal(DurationUnit.Week, weekQuantity.Unit);
+
+ var yearQuantity = second.ToUnit(DurationUnit.Year);
+ AssertEx.EqualTolerance(YearsInOneSecond, (double)yearQuantity.Value, YearsTolerance);
+ Assert.Equal(DurationUnit.Year, yearQuantity.Unit);
+
+ var year365Quantity = second.ToUnit(DurationUnit.Year365);
+ AssertEx.EqualTolerance(Years365InOneSecond, (double)year365Quantity.Value, Years365Tolerance);
+ Assert.Equal(DurationUnit.Year365, year365Quantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs
index 8f01108d87..80376b897c 100644
--- a/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs
@@ -103,6 +103,36 @@ public void As()
AssertEx.EqualTolerance(PoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.Poise), PoiseTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1);
+
+ var centipoiseQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.Centipoise);
+ AssertEx.EqualTolerance(CentipoiseInOneNewtonSecondPerMeterSquared, (double)centipoiseQuantity.Value, CentipoiseTolerance);
+ Assert.Equal(DynamicViscosityUnit.Centipoise, centipoiseQuantity.Unit);
+
+ var micropascalsecondQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.MicropascalSecond);
+ AssertEx.EqualTolerance(MicropascalSecondsInOneNewtonSecondPerMeterSquared, (double)micropascalsecondQuantity.Value, MicropascalSecondsTolerance);
+ Assert.Equal(DynamicViscosityUnit.MicropascalSecond, micropascalsecondQuantity.Unit);
+
+ var millipascalsecondQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.MillipascalSecond);
+ AssertEx.EqualTolerance(MillipascalSecondsInOneNewtonSecondPerMeterSquared, (double)millipascalsecondQuantity.Value, MillipascalSecondsTolerance);
+ Assert.Equal(DynamicViscosityUnit.MillipascalSecond, millipascalsecondQuantity.Unit);
+
+ var newtonsecondpermetersquaredQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.NewtonSecondPerMeterSquared);
+ AssertEx.EqualTolerance(NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared, (double)newtonsecondpermetersquaredQuantity.Value, NewtonSecondsPerMeterSquaredTolerance);
+ Assert.Equal(DynamicViscosityUnit.NewtonSecondPerMeterSquared, newtonsecondpermetersquaredQuantity.Unit);
+
+ var pascalsecondQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.PascalSecond);
+ AssertEx.EqualTolerance(PascalSecondsInOneNewtonSecondPerMeterSquared, (double)pascalsecondQuantity.Value, PascalSecondsTolerance);
+ Assert.Equal(DynamicViscosityUnit.PascalSecond, pascalsecondQuantity.Unit);
+
+ var poiseQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.Poise);
+ AssertEx.EqualTolerance(PoiseInOneNewtonSecondPerMeterSquared, (double)poiseQuantity.Value, PoiseTolerance);
+ Assert.Equal(DynamicViscosityUnit.Poise, poiseQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs
index 3410243f95..284db977d7 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs
@@ -93,6 +93,28 @@ public void As()
AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.As(ElectricAdmittanceUnit.Siemens), SiemensTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var siemens = ElectricAdmittance.FromSiemens(1);
+
+ var microsiemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Microsiemens);
+ AssertEx.EqualTolerance(MicrosiemensInOneSiemens, (double)microsiemensQuantity.Value, MicrosiemensTolerance);
+ Assert.Equal(ElectricAdmittanceUnit.Microsiemens, microsiemensQuantity.Unit);
+
+ var millisiemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Millisiemens);
+ AssertEx.EqualTolerance(MillisiemensInOneSiemens, (double)millisiemensQuantity.Value, MillisiemensTolerance);
+ Assert.Equal(ElectricAdmittanceUnit.Millisiemens, millisiemensQuantity.Unit);
+
+ var nanosiemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Nanosiemens);
+ AssertEx.EqualTolerance(NanosiemensInOneSiemens, (double)nanosiemensQuantity.Value, NanosiemensTolerance);
+ Assert.Equal(ElectricAdmittanceUnit.Nanosiemens, nanosiemensQuantity.Unit);
+
+ var siemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Siemens);
+ AssertEx.EqualTolerance(SiemensInOneSiemens, (double)siemensQuantity.Value, SiemensTolerance);
+ Assert.Equal(ElectricAdmittanceUnit.Siemens, siemensQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs
index 8d09efe22d..cd1d106d01 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(CoulombsPerCubicMeterInOneCoulombPerCubicMeter, coulombpercubicmeter.As(ElectricChargeDensityUnit.CoulombPerCubicMeter), CoulombsPerCubicMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1);
+
+ var coulombpercubicmeterQuantity = coulombpercubicmeter.ToUnit(ElectricChargeDensityUnit.CoulombPerCubicMeter);
+ AssertEx.EqualTolerance(CoulombsPerCubicMeterInOneCoulombPerCubicMeter, (double)coulombpercubicmeterQuantity.Value, CoulombsPerCubicMeterTolerance);
+ Assert.Equal(ElectricChargeDensityUnit.CoulombPerCubicMeter, coulombpercubicmeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs
index 2fc9e971ef..15e3013e98 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(CoulombsInOneCoulomb, coulomb.As(ElectricChargeUnit.Coulomb), CoulombsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var coulomb = ElectricCharge.FromCoulombs(1);
+
+ var coulombQuantity = coulomb.ToUnit(ElectricChargeUnit.Coulomb);
+ AssertEx.EqualTolerance(CoulombsInOneCoulomb, (double)coulombQuantity.Value, CoulombsTolerance);
+ Assert.Equal(ElectricChargeUnit.Coulomb, coulombQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs
index ab1016f678..fc033e26fd 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs
@@ -88,6 +88,24 @@ public void As()
AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Siemens), SiemensTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var siemens = ElectricConductance.FromSiemens(1);
+
+ var microsiemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Microsiemens);
+ AssertEx.EqualTolerance(MicrosiemensInOneSiemens, (double)microsiemensQuantity.Value, MicrosiemensTolerance);
+ Assert.Equal(ElectricConductanceUnit.Microsiemens, microsiemensQuantity.Unit);
+
+ var millisiemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Millisiemens);
+ AssertEx.EqualTolerance(MillisiemensInOneSiemens, (double)millisiemensQuantity.Value, MillisiemensTolerance);
+ Assert.Equal(ElectricConductanceUnit.Millisiemens, millisiemensQuantity.Unit);
+
+ var siemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Siemens);
+ AssertEx.EqualTolerance(SiemensInOneSiemens, (double)siemensQuantity.Value, SiemensTolerance);
+ Assert.Equal(ElectricConductanceUnit.Siemens, siemensQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs
index f7136969ee..1553afd41b 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(SiemensPerMeterInOneSiemensPerMeter, siemenspermeter.As(ElectricConductivityUnit.SiemensPerMeter), SiemensPerMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1);
+
+ var siemenspermeterQuantity = siemenspermeter.ToUnit(ElectricConductivityUnit.SiemensPerMeter);
+ AssertEx.EqualTolerance(SiemensPerMeterInOneSiemensPerMeter, (double)siemenspermeterQuantity.Value, SiemensPerMeterTolerance);
+ Assert.Equal(ElectricConductivityUnit.SiemensPerMeter, siemenspermeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs
index d2f763526d..3a3eee43b9 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareMeter), AmperesPerSquareMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
+
+ var amperepersquaremeterQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareMeter);
+ AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, (double)amperepersquaremeterQuantity.Value, AmperesPerSquareMeterTolerance);
+ Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareMeter, amperepersquaremeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs
index c0c4f74a8f..7b5afa0915 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(AmperesPerSecondInOneAmperePerSecond, amperepersecond.As(ElectricCurrentGradientUnit.AmperePerSecond), AmperesPerSecondTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1);
+
+ var amperepersecondQuantity = amperepersecond.ToUnit(ElectricCurrentGradientUnit.AmperePerSecond);
+ AssertEx.EqualTolerance(AmperesPerSecondInOneAmperePerSecond, (double)amperepersecondQuantity.Value, AmperesPerSecondTolerance);
+ Assert.Equal(ElectricCurrentGradientUnit.AmperePerSecond, amperepersecondQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs
index 1fad07b776..84d7555754 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs
@@ -108,6 +108,40 @@ public void As()
AssertEx.EqualTolerance(PicoamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Picoampere), PicoamperesTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var ampere = ElectricCurrent.FromAmperes(1);
+
+ var ampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Ampere);
+ AssertEx.EqualTolerance(AmperesInOneAmpere, (double)ampereQuantity.Value, AmperesTolerance);
+ Assert.Equal(ElectricCurrentUnit.Ampere, ampereQuantity.Unit);
+
+ var kiloampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Kiloampere);
+ AssertEx.EqualTolerance(KiloamperesInOneAmpere, (double)kiloampereQuantity.Value, KiloamperesTolerance);
+ Assert.Equal(ElectricCurrentUnit.Kiloampere, kiloampereQuantity.Unit);
+
+ var megaampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Megaampere);
+ AssertEx.EqualTolerance(MegaamperesInOneAmpere, (double)megaampereQuantity.Value, MegaamperesTolerance);
+ Assert.Equal(ElectricCurrentUnit.Megaampere, megaampereQuantity.Unit);
+
+ var microampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Microampere);
+ AssertEx.EqualTolerance(MicroamperesInOneAmpere, (double)microampereQuantity.Value, MicroamperesTolerance);
+ Assert.Equal(ElectricCurrentUnit.Microampere, microampereQuantity.Unit);
+
+ var milliampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Milliampere);
+ AssertEx.EqualTolerance(MilliamperesInOneAmpere, (double)milliampereQuantity.Value, MilliamperesTolerance);
+ Assert.Equal(ElectricCurrentUnit.Milliampere, milliampereQuantity.Unit);
+
+ var nanoampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Nanoampere);
+ AssertEx.EqualTolerance(NanoamperesInOneAmpere, (double)nanoampereQuantity.Value, NanoamperesTolerance);
+ Assert.Equal(ElectricCurrentUnit.Nanoampere, nanoampereQuantity.Unit);
+
+ var picoampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Picoampere);
+ AssertEx.EqualTolerance(PicoamperesInOneAmpere, (double)picoampereQuantity.Value, PicoamperesTolerance);
+ Assert.Equal(ElectricCurrentUnit.Picoampere, picoampereQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs
index 26ceb3ae4e..b22cddca73 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, voltpermeter.As(ElectricFieldUnit.VoltPerMeter), VoltsPerMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var voltpermeter = ElectricField.FromVoltsPerMeter(1);
+
+ var voltpermeterQuantity = voltpermeter.ToUnit(ElectricFieldUnit.VoltPerMeter);
+ AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, (double)voltpermeterQuantity.Value, VoltsPerMeterTolerance);
+ Assert.Equal(ElectricFieldUnit.VoltPerMeter, voltpermeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs
index e786c88440..8870542b66 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(HenriesInOneHenry, henry.As(ElectricInductanceUnit.Henry), HenriesTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var henry = ElectricInductance.FromHenries(1);
+
+ var henryQuantity = henry.ToUnit(ElectricInductanceUnit.Henry);
+ AssertEx.EqualTolerance(HenriesInOneHenry, (double)henryQuantity.Value, HenriesTolerance);
+ Assert.Equal(ElectricInductanceUnit.Henry, henryQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs
index 6de830d596..7319d1e0de 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs
@@ -98,6 +98,32 @@ public void As()
AssertEx.EqualTolerance(VoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.VoltAc), VoltsAcTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var voltac = ElectricPotentialAc.FromVoltsAc(1);
+
+ var kilovoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.KilovoltAc);
+ AssertEx.EqualTolerance(KilovoltsAcInOneVoltAc, (double)kilovoltacQuantity.Value, KilovoltsAcTolerance);
+ Assert.Equal(ElectricPotentialAcUnit.KilovoltAc, kilovoltacQuantity.Unit);
+
+ var megavoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.MegavoltAc);
+ AssertEx.EqualTolerance(MegavoltsAcInOneVoltAc, (double)megavoltacQuantity.Value, MegavoltsAcTolerance);
+ Assert.Equal(ElectricPotentialAcUnit.MegavoltAc, megavoltacQuantity.Unit);
+
+ var microvoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.MicrovoltAc);
+ AssertEx.EqualTolerance(MicrovoltsAcInOneVoltAc, (double)microvoltacQuantity.Value, MicrovoltsAcTolerance);
+ Assert.Equal(ElectricPotentialAcUnit.MicrovoltAc, microvoltacQuantity.Unit);
+
+ var millivoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.MillivoltAc);
+ AssertEx.EqualTolerance(MillivoltsAcInOneVoltAc, (double)millivoltacQuantity.Value, MillivoltsAcTolerance);
+ Assert.Equal(ElectricPotentialAcUnit.MillivoltAc, millivoltacQuantity.Unit);
+
+ var voltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.VoltAc);
+ AssertEx.EqualTolerance(VoltsAcInOneVoltAc, (double)voltacQuantity.Value, VoltsAcTolerance);
+ Assert.Equal(ElectricPotentialAcUnit.VoltAc, voltacQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs
index d306baca6b..6c968c1167 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs
@@ -98,6 +98,32 @@ public void As()
AssertEx.EqualTolerance(VoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.VoltDc), VoltsDcTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var voltdc = ElectricPotentialDc.FromVoltsDc(1);
+
+ var kilovoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.KilovoltDc);
+ AssertEx.EqualTolerance(KilovoltsDcInOneVoltDc, (double)kilovoltdcQuantity.Value, KilovoltsDcTolerance);
+ Assert.Equal(ElectricPotentialDcUnit.KilovoltDc, kilovoltdcQuantity.Unit);
+
+ var megavoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.MegavoltDc);
+ AssertEx.EqualTolerance(MegavoltsDcInOneVoltDc, (double)megavoltdcQuantity.Value, MegavoltsDcTolerance);
+ Assert.Equal(ElectricPotentialDcUnit.MegavoltDc, megavoltdcQuantity.Unit);
+
+ var microvoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.MicrovoltDc);
+ AssertEx.EqualTolerance(MicrovoltsDcInOneVoltDc, (double)microvoltdcQuantity.Value, MicrovoltsDcTolerance);
+ Assert.Equal(ElectricPotentialDcUnit.MicrovoltDc, microvoltdcQuantity.Unit);
+
+ var millivoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.MillivoltDc);
+ AssertEx.EqualTolerance(MillivoltsDcInOneVoltDc, (double)millivoltdcQuantity.Value, MillivoltsDcTolerance);
+ Assert.Equal(ElectricPotentialDcUnit.MillivoltDc, millivoltdcQuantity.Unit);
+
+ var voltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.VoltDc);
+ AssertEx.EqualTolerance(VoltsDcInOneVoltDc, (double)voltdcQuantity.Value, VoltsDcTolerance);
+ Assert.Equal(ElectricPotentialDcUnit.VoltDc, voltdcQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricPotentialTestsBase.g.cs
index b4da33cdce..4e2d336188 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricPotentialTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricPotentialTestsBase.g.cs
@@ -98,6 +98,32 @@ public void As()
AssertEx.EqualTolerance(VoltsInOneVolt, volt.As(ElectricPotentialUnit.Volt), VoltsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var volt = ElectricPotential.FromVolts(1);
+
+ var kilovoltQuantity = volt.ToUnit(ElectricPotentialUnit.Kilovolt);
+ AssertEx.EqualTolerance(KilovoltsInOneVolt, (double)kilovoltQuantity.Value, KilovoltsTolerance);
+ Assert.Equal(ElectricPotentialUnit.Kilovolt, kilovoltQuantity.Unit);
+
+ var megavoltQuantity = volt.ToUnit(ElectricPotentialUnit.Megavolt);
+ AssertEx.EqualTolerance(MegavoltsInOneVolt, (double)megavoltQuantity.Value, MegavoltsTolerance);
+ Assert.Equal(ElectricPotentialUnit.Megavolt, megavoltQuantity.Unit);
+
+ var microvoltQuantity = volt.ToUnit(ElectricPotentialUnit.Microvolt);
+ AssertEx.EqualTolerance(MicrovoltsInOneVolt, (double)microvoltQuantity.Value, MicrovoltsTolerance);
+ Assert.Equal(ElectricPotentialUnit.Microvolt, microvoltQuantity.Unit);
+
+ var millivoltQuantity = volt.ToUnit(ElectricPotentialUnit.Millivolt);
+ AssertEx.EqualTolerance(MillivoltsInOneVolt, (double)millivoltQuantity.Value, MillivoltsTolerance);
+ Assert.Equal(ElectricPotentialUnit.Millivolt, millivoltQuantity.Unit);
+
+ var voltQuantity = volt.ToUnit(ElectricPotentialUnit.Volt);
+ AssertEx.EqualTolerance(VoltsInOneVolt, (double)voltQuantity.Value, VoltsTolerance);
+ Assert.Equal(ElectricPotentialUnit.Volt, voltQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricResistanceTestsBase.g.cs
index 4c185545e9..1c274d5cfe 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricResistanceTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricResistanceTestsBase.g.cs
@@ -93,6 +93,28 @@ public void As()
AssertEx.EqualTolerance(OhmsInOneOhm, ohm.As(ElectricResistanceUnit.Ohm), OhmsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var ohm = ElectricResistance.FromOhms(1);
+
+ var kiloohmQuantity = ohm.ToUnit(ElectricResistanceUnit.Kiloohm);
+ AssertEx.EqualTolerance(KiloohmsInOneOhm, (double)kiloohmQuantity.Value, KiloohmsTolerance);
+ Assert.Equal(ElectricResistanceUnit.Kiloohm, kiloohmQuantity.Unit);
+
+ var megaohmQuantity = ohm.ToUnit(ElectricResistanceUnit.Megaohm);
+ AssertEx.EqualTolerance(MegaohmsInOneOhm, (double)megaohmQuantity.Value, MegaohmsTolerance);
+ Assert.Equal(ElectricResistanceUnit.Megaohm, megaohmQuantity.Unit);
+
+ var milliohmQuantity = ohm.ToUnit(ElectricResistanceUnit.Milliohm);
+ AssertEx.EqualTolerance(MilliohmsInOneOhm, (double)milliohmQuantity.Value, MilliohmsTolerance);
+ Assert.Equal(ElectricResistanceUnit.Milliohm, milliohmQuantity.Unit);
+
+ var ohmQuantity = ohm.ToUnit(ElectricResistanceUnit.Ohm);
+ AssertEx.EqualTolerance(OhmsInOneOhm, (double)ohmQuantity.Value, OhmsTolerance);
+ Assert.Equal(ElectricResistanceUnit.Ohm, ohmQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricResistivityTestsBase.g.cs
index e02d7f5781..903d86fab5 100644
--- a/UnitsNet.Tests/GeneratedCode/ElectricResistivityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ElectricResistivityTestsBase.g.cs
@@ -93,6 +93,28 @@ public void As()
AssertEx.EqualTolerance(OhmMetersInOneOhmMeter, ohmmeter.As(ElectricResistivityUnit.OhmMeter), OhmMetersTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var ohmmeter = ElectricResistivity.FromOhmMeters(1);
+
+ var microohmmeterQuantity = ohmmeter.ToUnit(ElectricResistivityUnit.MicroohmMeter);
+ AssertEx.EqualTolerance(MicroohmMetersInOneOhmMeter, (double)microohmmeterQuantity.Value, MicroohmMetersTolerance);
+ Assert.Equal(ElectricResistivityUnit.MicroohmMeter, microohmmeterQuantity.Unit);
+
+ var milliohmmeterQuantity = ohmmeter.ToUnit(ElectricResistivityUnit.MilliohmMeter);
+ AssertEx.EqualTolerance(MilliohmMetersInOneOhmMeter, (double)milliohmmeterQuantity.Value, MilliohmMetersTolerance);
+ Assert.Equal(ElectricResistivityUnit.MilliohmMeter, milliohmmeterQuantity.Unit);
+
+ var nanoohmmeterQuantity = ohmmeter.ToUnit(ElectricResistivityUnit.NanoohmMeter);
+ AssertEx.EqualTolerance(NanoohmMetersInOneOhmMeter, (double)nanoohmmeterQuantity.Value, NanoohmMetersTolerance);
+ Assert.Equal(ElectricResistivityUnit.NanoohmMeter, nanoohmmeterQuantity.Unit);
+
+ var ohmmeterQuantity = ohmmeter.ToUnit(ElectricResistivityUnit.OhmMeter);
+ AssertEx.EqualTolerance(OhmMetersInOneOhmMeter, (double)ohmmeterQuantity.Value, OhmMetersTolerance);
+ Assert.Equal(ElectricResistivityUnit.OhmMeter, ohmmeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/EnergyTestsBase.g.cs
index 835665c85d..16b44017ad 100644
--- a/UnitsNet.Tests/GeneratedCode/EnergyTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/EnergyTestsBase.g.cs
@@ -183,6 +183,100 @@ public void As()
AssertEx.EqualTolerance(WattHoursInOneJoule, joule.As(EnergyUnit.WattHour), WattHoursTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var joule = Energy.FromJoules(1);
+
+ var britishthermalunitQuantity = joule.ToUnit(EnergyUnit.BritishThermalUnit);
+ AssertEx.EqualTolerance(BritishThermalUnitsInOneJoule, (double)britishthermalunitQuantity.Value, BritishThermalUnitsTolerance);
+ Assert.Equal(EnergyUnit.BritishThermalUnit, britishthermalunitQuantity.Unit);
+
+ var calorieQuantity = joule.ToUnit(EnergyUnit.Calorie);
+ AssertEx.EqualTolerance(CaloriesInOneJoule, (double)calorieQuantity.Value, CaloriesTolerance);
+ Assert.Equal(EnergyUnit.Calorie, calorieQuantity.Unit);
+
+ var decathermecQuantity = joule.ToUnit(EnergyUnit.DecathermEc);
+ AssertEx.EqualTolerance(DecathermsEcInOneJoule, (double)decathermecQuantity.Value, DecathermsEcTolerance);
+ Assert.Equal(EnergyUnit.DecathermEc, decathermecQuantity.Unit);
+
+ var decathermimperialQuantity = joule.ToUnit(EnergyUnit.DecathermImperial);
+ AssertEx.EqualTolerance(DecathermsImperialInOneJoule, (double)decathermimperialQuantity.Value, DecathermsImperialTolerance);
+ Assert.Equal(EnergyUnit.DecathermImperial, decathermimperialQuantity.Unit);
+
+ var decathermusQuantity = joule.ToUnit(EnergyUnit.DecathermUs);
+ AssertEx.EqualTolerance(DecathermsUsInOneJoule, (double)decathermusQuantity.Value, DecathermsUsTolerance);
+ Assert.Equal(EnergyUnit.DecathermUs, decathermusQuantity.Unit);
+
+ var electronvoltQuantity = joule.ToUnit(EnergyUnit.ElectronVolt);
+ AssertEx.EqualTolerance(ElectronVoltsInOneJoule, (double)electronvoltQuantity.Value, ElectronVoltsTolerance);
+ Assert.Equal(EnergyUnit.ElectronVolt, electronvoltQuantity.Unit);
+
+ var ergQuantity = joule.ToUnit(EnergyUnit.Erg);
+ AssertEx.EqualTolerance(ErgsInOneJoule, (double)ergQuantity.Value, ErgsTolerance);
+ Assert.Equal(EnergyUnit.Erg, ergQuantity.Unit);
+
+ var footpoundQuantity = joule.ToUnit(EnergyUnit.FootPound);
+ AssertEx.EqualTolerance(FootPoundsInOneJoule, (double)footpoundQuantity.Value, FootPoundsTolerance);
+ Assert.Equal(EnergyUnit.FootPound, footpoundQuantity.Unit);
+
+ var gigabritishthermalunitQuantity = joule.ToUnit(EnergyUnit.GigabritishThermalUnit);
+ AssertEx.EqualTolerance(GigabritishThermalUnitsInOneJoule, (double)gigabritishthermalunitQuantity.Value, GigabritishThermalUnitsTolerance);
+ Assert.Equal(EnergyUnit.GigabritishThermalUnit, gigabritishthermalunitQuantity.Unit);
+
+ var gigawatthourQuantity = joule.ToUnit(EnergyUnit.GigawattHour);
+ AssertEx.EqualTolerance(GigawattHoursInOneJoule, (double)gigawatthourQuantity.Value, GigawattHoursTolerance);
+ Assert.Equal(EnergyUnit.GigawattHour, gigawatthourQuantity.Unit);
+
+ var jouleQuantity = joule.ToUnit(EnergyUnit.Joule);
+ AssertEx.EqualTolerance(JoulesInOneJoule, (double)jouleQuantity.Value, JoulesTolerance);
+ Assert.Equal(EnergyUnit.Joule, jouleQuantity.Unit);
+
+ var kilobritishthermalunitQuantity = joule.ToUnit(EnergyUnit.KilobritishThermalUnit);
+ AssertEx.EqualTolerance(KilobritishThermalUnitsInOneJoule, (double)kilobritishthermalunitQuantity.Value, KilobritishThermalUnitsTolerance);
+ Assert.Equal(EnergyUnit.KilobritishThermalUnit, kilobritishthermalunitQuantity.Unit);
+
+ var kilocalorieQuantity = joule.ToUnit(EnergyUnit.Kilocalorie);
+ AssertEx.EqualTolerance(KilocaloriesInOneJoule, (double)kilocalorieQuantity.Value, KilocaloriesTolerance);
+ Assert.Equal(EnergyUnit.Kilocalorie, kilocalorieQuantity.Unit);
+
+ var kilojouleQuantity = joule.ToUnit(EnergyUnit.Kilojoule);
+ AssertEx.EqualTolerance(KilojoulesInOneJoule, (double)kilojouleQuantity.Value, KilojoulesTolerance);
+ Assert.Equal(EnergyUnit.Kilojoule, kilojouleQuantity.Unit);
+
+ var kilowatthourQuantity = joule.ToUnit(EnergyUnit.KilowattHour);
+ AssertEx.EqualTolerance(KilowattHoursInOneJoule, (double)kilowatthourQuantity.Value, KilowattHoursTolerance);
+ Assert.Equal(EnergyUnit.KilowattHour, kilowatthourQuantity.Unit);
+
+ var megabritishthermalunitQuantity = joule.ToUnit(EnergyUnit.MegabritishThermalUnit);
+ AssertEx.EqualTolerance(MegabritishThermalUnitsInOneJoule, (double)megabritishthermalunitQuantity.Value, MegabritishThermalUnitsTolerance);
+ Assert.Equal(EnergyUnit.MegabritishThermalUnit, megabritishthermalunitQuantity.Unit);
+
+ var megajouleQuantity = joule.ToUnit(EnergyUnit.Megajoule);
+ AssertEx.EqualTolerance(MegajoulesInOneJoule, (double)megajouleQuantity.Value, MegajoulesTolerance);
+ Assert.Equal(EnergyUnit.Megajoule, megajouleQuantity.Unit);
+
+ var megawatthourQuantity = joule.ToUnit(EnergyUnit.MegawattHour);
+ AssertEx.EqualTolerance(MegawattHoursInOneJoule, (double)megawatthourQuantity.Value, MegawattHoursTolerance);
+ Assert.Equal(EnergyUnit.MegawattHour, megawatthourQuantity.Unit);
+
+ var thermecQuantity = joule.ToUnit(EnergyUnit.ThermEc);
+ AssertEx.EqualTolerance(ThermsEcInOneJoule, (double)thermecQuantity.Value, ThermsEcTolerance);
+ Assert.Equal(EnergyUnit.ThermEc, thermecQuantity.Unit);
+
+ var thermimperialQuantity = joule.ToUnit(EnergyUnit.ThermImperial);
+ AssertEx.EqualTolerance(ThermsImperialInOneJoule, (double)thermimperialQuantity.Value, ThermsImperialTolerance);
+ Assert.Equal(EnergyUnit.ThermImperial, thermimperialQuantity.Unit);
+
+ var thermusQuantity = joule.ToUnit(EnergyUnit.ThermUs);
+ AssertEx.EqualTolerance(ThermsUsInOneJoule, (double)thermusQuantity.Value, ThermsUsTolerance);
+ Assert.Equal(EnergyUnit.ThermUs, thermusQuantity.Unit);
+
+ var watthourQuantity = joule.ToUnit(EnergyUnit.WattHour);
+ AssertEx.EqualTolerance(WattHoursInOneJoule, (double)watthourQuantity.Value, WattHoursTolerance);
+ Assert.Equal(EnergyUnit.WattHour, watthourQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/EntropyTestsBase.g.cs
index 19e68d1ef7..a804e3d4e0 100644
--- a/UnitsNet.Tests/GeneratedCode/EntropyTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/EntropyTestsBase.g.cs
@@ -108,6 +108,40 @@ public void As()
AssertEx.EqualTolerance(MegajoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.MegajoulePerKelvin), MegajoulesPerKelvinTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var jouleperkelvin = Entropy.FromJoulesPerKelvin(1);
+
+ var calorieperkelvinQuantity = jouleperkelvin.ToUnit(EntropyUnit.CaloriePerKelvin);
+ AssertEx.EqualTolerance(CaloriesPerKelvinInOneJoulePerKelvin, (double)calorieperkelvinQuantity.Value, CaloriesPerKelvinTolerance);
+ Assert.Equal(EntropyUnit.CaloriePerKelvin, calorieperkelvinQuantity.Unit);
+
+ var jouleperdegreecelsiusQuantity = jouleperkelvin.ToUnit(EntropyUnit.JoulePerDegreeCelsius);
+ AssertEx.EqualTolerance(JoulesPerDegreeCelsiusInOneJoulePerKelvin, (double)jouleperdegreecelsiusQuantity.Value, JoulesPerDegreeCelsiusTolerance);
+ Assert.Equal(EntropyUnit.JoulePerDegreeCelsius, jouleperdegreecelsiusQuantity.Unit);
+
+ var jouleperkelvinQuantity = jouleperkelvin.ToUnit(EntropyUnit.JoulePerKelvin);
+ AssertEx.EqualTolerance(JoulesPerKelvinInOneJoulePerKelvin, (double)jouleperkelvinQuantity.Value, JoulesPerKelvinTolerance);
+ Assert.Equal(EntropyUnit.JoulePerKelvin, jouleperkelvinQuantity.Unit);
+
+ var kilocalorieperkelvinQuantity = jouleperkelvin.ToUnit(EntropyUnit.KilocaloriePerKelvin);
+ AssertEx.EqualTolerance(KilocaloriesPerKelvinInOneJoulePerKelvin, (double)kilocalorieperkelvinQuantity.Value, KilocaloriesPerKelvinTolerance);
+ Assert.Equal(EntropyUnit.KilocaloriePerKelvin, kilocalorieperkelvinQuantity.Unit);
+
+ var kilojouleperdegreecelsiusQuantity = jouleperkelvin.ToUnit(EntropyUnit.KilojoulePerDegreeCelsius);
+ AssertEx.EqualTolerance(KilojoulesPerDegreeCelsiusInOneJoulePerKelvin, (double)kilojouleperdegreecelsiusQuantity.Value, KilojoulesPerDegreeCelsiusTolerance);
+ Assert.Equal(EntropyUnit.KilojoulePerDegreeCelsius, kilojouleperdegreecelsiusQuantity.Unit);
+
+ var kilojouleperkelvinQuantity = jouleperkelvin.ToUnit(EntropyUnit.KilojoulePerKelvin);
+ AssertEx.EqualTolerance(KilojoulesPerKelvinInOneJoulePerKelvin, (double)kilojouleperkelvinQuantity.Value, KilojoulesPerKelvinTolerance);
+ Assert.Equal(EntropyUnit.KilojoulePerKelvin, kilojouleperkelvinQuantity.Unit);
+
+ var megajouleperkelvinQuantity = jouleperkelvin.ToUnit(EntropyUnit.MegajoulePerKelvin);
+ AssertEx.EqualTolerance(MegajoulesPerKelvinInOneJoulePerKelvin, (double)megajouleperkelvinQuantity.Value, MegajoulesPerKelvinTolerance);
+ Assert.Equal(EntropyUnit.MegajoulePerKelvin, megajouleperkelvinQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/FlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/FlowTestsBase.g.cs
index bd660e58c2..a37b4b45ee 100644
--- a/UnitsNet.Tests/GeneratedCode/FlowTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/FlowTestsBase.g.cs
@@ -193,6 +193,108 @@ public void As()
AssertEx.EqualTolerance(UsGallonsPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.As(FlowUnit.UsGallonsPerSecond), UsGallonsPerSecondTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var cubicmeterpersecond = Flow.FromCubicMetersPerSecond(1);
+
+ var centilitersperminuteQuantity = cubicmeterpersecond.ToUnit(FlowUnit.CentilitersPerMinute);
+ AssertEx.EqualTolerance(CentilitersPerMinuteInOneCubicMeterPerSecond, (double)centilitersperminuteQuantity.Value, CentilitersPerMinuteTolerance);
+ Assert.Equal(FlowUnit.CentilitersPerMinute, centilitersperminuteQuantity.Unit);
+
+ var cubicdecimeterperminuteQuantity = cubicmeterpersecond.ToUnit(FlowUnit.CubicDecimeterPerMinute);
+ AssertEx.EqualTolerance(CubicDecimetersPerMinuteInOneCubicMeterPerSecond, (double)cubicdecimeterperminuteQuantity.Value, CubicDecimetersPerMinuteTolerance);
+ Assert.Equal(FlowUnit.CubicDecimeterPerMinute, cubicdecimeterperminuteQuantity.Unit);
+
+ var cubicfootperhourQuantity = cubicmeterpersecond.ToUnit(FlowUnit.CubicFootPerHour);
+ AssertEx.EqualTolerance(CubicFeetPerHourInOneCubicMeterPerSecond, (double)cubicfootperhourQuantity.Value, CubicFeetPerHourTolerance);
+ Assert.Equal(FlowUnit.CubicFootPerHour, cubicfootperhourQuantity.Unit);
+
+ var cubicfootperminuteQuantity = cubicmeterpersecond.ToUnit(FlowUnit.CubicFootPerMinute);
+ AssertEx.EqualTolerance(CubicFeetPerMinuteInOneCubicMeterPerSecond, (double)cubicfootperminuteQuantity.Value, CubicFeetPerMinuteTolerance);
+ Assert.Equal(FlowUnit.CubicFootPerMinute, cubicfootperminuteQuantity.Unit);
+
+ var cubicfootpersecondQuantity = cubicmeterpersecond.ToUnit(FlowUnit.CubicFootPerSecond);
+ AssertEx.EqualTolerance(CubicFeetPerSecondInOneCubicMeterPerSecond, (double)cubicfootpersecondQuantity.Value, CubicFeetPerSecondTolerance);
+ Assert.Equal(FlowUnit.CubicFootPerSecond, cubicfootpersecondQuantity.Unit);
+
+ var cubicmeterperhourQuantity = cubicmeterpersecond.ToUnit(FlowUnit.CubicMeterPerHour);
+ AssertEx.EqualTolerance(CubicMetersPerHourInOneCubicMeterPerSecond, (double)cubicmeterperhourQuantity.Value, CubicMetersPerHourTolerance);
+ Assert.Equal(FlowUnit.CubicMeterPerHour, cubicmeterperhourQuantity.Unit);
+
+ var cubicmeterperminuteQuantity = cubicmeterpersecond.ToUnit(FlowUnit.CubicMeterPerMinute);
+ AssertEx.EqualTolerance(CubicMetersPerMinuteInOneCubicMeterPerSecond, (double)cubicmeterperminuteQuantity.Value, CubicMetersPerMinuteTolerance);
+ Assert.Equal(FlowUnit.CubicMeterPerMinute, cubicmeterperminuteQuantity.Unit);
+
+ var cubicmeterpersecondQuantity = cubicmeterpersecond.ToUnit(FlowUnit.CubicMeterPerSecond);
+ AssertEx.EqualTolerance(CubicMetersPerSecondInOneCubicMeterPerSecond, (double)cubicmeterpersecondQuantity.Value, CubicMetersPerSecondTolerance);
+ Assert.Equal(FlowUnit.CubicMeterPerSecond, cubicmeterpersecondQuantity.Unit);
+
+ var cubicyardperhourQuantity = cubicmeterpersecond.ToUnit(FlowUnit.CubicYardPerHour);
+ AssertEx.EqualTolerance(CubicYardsPerHourInOneCubicMeterPerSecond, (double)cubicyardperhourQuantity.Value, CubicYardsPerHourTolerance);
+ Assert.Equal(FlowUnit.CubicYardPerHour, cubicyardperhourQuantity.Unit);
+
+ var cubicyardperminuteQuantity = cubicmeterpersecond.ToUnit(FlowUnit.CubicYardPerMinute);
+ AssertEx.EqualTolerance(CubicYardsPerMinuteInOneCubicMeterPerSecond, (double)cubicyardperminuteQuantity.Value, CubicYardsPerMinuteTolerance);
+ Assert.Equal(FlowUnit.CubicYardPerMinute, cubicyardperminuteQuantity.Unit);
+
+ var cubicyardpersecondQuantity = cubicmeterpersecond.ToUnit(FlowUnit.CubicYardPerSecond);
+ AssertEx.EqualTolerance(CubicYardsPerSecondInOneCubicMeterPerSecond, (double)cubicyardpersecondQuantity.Value, CubicYardsPerSecondTolerance);
+ Assert.Equal(FlowUnit.CubicYardPerSecond, cubicyardpersecondQuantity.Unit);
+
+ var decilitersperminuteQuantity = cubicmeterpersecond.ToUnit(FlowUnit.DecilitersPerMinute);
+ AssertEx.EqualTolerance(DecilitersPerMinuteInOneCubicMeterPerSecond, (double)decilitersperminuteQuantity.Value, DecilitersPerMinuteTolerance);
+ Assert.Equal(FlowUnit.DecilitersPerMinute, decilitersperminuteQuantity.Unit);
+
+ var kilolitersperminuteQuantity = cubicmeterpersecond.ToUnit(FlowUnit.KilolitersPerMinute);
+ AssertEx.EqualTolerance(KilolitersPerMinuteInOneCubicMeterPerSecond, (double)kilolitersperminuteQuantity.Value, KilolitersPerMinuteTolerance);
+ Assert.Equal(FlowUnit.KilolitersPerMinute, kilolitersperminuteQuantity.Unit);
+
+ var litersperhourQuantity = cubicmeterpersecond.ToUnit(FlowUnit.LitersPerHour);
+ AssertEx.EqualTolerance(LitersPerHourInOneCubicMeterPerSecond, (double)litersperhourQuantity.Value, LitersPerHourTolerance);
+ Assert.Equal(FlowUnit.LitersPerHour, litersperhourQuantity.Unit);
+
+ var litersperminuteQuantity = cubicmeterpersecond.ToUnit(FlowUnit.LitersPerMinute);
+ AssertEx.EqualTolerance(LitersPerMinuteInOneCubicMeterPerSecond, (double)litersperminuteQuantity.Value, LitersPerMinuteTolerance);
+ Assert.Equal(FlowUnit.LitersPerMinute, litersperminuteQuantity.Unit);
+
+ var literspersecondQuantity = cubicmeterpersecond.ToUnit(FlowUnit.LitersPerSecond);
+ AssertEx.EqualTolerance(LitersPerSecondInOneCubicMeterPerSecond, (double)literspersecondQuantity.Value, LitersPerSecondTolerance);
+ Assert.Equal(FlowUnit.LitersPerSecond, literspersecondQuantity.Unit);
+
+ var microlitersperminuteQuantity = cubicmeterpersecond.ToUnit(FlowUnit.MicrolitersPerMinute);
+ AssertEx.EqualTolerance(MicrolitersPerMinuteInOneCubicMeterPerSecond, (double)microlitersperminuteQuantity.Value, MicrolitersPerMinuteTolerance);
+ Assert.Equal(FlowUnit.MicrolitersPerMinute, microlitersperminuteQuantity.Unit);
+
+ var millilitersperminuteQuantity = cubicmeterpersecond.ToUnit(FlowUnit.MillilitersPerMinute);
+ AssertEx.EqualTolerance(MillilitersPerMinuteInOneCubicMeterPerSecond, (double)millilitersperminuteQuantity.Value, MillilitersPerMinuteTolerance);
+ Assert.Equal(FlowUnit.MillilitersPerMinute, millilitersperminuteQuantity.Unit);
+
+ var millionusgallonsperdayQuantity = cubicmeterpersecond.ToUnit(FlowUnit.MillionUsGallonsPerDay);
+ AssertEx.EqualTolerance(MillionUsGallonsPerDayInOneCubicMeterPerSecond, (double)millionusgallonsperdayQuantity.Value, MillionUsGallonsPerDayTolerance);
+ Assert.Equal(FlowUnit.MillionUsGallonsPerDay, millionusgallonsperdayQuantity.Unit);
+
+ var nanolitersperminuteQuantity = cubicmeterpersecond.ToUnit(FlowUnit.NanolitersPerMinute);
+ AssertEx.EqualTolerance(NanolitersPerMinuteInOneCubicMeterPerSecond, (double)nanolitersperminuteQuantity.Value, NanolitersPerMinuteTolerance);
+ Assert.Equal(FlowUnit.NanolitersPerMinute, nanolitersperminuteQuantity.Unit);
+
+ var oilbarrelsperdayQuantity = cubicmeterpersecond.ToUnit(FlowUnit.OilBarrelsPerDay);
+ AssertEx.EqualTolerance(OilBarrelsPerDayInOneCubicMeterPerSecond, (double)oilbarrelsperdayQuantity.Value, OilBarrelsPerDayTolerance);
+ Assert.Equal(FlowUnit.OilBarrelsPerDay, oilbarrelsperdayQuantity.Unit);
+
+ var usgallonsperhourQuantity = cubicmeterpersecond.ToUnit(FlowUnit.UsGallonsPerHour);
+ AssertEx.EqualTolerance(UsGallonsPerHourInOneCubicMeterPerSecond, (double)usgallonsperhourQuantity.Value, UsGallonsPerHourTolerance);
+ Assert.Equal(FlowUnit.UsGallonsPerHour, usgallonsperhourQuantity.Unit);
+
+ var usgallonsperminuteQuantity = cubicmeterpersecond.ToUnit(FlowUnit.UsGallonsPerMinute);
+ AssertEx.EqualTolerance(UsGallonsPerMinuteInOneCubicMeterPerSecond, (double)usgallonsperminuteQuantity.Value, UsGallonsPerMinuteTolerance);
+ Assert.Equal(FlowUnit.UsGallonsPerMinute, usgallonsperminuteQuantity.Unit);
+
+ var usgallonspersecondQuantity = cubicmeterpersecond.ToUnit(FlowUnit.UsGallonsPerSecond);
+ AssertEx.EqualTolerance(UsGallonsPerSecondInOneCubicMeterPerSecond, (double)usgallonspersecondQuantity.Value, UsGallonsPerSecondTolerance);
+ Assert.Equal(FlowUnit.UsGallonsPerSecond, usgallonspersecondQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ForceChangeRateTestsBase.g.cs
index 42351f2075..988a85ea5f 100644
--- a/UnitsNet.Tests/GeneratedCode/ForceChangeRateTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ForceChangeRateTestsBase.g.cs
@@ -128,6 +128,56 @@ public void As()
AssertEx.EqualTolerance(NewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.As(ForceChangeRateUnit.NewtonPerSecond), NewtonsPerSecondTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1);
+
+ var centinewtonpersecondQuantity = newtonpersecond.ToUnit(ForceChangeRateUnit.CentinewtonPerSecond);
+ AssertEx.EqualTolerance(CentinewtonsPerSecondInOneNewtonPerSecond, (double)centinewtonpersecondQuantity.Value, CentinewtonsPerSecondTolerance);
+ Assert.Equal(ForceChangeRateUnit.CentinewtonPerSecond, centinewtonpersecondQuantity.Unit);
+
+ var decanewtonperminuteQuantity = newtonpersecond.ToUnit(ForceChangeRateUnit.DecanewtonPerMinute);
+ AssertEx.EqualTolerance(DecanewtonsPerMinuteInOneNewtonPerSecond, (double)decanewtonperminuteQuantity.Value, DecanewtonsPerMinuteTolerance);
+ Assert.Equal(ForceChangeRateUnit.DecanewtonPerMinute, decanewtonperminuteQuantity.Unit);
+
+ var decanewtonpersecondQuantity = newtonpersecond.ToUnit(ForceChangeRateUnit.DecanewtonPerSecond);
+ AssertEx.EqualTolerance(DecanewtonsPerSecondInOneNewtonPerSecond, (double)decanewtonpersecondQuantity.Value, DecanewtonsPerSecondTolerance);
+ Assert.Equal(ForceChangeRateUnit.DecanewtonPerSecond, decanewtonpersecondQuantity.Unit);
+
+ var decinewtonpersecondQuantity = newtonpersecond.ToUnit(ForceChangeRateUnit.DecinewtonPerSecond);
+ AssertEx.EqualTolerance(DecinewtonsPerSecondInOneNewtonPerSecond, (double)decinewtonpersecondQuantity.Value, DecinewtonsPerSecondTolerance);
+ Assert.Equal(ForceChangeRateUnit.DecinewtonPerSecond, decinewtonpersecondQuantity.Unit);
+
+ var kilonewtonperminuteQuantity = newtonpersecond.ToUnit(ForceChangeRateUnit.KilonewtonPerMinute);
+ AssertEx.EqualTolerance(KilonewtonsPerMinuteInOneNewtonPerSecond, (double)kilonewtonperminuteQuantity.Value, KilonewtonsPerMinuteTolerance);
+ Assert.Equal(ForceChangeRateUnit.KilonewtonPerMinute, kilonewtonperminuteQuantity.Unit);
+
+ var kilonewtonpersecondQuantity = newtonpersecond.ToUnit(ForceChangeRateUnit.KilonewtonPerSecond);
+ AssertEx.EqualTolerance(KilonewtonsPerSecondInOneNewtonPerSecond, (double)kilonewtonpersecondQuantity.Value, KilonewtonsPerSecondTolerance);
+ Assert.Equal(ForceChangeRateUnit.KilonewtonPerSecond, kilonewtonpersecondQuantity.Unit);
+
+ var micronewtonpersecondQuantity = newtonpersecond.ToUnit(ForceChangeRateUnit.MicronewtonPerSecond);
+ AssertEx.EqualTolerance(MicronewtonsPerSecondInOneNewtonPerSecond, (double)micronewtonpersecondQuantity.Value, MicronewtonsPerSecondTolerance);
+ Assert.Equal(ForceChangeRateUnit.MicronewtonPerSecond, micronewtonpersecondQuantity.Unit);
+
+ var millinewtonpersecondQuantity = newtonpersecond.ToUnit(ForceChangeRateUnit.MillinewtonPerSecond);
+ AssertEx.EqualTolerance(MillinewtonsPerSecondInOneNewtonPerSecond, (double)millinewtonpersecondQuantity.Value, MillinewtonsPerSecondTolerance);
+ Assert.Equal(ForceChangeRateUnit.MillinewtonPerSecond, millinewtonpersecondQuantity.Unit);
+
+ var nanonewtonpersecondQuantity = newtonpersecond.ToUnit(ForceChangeRateUnit.NanonewtonPerSecond);
+ AssertEx.EqualTolerance(NanonewtonsPerSecondInOneNewtonPerSecond, (double)nanonewtonpersecondQuantity.Value, NanonewtonsPerSecondTolerance);
+ Assert.Equal(ForceChangeRateUnit.NanonewtonPerSecond, nanonewtonpersecondQuantity.Unit);
+
+ var newtonperminuteQuantity = newtonpersecond.ToUnit(ForceChangeRateUnit.NewtonPerMinute);
+ AssertEx.EqualTolerance(NewtonsPerMinuteInOneNewtonPerSecond, (double)newtonperminuteQuantity.Value, NewtonsPerMinuteTolerance);
+ Assert.Equal(ForceChangeRateUnit.NewtonPerMinute, newtonperminuteQuantity.Unit);
+
+ var newtonpersecondQuantity = newtonpersecond.ToUnit(ForceChangeRateUnit.NewtonPerSecond);
+ AssertEx.EqualTolerance(NewtonsPerSecondInOneNewtonPerSecond, (double)newtonpersecondQuantity.Value, NewtonsPerSecondTolerance);
+ Assert.Equal(ForceChangeRateUnit.NewtonPerSecond, newtonpersecondQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ForcePerLengthTestsBase.g.cs
index d0a5b55188..adbee4666d 100644
--- a/UnitsNet.Tests/GeneratedCode/ForcePerLengthTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ForcePerLengthTestsBase.g.cs
@@ -118,6 +118,48 @@ public void As()
AssertEx.EqualTolerance(NewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.NewtonPerMeter), NewtonsPerMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1);
+
+ var centinewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.CentinewtonPerMeter);
+ AssertEx.EqualTolerance(CentinewtonsPerMeterInOneNewtonPerMeter, (double)centinewtonpermeterQuantity.Value, CentinewtonsPerMeterTolerance);
+ Assert.Equal(ForcePerLengthUnit.CentinewtonPerMeter, centinewtonpermeterQuantity.Unit);
+
+ var decinewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.DecinewtonPerMeter);
+ AssertEx.EqualTolerance(DecinewtonsPerMeterInOneNewtonPerMeter, (double)decinewtonpermeterQuantity.Value, DecinewtonsPerMeterTolerance);
+ Assert.Equal(ForcePerLengthUnit.DecinewtonPerMeter, decinewtonpermeterQuantity.Unit);
+
+ var kilogramforcepermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.KilogramForcePerMeter);
+ AssertEx.EqualTolerance(KilogramsForcePerMeterInOneNewtonPerMeter, (double)kilogramforcepermeterQuantity.Value, KilogramsForcePerMeterTolerance);
+ Assert.Equal(ForcePerLengthUnit.KilogramForcePerMeter, kilogramforcepermeterQuantity.Unit);
+
+ var kilonewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.KilonewtonPerMeter);
+ AssertEx.EqualTolerance(KilonewtonsPerMeterInOneNewtonPerMeter, (double)kilonewtonpermeterQuantity.Value, KilonewtonsPerMeterTolerance);
+ Assert.Equal(ForcePerLengthUnit.KilonewtonPerMeter, kilonewtonpermeterQuantity.Unit);
+
+ var meganewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.MeganewtonPerMeter);
+ AssertEx.EqualTolerance(MeganewtonsPerMeterInOneNewtonPerMeter, (double)meganewtonpermeterQuantity.Value, MeganewtonsPerMeterTolerance);
+ Assert.Equal(ForcePerLengthUnit.MeganewtonPerMeter, meganewtonpermeterQuantity.Unit);
+
+ var micronewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.MicronewtonPerMeter);
+ AssertEx.EqualTolerance(MicronewtonsPerMeterInOneNewtonPerMeter, (double)micronewtonpermeterQuantity.Value, MicronewtonsPerMeterTolerance);
+ Assert.Equal(ForcePerLengthUnit.MicronewtonPerMeter, micronewtonpermeterQuantity.Unit);
+
+ var millinewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.MillinewtonPerMeter);
+ AssertEx.EqualTolerance(MillinewtonsPerMeterInOneNewtonPerMeter, (double)millinewtonpermeterQuantity.Value, MillinewtonsPerMeterTolerance);
+ Assert.Equal(ForcePerLengthUnit.MillinewtonPerMeter, millinewtonpermeterQuantity.Unit);
+
+ var nanonewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.NanonewtonPerMeter);
+ AssertEx.EqualTolerance(NanonewtonsPerMeterInOneNewtonPerMeter, (double)nanonewtonpermeterQuantity.Value, NanonewtonsPerMeterTolerance);
+ Assert.Equal(ForcePerLengthUnit.NanonewtonPerMeter, nanonewtonpermeterQuantity.Unit);
+
+ var newtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.NewtonPerMeter);
+ AssertEx.EqualTolerance(NewtonsPerMeterInOneNewtonPerMeter, (double)newtonpermeterQuantity.Value, NewtonsPerMeterTolerance);
+ Assert.Equal(ForcePerLengthUnit.NewtonPerMeter, newtonpermeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ForceTestsBase.g.cs
index 8d1333b352..96df940303 100644
--- a/UnitsNet.Tests/GeneratedCode/ForceTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ForceTestsBase.g.cs
@@ -123,6 +123,52 @@ public void As()
AssertEx.EqualTolerance(TonnesForceInOneNewton, newton.As(ForceUnit.TonneForce), TonnesForceTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var newton = Force.FromNewtons(1);
+
+ var decanewtonQuantity = newton.ToUnit(ForceUnit.Decanewton);
+ AssertEx.EqualTolerance(DecanewtonsInOneNewton, (double)decanewtonQuantity.Value, DecanewtonsTolerance);
+ Assert.Equal(ForceUnit.Decanewton, decanewtonQuantity.Unit);
+
+ var dynQuantity = newton.ToUnit(ForceUnit.Dyn);
+ AssertEx.EqualTolerance(DyneInOneNewton, (double)dynQuantity.Value, DyneTolerance);
+ Assert.Equal(ForceUnit.Dyn, dynQuantity.Unit);
+
+ var kilogramforceQuantity = newton.ToUnit(ForceUnit.KilogramForce);
+ AssertEx.EqualTolerance(KilogramsForceInOneNewton, (double)kilogramforceQuantity.Value, KilogramsForceTolerance);
+ Assert.Equal(ForceUnit.KilogramForce, kilogramforceQuantity.Unit);
+
+ var kilonewtonQuantity = newton.ToUnit(ForceUnit.Kilonewton);
+ AssertEx.EqualTolerance(KilonewtonsInOneNewton, (double)kilonewtonQuantity.Value, KilonewtonsTolerance);
+ Assert.Equal(ForceUnit.Kilonewton, kilonewtonQuantity.Unit);
+
+ var kilopondQuantity = newton.ToUnit(ForceUnit.KiloPond);
+ AssertEx.EqualTolerance(KiloPondsInOneNewton, (double)kilopondQuantity.Value, KiloPondsTolerance);
+ Assert.Equal(ForceUnit.KiloPond, kilopondQuantity.Unit);
+
+ var meganewtonQuantity = newton.ToUnit(ForceUnit.Meganewton);
+ AssertEx.EqualTolerance(MeganewtonsInOneNewton, (double)meganewtonQuantity.Value, MeganewtonsTolerance);
+ Assert.Equal(ForceUnit.Meganewton, meganewtonQuantity.Unit);
+
+ var newtonQuantity = newton.ToUnit(ForceUnit.Newton);
+ AssertEx.EqualTolerance(NewtonsInOneNewton, (double)newtonQuantity.Value, NewtonsTolerance);
+ Assert.Equal(ForceUnit.Newton, newtonQuantity.Unit);
+
+ var poundalQuantity = newton.ToUnit(ForceUnit.Poundal);
+ AssertEx.EqualTolerance(PoundalsInOneNewton, (double)poundalQuantity.Value, PoundalsTolerance);
+ Assert.Equal(ForceUnit.Poundal, poundalQuantity.Unit);
+
+ var poundforceQuantity = newton.ToUnit(ForceUnit.PoundForce);
+ AssertEx.EqualTolerance(PoundsForceInOneNewton, (double)poundforceQuantity.Value, PoundsForceTolerance);
+ Assert.Equal(ForceUnit.PoundForce, poundforceQuantity.Unit);
+
+ var tonneforceQuantity = newton.ToUnit(ForceUnit.TonneForce);
+ AssertEx.EqualTolerance(TonnesForceInOneNewton, (double)tonneforceQuantity.Value, TonnesForceTolerance);
+ Assert.Equal(ForceUnit.TonneForce, tonneforceQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/FrequencyTestsBase.g.cs
index 1abe276214..7d5cb3f8d9 100644
--- a/UnitsNet.Tests/GeneratedCode/FrequencyTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/FrequencyTestsBase.g.cs
@@ -113,6 +113,44 @@ public void As()
AssertEx.EqualTolerance(TerahertzInOneHertz, hertz.As(FrequencyUnit.Terahertz), TerahertzTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var hertz = Frequency.FromHertz(1);
+
+ var cycleperhourQuantity = hertz.ToUnit(FrequencyUnit.CyclePerHour);
+ AssertEx.EqualTolerance(CyclesPerHourInOneHertz, (double)cycleperhourQuantity.Value, CyclesPerHourTolerance);
+ Assert.Equal(FrequencyUnit.CyclePerHour, cycleperhourQuantity.Unit);
+
+ var cycleperminuteQuantity = hertz.ToUnit(FrequencyUnit.CyclePerMinute);
+ AssertEx.EqualTolerance(CyclesPerMinuteInOneHertz, (double)cycleperminuteQuantity.Value, CyclesPerMinuteTolerance);
+ Assert.Equal(FrequencyUnit.CyclePerMinute, cycleperminuteQuantity.Unit);
+
+ var gigahertzQuantity = hertz.ToUnit(FrequencyUnit.Gigahertz);
+ AssertEx.EqualTolerance(GigahertzInOneHertz, (double)gigahertzQuantity.Value, GigahertzTolerance);
+ Assert.Equal(FrequencyUnit.Gigahertz, gigahertzQuantity.Unit);
+
+ var hertzQuantity = hertz.ToUnit(FrequencyUnit.Hertz);
+ AssertEx.EqualTolerance(HertzInOneHertz, (double)hertzQuantity.Value, HertzTolerance);
+ Assert.Equal(FrequencyUnit.Hertz, hertzQuantity.Unit);
+
+ var kilohertzQuantity = hertz.ToUnit(FrequencyUnit.Kilohertz);
+ AssertEx.EqualTolerance(KilohertzInOneHertz, (double)kilohertzQuantity.Value, KilohertzTolerance);
+ Assert.Equal(FrequencyUnit.Kilohertz, kilohertzQuantity.Unit);
+
+ var megahertzQuantity = hertz.ToUnit(FrequencyUnit.Megahertz);
+ AssertEx.EqualTolerance(MegahertzInOneHertz, (double)megahertzQuantity.Value, MegahertzTolerance);
+ Assert.Equal(FrequencyUnit.Megahertz, megahertzQuantity.Unit);
+
+ var radianpersecondQuantity = hertz.ToUnit(FrequencyUnit.RadianPerSecond);
+ AssertEx.EqualTolerance(RadiansPerSecondInOneHertz, (double)radianpersecondQuantity.Value, RadiansPerSecondTolerance);
+ Assert.Equal(FrequencyUnit.RadianPerSecond, radianpersecondQuantity.Unit);
+
+ var terahertzQuantity = hertz.ToUnit(FrequencyUnit.Terahertz);
+ AssertEx.EqualTolerance(TerahertzInOneHertz, (double)terahertzQuantity.Value, TerahertzTolerance);
+ Assert.Equal(FrequencyUnit.Terahertz, terahertzQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/HeatFluxTestsBase.g.cs
index 48efc387cf..e45a582e3c 100644
--- a/UnitsNet.Tests/GeneratedCode/HeatFluxTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/HeatFluxTestsBase.g.cs
@@ -153,6 +153,76 @@ public void As()
AssertEx.EqualTolerance(WattsPerSquareMeterInOneWattPerSquareMeter, wattpersquaremeter.As(HeatFluxUnit.WattPerSquareMeter), WattsPerSquareMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1);
+
+ var btuperhoursquarefootQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.BtuPerHourSquareFoot);
+ AssertEx.EqualTolerance(BtusPerHourSquareFootInOneWattPerSquareMeter, (double)btuperhoursquarefootQuantity.Value, BtusPerHourSquareFootTolerance);
+ Assert.Equal(HeatFluxUnit.BtuPerHourSquareFoot, btuperhoursquarefootQuantity.Unit);
+
+ var btuperminutesquarefootQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.BtuPerMinuteSquareFoot);
+ AssertEx.EqualTolerance(BtusPerMinuteSquareFootInOneWattPerSquareMeter, (double)btuperminutesquarefootQuantity.Value, BtusPerMinuteSquareFootTolerance);
+ Assert.Equal(HeatFluxUnit.BtuPerMinuteSquareFoot, btuperminutesquarefootQuantity.Unit);
+
+ var btupersecondsquarefootQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.BtuPerSecondSquareFoot);
+ AssertEx.EqualTolerance(BtusPerSecondSquareFootInOneWattPerSquareMeter, (double)btupersecondsquarefootQuantity.Value, BtusPerSecondSquareFootTolerance);
+ Assert.Equal(HeatFluxUnit.BtuPerSecondSquareFoot, btupersecondsquarefootQuantity.Unit);
+
+ var btupersecondsquareinchQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.BtuPerSecondSquareInch);
+ AssertEx.EqualTolerance(BtusPerSecondSquareInchInOneWattPerSquareMeter, (double)btupersecondsquareinchQuantity.Value, BtusPerSecondSquareInchTolerance);
+ Assert.Equal(HeatFluxUnit.BtuPerSecondSquareInch, btupersecondsquareinchQuantity.Unit);
+
+ var caloriepersecondsquarecentimeterQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.CaloriePerSecondSquareCentimeter);
+ AssertEx.EqualTolerance(CaloriesPerSecondSquareCentimeterInOneWattPerSquareMeter, (double)caloriepersecondsquarecentimeterQuantity.Value, CaloriesPerSecondSquareCentimeterTolerance);
+ Assert.Equal(HeatFluxUnit.CaloriePerSecondSquareCentimeter, caloriepersecondsquarecentimeterQuantity.Unit);
+
+ var centiwattpersquaremeterQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.CentiwattPerSquareMeter);
+ AssertEx.EqualTolerance(CentiwattsPerSquareMeterInOneWattPerSquareMeter, (double)centiwattpersquaremeterQuantity.Value, CentiwattsPerSquareMeterTolerance);
+ Assert.Equal(HeatFluxUnit.CentiwattPerSquareMeter, centiwattpersquaremeterQuantity.Unit);
+
+ var deciwattpersquaremeterQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.DeciwattPerSquareMeter);
+ AssertEx.EqualTolerance(DeciwattsPerSquareMeterInOneWattPerSquareMeter, (double)deciwattpersquaremeterQuantity.Value, DeciwattsPerSquareMeterTolerance);
+ Assert.Equal(HeatFluxUnit.DeciwattPerSquareMeter, deciwattpersquaremeterQuantity.Unit);
+
+ var kilocalorieperhoursquaremeterQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.KilocaloriePerHourSquareMeter);
+ AssertEx.EqualTolerance(KilocaloriesPerHourSquareMeterInOneWattPerSquareMeter, (double)kilocalorieperhoursquaremeterQuantity.Value, KilocaloriesPerHourSquareMeterTolerance);
+ Assert.Equal(HeatFluxUnit.KilocaloriePerHourSquareMeter, kilocalorieperhoursquaremeterQuantity.Unit);
+
+ var kilocaloriepersecondsquarecentimeterQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter);
+ AssertEx.EqualTolerance(KilocaloriesPerSecondSquareCentimeterInOneWattPerSquareMeter, (double)kilocaloriepersecondsquarecentimeterQuantity.Value, KilocaloriesPerSecondSquareCentimeterTolerance);
+ Assert.Equal(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, kilocaloriepersecondsquarecentimeterQuantity.Unit);
+
+ var kilowattpersquaremeterQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.KilowattPerSquareMeter);
+ AssertEx.EqualTolerance(KilowattsPerSquareMeterInOneWattPerSquareMeter, (double)kilowattpersquaremeterQuantity.Value, KilowattsPerSquareMeterTolerance);
+ Assert.Equal(HeatFluxUnit.KilowattPerSquareMeter, kilowattpersquaremeterQuantity.Unit);
+
+ var microwattpersquaremeterQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.MicrowattPerSquareMeter);
+ AssertEx.EqualTolerance(MicrowattsPerSquareMeterInOneWattPerSquareMeter, (double)microwattpersquaremeterQuantity.Value, MicrowattsPerSquareMeterTolerance);
+ Assert.Equal(HeatFluxUnit.MicrowattPerSquareMeter, microwattpersquaremeterQuantity.Unit);
+
+ var milliwattpersquaremeterQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.MilliwattPerSquareMeter);
+ AssertEx.EqualTolerance(MilliwattsPerSquareMeterInOneWattPerSquareMeter, (double)milliwattpersquaremeterQuantity.Value, MilliwattsPerSquareMeterTolerance);
+ Assert.Equal(HeatFluxUnit.MilliwattPerSquareMeter, milliwattpersquaremeterQuantity.Unit);
+
+ var nanowattpersquaremeterQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.NanowattPerSquareMeter);
+ AssertEx.EqualTolerance(NanowattsPerSquareMeterInOneWattPerSquareMeter, (double)nanowattpersquaremeterQuantity.Value, NanowattsPerSquareMeterTolerance);
+ Assert.Equal(HeatFluxUnit.NanowattPerSquareMeter, nanowattpersquaremeterQuantity.Unit);
+
+ var wattpersquarefootQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.WattPerSquareFoot);
+ AssertEx.EqualTolerance(WattsPerSquareFootInOneWattPerSquareMeter, (double)wattpersquarefootQuantity.Value, WattsPerSquareFootTolerance);
+ Assert.Equal(HeatFluxUnit.WattPerSquareFoot, wattpersquarefootQuantity.Unit);
+
+ var wattpersquareinchQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.WattPerSquareInch);
+ AssertEx.EqualTolerance(WattsPerSquareInchInOneWattPerSquareMeter, (double)wattpersquareinchQuantity.Value, WattsPerSquareInchTolerance);
+ Assert.Equal(HeatFluxUnit.WattPerSquareInch, wattpersquareinchQuantity.Unit);
+
+ var wattpersquaremeterQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.WattPerSquareMeter);
+ AssertEx.EqualTolerance(WattsPerSquareMeterInOneWattPerSquareMeter, (double)wattpersquaremeterQuantity.Value, WattsPerSquareMeterTolerance);
+ Assert.Equal(HeatFluxUnit.WattPerSquareMeter, wattpersquaremeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/HeatTransferCoefficientTestsBase.g.cs
index 24ca97ae35..19fa30d007 100644
--- a/UnitsNet.Tests/GeneratedCode/HeatTransferCoefficientTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/HeatTransferCoefficientTestsBase.g.cs
@@ -83,6 +83,20 @@ public void As()
AssertEx.EqualTolerance(WattsPerSquareMeterKelvinInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin), WattsPerSquareMeterKelvinTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1);
+
+ var wattpersquaremetercelsiusQuantity = wattpersquaremeterkelvin.ToUnit(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius);
+ AssertEx.EqualTolerance(WattsPerSquareMeterCelsiusInOneWattPerSquareMeterKelvin, (double)wattpersquaremetercelsiusQuantity.Value, WattsPerSquareMeterCelsiusTolerance);
+ Assert.Equal(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, wattpersquaremetercelsiusQuantity.Unit);
+
+ var wattpersquaremeterkelvinQuantity = wattpersquaremeterkelvin.ToUnit(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin);
+ AssertEx.EqualTolerance(WattsPerSquareMeterKelvinInOneWattPerSquareMeterKelvin, (double)wattpersquaremeterkelvinQuantity.Value, WattsPerSquareMeterKelvinTolerance);
+ Assert.Equal(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, wattpersquaremeterkelvinQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/IlluminanceTestsBase.g.cs
index aa2f8cb5b9..92c4091daa 100644
--- a/UnitsNet.Tests/GeneratedCode/IlluminanceTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/IlluminanceTestsBase.g.cs
@@ -93,6 +93,28 @@ public void As()
AssertEx.EqualTolerance(MilliluxInOneLux, lux.As(IlluminanceUnit.Millilux), MilliluxTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var lux = Illuminance.FromLux(1);
+
+ var kiloluxQuantity = lux.ToUnit(IlluminanceUnit.Kilolux);
+ AssertEx.EqualTolerance(KiloluxInOneLux, (double)kiloluxQuantity.Value, KiloluxTolerance);
+ Assert.Equal(IlluminanceUnit.Kilolux, kiloluxQuantity.Unit);
+
+ var luxQuantity = lux.ToUnit(IlluminanceUnit.Lux);
+ AssertEx.EqualTolerance(LuxInOneLux, (double)luxQuantity.Value, LuxTolerance);
+ Assert.Equal(IlluminanceUnit.Lux, luxQuantity.Unit);
+
+ var megaluxQuantity = lux.ToUnit(IlluminanceUnit.Megalux);
+ AssertEx.EqualTolerance(MegaluxInOneLux, (double)megaluxQuantity.Value, MegaluxTolerance);
+ Assert.Equal(IlluminanceUnit.Megalux, megaluxQuantity.Unit);
+
+ var milliluxQuantity = lux.ToUnit(IlluminanceUnit.Millilux);
+ AssertEx.EqualTolerance(MilliluxInOneLux, (double)milliluxQuantity.Value, MilliluxTolerance);
+ Assert.Equal(IlluminanceUnit.Millilux, milliluxQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/InformationTestsBase.g.cs
index d4addb41e5..edbc0efa2d 100644
--- a/UnitsNet.Tests/GeneratedCode/InformationTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/InformationTestsBase.g.cs
@@ -203,6 +203,116 @@ public void As()
AssertEx.EqualTolerance(TerabytesInOneBit, bit.As(InformationUnit.Terabyte), TerabytesTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var bit = Information.FromBits(1);
+
+ var bitQuantity = bit.ToUnit(InformationUnit.Bit);
+ AssertEx.EqualTolerance(BitsInOneBit, (double)bitQuantity.Value, BitsTolerance);
+ Assert.Equal(InformationUnit.Bit, bitQuantity.Unit);
+
+ var byteQuantity = bit.ToUnit(InformationUnit.Byte);
+ AssertEx.EqualTolerance(BytesInOneBit, (double)byteQuantity.Value, BytesTolerance);
+ Assert.Equal(InformationUnit.Byte, byteQuantity.Unit);
+
+ var exabitQuantity = bit.ToUnit(InformationUnit.Exabit);
+ AssertEx.EqualTolerance(ExabitsInOneBit, (double)exabitQuantity.Value, ExabitsTolerance);
+ Assert.Equal(InformationUnit.Exabit, exabitQuantity.Unit);
+
+ var exabyteQuantity = bit.ToUnit(InformationUnit.Exabyte);
+ AssertEx.EqualTolerance(ExabytesInOneBit, (double)exabyteQuantity.Value, ExabytesTolerance);
+ Assert.Equal(InformationUnit.Exabyte, exabyteQuantity.Unit);
+
+ var exbibitQuantity = bit.ToUnit(InformationUnit.Exbibit);
+ AssertEx.EqualTolerance(ExbibitsInOneBit, (double)exbibitQuantity.Value, ExbibitsTolerance);
+ Assert.Equal(InformationUnit.Exbibit, exbibitQuantity.Unit);
+
+ var exbibyteQuantity = bit.ToUnit(InformationUnit.Exbibyte);
+ AssertEx.EqualTolerance(ExbibytesInOneBit, (double)exbibyteQuantity.Value, ExbibytesTolerance);
+ Assert.Equal(InformationUnit.Exbibyte, exbibyteQuantity.Unit);
+
+ var gibibitQuantity = bit.ToUnit(InformationUnit.Gibibit);
+ AssertEx.EqualTolerance(GibibitsInOneBit, (double)gibibitQuantity.Value, GibibitsTolerance);
+ Assert.Equal(InformationUnit.Gibibit, gibibitQuantity.Unit);
+
+ var gibibyteQuantity = bit.ToUnit(InformationUnit.Gibibyte);
+ AssertEx.EqualTolerance(GibibytesInOneBit, (double)gibibyteQuantity.Value, GibibytesTolerance);
+ Assert.Equal(InformationUnit.Gibibyte, gibibyteQuantity.Unit);
+
+ var gigabitQuantity = bit.ToUnit(InformationUnit.Gigabit);
+ AssertEx.EqualTolerance(GigabitsInOneBit, (double)gigabitQuantity.Value, GigabitsTolerance);
+ Assert.Equal(InformationUnit.Gigabit, gigabitQuantity.Unit);
+
+ var gigabyteQuantity = bit.ToUnit(InformationUnit.Gigabyte);
+ AssertEx.EqualTolerance(GigabytesInOneBit, (double)gigabyteQuantity.Value, GigabytesTolerance);
+ Assert.Equal(InformationUnit.Gigabyte, gigabyteQuantity.Unit);
+
+ var kibibitQuantity = bit.ToUnit(InformationUnit.Kibibit);
+ AssertEx.EqualTolerance(KibibitsInOneBit, (double)kibibitQuantity.Value, KibibitsTolerance);
+ Assert.Equal(InformationUnit.Kibibit, kibibitQuantity.Unit);
+
+ var kibibyteQuantity = bit.ToUnit(InformationUnit.Kibibyte);
+ AssertEx.EqualTolerance(KibibytesInOneBit, (double)kibibyteQuantity.Value, KibibytesTolerance);
+ Assert.Equal(InformationUnit.Kibibyte, kibibyteQuantity.Unit);
+
+ var kilobitQuantity = bit.ToUnit(InformationUnit.Kilobit);
+ AssertEx.EqualTolerance(KilobitsInOneBit, (double)kilobitQuantity.Value, KilobitsTolerance);
+ Assert.Equal(InformationUnit.Kilobit, kilobitQuantity.Unit);
+
+ var kilobyteQuantity = bit.ToUnit(InformationUnit.Kilobyte);
+ AssertEx.EqualTolerance(KilobytesInOneBit, (double)kilobyteQuantity.Value, KilobytesTolerance);
+ Assert.Equal(InformationUnit.Kilobyte, kilobyteQuantity.Unit);
+
+ var mebibitQuantity = bit.ToUnit(InformationUnit.Mebibit);
+ AssertEx.EqualTolerance(MebibitsInOneBit, (double)mebibitQuantity.Value, MebibitsTolerance);
+ Assert.Equal(InformationUnit.Mebibit, mebibitQuantity.Unit);
+
+ var mebibyteQuantity = bit.ToUnit(InformationUnit.Mebibyte);
+ AssertEx.EqualTolerance(MebibytesInOneBit, (double)mebibyteQuantity.Value, MebibytesTolerance);
+ Assert.Equal(InformationUnit.Mebibyte, mebibyteQuantity.Unit);
+
+ var megabitQuantity = bit.ToUnit(InformationUnit.Megabit);
+ AssertEx.EqualTolerance(MegabitsInOneBit, (double)megabitQuantity.Value, MegabitsTolerance);
+ Assert.Equal(InformationUnit.Megabit, megabitQuantity.Unit);
+
+ var megabyteQuantity = bit.ToUnit(InformationUnit.Megabyte);
+ AssertEx.EqualTolerance(MegabytesInOneBit, (double)megabyteQuantity.Value, MegabytesTolerance);
+ Assert.Equal(InformationUnit.Megabyte, megabyteQuantity.Unit);
+
+ var pebibitQuantity = bit.ToUnit(InformationUnit.Pebibit);
+ AssertEx.EqualTolerance(PebibitsInOneBit, (double)pebibitQuantity.Value, PebibitsTolerance);
+ Assert.Equal(InformationUnit.Pebibit, pebibitQuantity.Unit);
+
+ var pebibyteQuantity = bit.ToUnit(InformationUnit.Pebibyte);
+ AssertEx.EqualTolerance(PebibytesInOneBit, (double)pebibyteQuantity.Value, PebibytesTolerance);
+ Assert.Equal(InformationUnit.Pebibyte, pebibyteQuantity.Unit);
+
+ var petabitQuantity = bit.ToUnit(InformationUnit.Petabit);
+ AssertEx.EqualTolerance(PetabitsInOneBit, (double)petabitQuantity.Value, PetabitsTolerance);
+ Assert.Equal(InformationUnit.Petabit, petabitQuantity.Unit);
+
+ var petabyteQuantity = bit.ToUnit(InformationUnit.Petabyte);
+ AssertEx.EqualTolerance(PetabytesInOneBit, (double)petabyteQuantity.Value, PetabytesTolerance);
+ Assert.Equal(InformationUnit.Petabyte, petabyteQuantity.Unit);
+
+ var tebibitQuantity = bit.ToUnit(InformationUnit.Tebibit);
+ AssertEx.EqualTolerance(TebibitsInOneBit, (double)tebibitQuantity.Value, TebibitsTolerance);
+ Assert.Equal(InformationUnit.Tebibit, tebibitQuantity.Unit);
+
+ var tebibyteQuantity = bit.ToUnit(InformationUnit.Tebibyte);
+ AssertEx.EqualTolerance(TebibytesInOneBit, (double)tebibyteQuantity.Value, TebibytesTolerance);
+ Assert.Equal(InformationUnit.Tebibyte, tebibyteQuantity.Unit);
+
+ var terabitQuantity = bit.ToUnit(InformationUnit.Terabit);
+ AssertEx.EqualTolerance(TerabitsInOneBit, (double)terabitQuantity.Value, TerabitsTolerance);
+ Assert.Equal(InformationUnit.Terabit, terabitQuantity.Unit);
+
+ var terabyteQuantity = bit.ToUnit(InformationUnit.Terabyte);
+ AssertEx.EqualTolerance(TerabytesInOneBit, (double)terabyteQuantity.Value, TerabytesTolerance);
+ Assert.Equal(InformationUnit.Terabyte, terabyteQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/IrradianceTestsBase.g.cs
index 5d0696fb73..281103a264 100644
--- a/UnitsNet.Tests/GeneratedCode/IrradianceTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/IrradianceTestsBase.g.cs
@@ -83,6 +83,20 @@ public void As()
AssertEx.EqualTolerance(WattsPerSquareMeterInOneWattPerSquareMeter, wattpersquaremeter.As(IrradianceUnit.WattPerSquareMeter), WattsPerSquareMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1);
+
+ var kilowattpersquaremeterQuantity = wattpersquaremeter.ToUnit(IrradianceUnit.KilowattPerSquareMeter);
+ AssertEx.EqualTolerance(KilowattsPerSquareMeterInOneWattPerSquareMeter, (double)kilowattpersquaremeterQuantity.Value, KilowattsPerSquareMeterTolerance);
+ Assert.Equal(IrradianceUnit.KilowattPerSquareMeter, kilowattpersquaremeterQuantity.Unit);
+
+ var wattpersquaremeterQuantity = wattpersquaremeter.ToUnit(IrradianceUnit.WattPerSquareMeter);
+ AssertEx.EqualTolerance(WattsPerSquareMeterInOneWattPerSquareMeter, (double)wattpersquaremeterQuantity.Value, WattsPerSquareMeterTolerance);
+ Assert.Equal(IrradianceUnit.WattPerSquareMeter, wattpersquaremeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/IrradiationTestsBase.g.cs
index 370825130c..ec1fda132e 100644
--- a/UnitsNet.Tests/GeneratedCode/IrradiationTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/IrradiationTestsBase.g.cs
@@ -88,6 +88,24 @@ public void As()
AssertEx.EqualTolerance(WattHoursPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.WattHourPerSquareMeter), WattHoursPerSquareMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1);
+
+ var joulepersquaremeterQuantity = joulepersquaremeter.ToUnit(IrradiationUnit.JoulePerSquareMeter);
+ AssertEx.EqualTolerance(JoulesPerSquareMeterInOneJoulePerSquareMeter, (double)joulepersquaremeterQuantity.Value, JoulesPerSquareMeterTolerance);
+ Assert.Equal(IrradiationUnit.JoulePerSquareMeter, joulepersquaremeterQuantity.Unit);
+
+ var kilowatthourpersquaremeterQuantity = joulepersquaremeter.ToUnit(IrradiationUnit.KilowattHourPerSquareMeter);
+ AssertEx.EqualTolerance(KilowattHoursPerSquareMeterInOneJoulePerSquareMeter, (double)kilowatthourpersquaremeterQuantity.Value, KilowattHoursPerSquareMeterTolerance);
+ Assert.Equal(IrradiationUnit.KilowattHourPerSquareMeter, kilowatthourpersquaremeterQuantity.Unit);
+
+ var watthourpersquaremeterQuantity = joulepersquaremeter.ToUnit(IrradiationUnit.WattHourPerSquareMeter);
+ AssertEx.EqualTolerance(WattHoursPerSquareMeterInOneJoulePerSquareMeter, (double)watthourpersquaremeterQuantity.Value, WattHoursPerSquareMeterTolerance);
+ Assert.Equal(IrradiationUnit.WattHourPerSquareMeter, watthourpersquaremeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/KinematicViscosityTestsBase.g.cs
index 3a5ea0d0be..7dbf465a2e 100644
--- a/UnitsNet.Tests/GeneratedCode/KinematicViscosityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/KinematicViscosityTestsBase.g.cs
@@ -113,6 +113,44 @@ public void As()
AssertEx.EqualTolerance(StokesInOneSquareMeterPerSecond, squaremeterpersecond.As(KinematicViscosityUnit.Stokes), StokesTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1);
+
+ var centistokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Centistokes);
+ AssertEx.EqualTolerance(CentistokesInOneSquareMeterPerSecond, (double)centistokesQuantity.Value, CentistokesTolerance);
+ Assert.Equal(KinematicViscosityUnit.Centistokes, centistokesQuantity.Unit);
+
+ var decistokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Decistokes);
+ AssertEx.EqualTolerance(DecistokesInOneSquareMeterPerSecond, (double)decistokesQuantity.Value, DecistokesTolerance);
+ Assert.Equal(KinematicViscosityUnit.Decistokes, decistokesQuantity.Unit);
+
+ var kilostokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Kilostokes);
+ AssertEx.EqualTolerance(KilostokesInOneSquareMeterPerSecond, (double)kilostokesQuantity.Value, KilostokesTolerance);
+ Assert.Equal(KinematicViscosityUnit.Kilostokes, kilostokesQuantity.Unit);
+
+ var microstokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Microstokes);
+ AssertEx.EqualTolerance(MicrostokesInOneSquareMeterPerSecond, (double)microstokesQuantity.Value, MicrostokesTolerance);
+ Assert.Equal(KinematicViscosityUnit.Microstokes, microstokesQuantity.Unit);
+
+ var millistokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Millistokes);
+ AssertEx.EqualTolerance(MillistokesInOneSquareMeterPerSecond, (double)millistokesQuantity.Value, MillistokesTolerance);
+ Assert.Equal(KinematicViscosityUnit.Millistokes, millistokesQuantity.Unit);
+
+ var nanostokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Nanostokes);
+ AssertEx.EqualTolerance(NanostokesInOneSquareMeterPerSecond, (double)nanostokesQuantity.Value, NanostokesTolerance);
+ Assert.Equal(KinematicViscosityUnit.Nanostokes, nanostokesQuantity.Unit);
+
+ var squaremeterpersecondQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.SquareMeterPerSecond);
+ AssertEx.EqualTolerance(SquareMetersPerSecondInOneSquareMeterPerSecond, (double)squaremeterpersecondQuantity.Value, SquareMetersPerSecondTolerance);
+ Assert.Equal(KinematicViscosityUnit.SquareMeterPerSecond, squaremeterpersecondQuantity.Unit);
+
+ var stokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Stokes);
+ AssertEx.EqualTolerance(StokesInOneSquareMeterPerSecond, (double)stokesQuantity.Value, StokesTolerance);
+ Assert.Equal(KinematicViscosityUnit.Stokes, stokesQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LapseRateTestsBase.g.cs
index c7d7ed5b1d..0732fe45f8 100644
--- a/UnitsNet.Tests/GeneratedCode/LapseRateTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/LapseRateTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(DegreesCelciusPerKilometerInOneDegreeCelsiusPerKilometer, degreecelsiusperkilometer.As(LapseRateUnit.DegreeCelsiusPerKilometer), DegreesCelciusPerKilometerTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1);
+
+ var degreecelsiusperkilometerQuantity = degreecelsiusperkilometer.ToUnit(LapseRateUnit.DegreeCelsiusPerKilometer);
+ AssertEx.EqualTolerance(DegreesCelciusPerKilometerInOneDegreeCelsiusPerKilometer, (double)degreecelsiusperkilometerQuantity.Value, DegreesCelciusPerKilometerTolerance);
+ Assert.Equal(LapseRateUnit.DegreeCelsiusPerKilometer, degreecelsiusperkilometerQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LengthTestsBase.g.cs
index b695efd6cc..5949af1417 100644
--- a/UnitsNet.Tests/GeneratedCode/LengthTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/LengthTestsBase.g.cs
@@ -183,6 +183,100 @@ public void As()
AssertEx.EqualTolerance(YardsInOneMeter, meter.As(LengthUnit.Yard), YardsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var meter = Length.FromMeters(1);
+
+ var centimeterQuantity = meter.ToUnit(LengthUnit.Centimeter);
+ AssertEx.EqualTolerance(CentimetersInOneMeter, (double)centimeterQuantity.Value, CentimetersTolerance);
+ Assert.Equal(LengthUnit.Centimeter, centimeterQuantity.Unit);
+
+ var decimeterQuantity = meter.ToUnit(LengthUnit.Decimeter);
+ AssertEx.EqualTolerance(DecimetersInOneMeter, (double)decimeterQuantity.Value, DecimetersTolerance);
+ Assert.Equal(LengthUnit.Decimeter, decimeterQuantity.Unit);
+
+ var dtppicaQuantity = meter.ToUnit(LengthUnit.DtpPica);
+ AssertEx.EqualTolerance(DtpPicasInOneMeter, (double)dtppicaQuantity.Value, DtpPicasTolerance);
+ Assert.Equal(LengthUnit.DtpPica, dtppicaQuantity.Unit);
+
+ var dtppointQuantity = meter.ToUnit(LengthUnit.DtpPoint);
+ AssertEx.EqualTolerance(DtpPointsInOneMeter, (double)dtppointQuantity.Value, DtpPointsTolerance);
+ Assert.Equal(LengthUnit.DtpPoint, dtppointQuantity.Unit);
+
+ var fathomQuantity = meter.ToUnit(LengthUnit.Fathom);
+ AssertEx.EqualTolerance(FathomsInOneMeter, (double)fathomQuantity.Value, FathomsTolerance);
+ Assert.Equal(LengthUnit.Fathom, fathomQuantity.Unit);
+
+ var footQuantity = meter.ToUnit(LengthUnit.Foot);
+ AssertEx.EqualTolerance(FeetInOneMeter, (double)footQuantity.Value, FeetTolerance);
+ Assert.Equal(LengthUnit.Foot, footQuantity.Unit);
+
+ var inchQuantity = meter.ToUnit(LengthUnit.Inch);
+ AssertEx.EqualTolerance(InchesInOneMeter, (double)inchQuantity.Value, InchesTolerance);
+ Assert.Equal(LengthUnit.Inch, inchQuantity.Unit);
+
+ var kilometerQuantity = meter.ToUnit(LengthUnit.Kilometer);
+ AssertEx.EqualTolerance(KilometersInOneMeter, (double)kilometerQuantity.Value, KilometersTolerance);
+ Assert.Equal(LengthUnit.Kilometer, kilometerQuantity.Unit);
+
+ var meterQuantity = meter.ToUnit(LengthUnit.Meter);
+ AssertEx.EqualTolerance(MetersInOneMeter, (double)meterQuantity.Value, MetersTolerance);
+ Assert.Equal(LengthUnit.Meter, meterQuantity.Unit);
+
+ var microinchQuantity = meter.ToUnit(LengthUnit.Microinch);
+ AssertEx.EqualTolerance(MicroinchesInOneMeter, (double)microinchQuantity.Value, MicroinchesTolerance);
+ Assert.Equal(LengthUnit.Microinch, microinchQuantity.Unit);
+
+ var micrometerQuantity = meter.ToUnit(LengthUnit.Micrometer);
+ AssertEx.EqualTolerance(MicrometersInOneMeter, (double)micrometerQuantity.Value, MicrometersTolerance);
+ Assert.Equal(LengthUnit.Micrometer, micrometerQuantity.Unit);
+
+ var milQuantity = meter.ToUnit(LengthUnit.Mil);
+ AssertEx.EqualTolerance(MilsInOneMeter, (double)milQuantity.Value, MilsTolerance);
+ Assert.Equal(LengthUnit.Mil, milQuantity.Unit);
+
+ var mileQuantity = meter.ToUnit(LengthUnit.Mile);
+ AssertEx.EqualTolerance(MilesInOneMeter, (double)mileQuantity.Value, MilesTolerance);
+ Assert.Equal(LengthUnit.Mile, mileQuantity.Unit);
+
+ var millimeterQuantity = meter.ToUnit(LengthUnit.Millimeter);
+ AssertEx.EqualTolerance(MillimetersInOneMeter, (double)millimeterQuantity.Value, MillimetersTolerance);
+ Assert.Equal(LengthUnit.Millimeter, millimeterQuantity.Unit);
+
+ var nanometerQuantity = meter.ToUnit(LengthUnit.Nanometer);
+ AssertEx.EqualTolerance(NanometersInOneMeter, (double)nanometerQuantity.Value, NanometersTolerance);
+ Assert.Equal(LengthUnit.Nanometer, nanometerQuantity.Unit);
+
+ var nauticalmileQuantity = meter.ToUnit(LengthUnit.NauticalMile);
+ AssertEx.EqualTolerance(NauticalMilesInOneMeter, (double)nauticalmileQuantity.Value, NauticalMilesTolerance);
+ Assert.Equal(LengthUnit.NauticalMile, nauticalmileQuantity.Unit);
+
+ var printerpicaQuantity = meter.ToUnit(LengthUnit.PrinterPica);
+ AssertEx.EqualTolerance(PrinterPicasInOneMeter, (double)printerpicaQuantity.Value, PrinterPicasTolerance);
+ Assert.Equal(LengthUnit.PrinterPica, printerpicaQuantity.Unit);
+
+ var printerpointQuantity = meter.ToUnit(LengthUnit.PrinterPoint);
+ AssertEx.EqualTolerance(PrinterPointsInOneMeter, (double)printerpointQuantity.Value, PrinterPointsTolerance);
+ Assert.Equal(LengthUnit.PrinterPoint, printerpointQuantity.Unit);
+
+ var shackleQuantity = meter.ToUnit(LengthUnit.Shackle);
+ AssertEx.EqualTolerance(ShacklesInOneMeter, (double)shackleQuantity.Value, ShacklesTolerance);
+ Assert.Equal(LengthUnit.Shackle, shackleQuantity.Unit);
+
+ var twipQuantity = meter.ToUnit(LengthUnit.Twip);
+ AssertEx.EqualTolerance(TwipsInOneMeter, (double)twipQuantity.Value, TwipsTolerance);
+ Assert.Equal(LengthUnit.Twip, twipQuantity.Unit);
+
+ var ussurveyfootQuantity = meter.ToUnit(LengthUnit.UsSurveyFoot);
+ AssertEx.EqualTolerance(UsSurveyFeetInOneMeter, (double)ussurveyfootQuantity.Value, UsSurveyFeetTolerance);
+ Assert.Equal(LengthUnit.UsSurveyFoot, ussurveyfootQuantity.Unit);
+
+ var yardQuantity = meter.ToUnit(LengthUnit.Yard);
+ AssertEx.EqualTolerance(YardsInOneMeter, (double)yardQuantity.Value, YardsTolerance);
+ Assert.Equal(LengthUnit.Yard, yardQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LevelTestsBase.g.cs
index b309e21047..7597d0e219 100644
--- a/UnitsNet.Tests/GeneratedCode/LevelTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/LevelTestsBase.g.cs
@@ -83,6 +83,20 @@ public void As()
AssertEx.EqualTolerance(NepersInOneDecibel, decibel.As(LevelUnit.Neper), NepersTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var decibel = Level.FromDecibels(1);
+
+ var decibelQuantity = decibel.ToUnit(LevelUnit.Decibel);
+ AssertEx.EqualTolerance(DecibelsInOneDecibel, (double)decibelQuantity.Value, DecibelsTolerance);
+ Assert.Equal(LevelUnit.Decibel, decibelQuantity.Unit);
+
+ var neperQuantity = decibel.ToUnit(LevelUnit.Neper);
+ AssertEx.EqualTolerance(NepersInOneDecibel, (double)neperQuantity.Value, NepersTolerance);
+ Assert.Equal(LevelUnit.Neper, neperQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LinearDensityTestsBase.g.cs
index f2b657d953..583ac6c777 100644
--- a/UnitsNet.Tests/GeneratedCode/LinearDensityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/LinearDensityTestsBase.g.cs
@@ -88,6 +88,24 @@ public void As()
AssertEx.EqualTolerance(PoundsPerFootInOneKilogramPerMeter, kilogrampermeter.As(LinearDensityUnit.PoundPerFoot), PoundsPerFootTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1);
+
+ var grampermeterQuantity = kilogrampermeter.ToUnit(LinearDensityUnit.GramPerMeter);
+ AssertEx.EqualTolerance(GramsPerMeterInOneKilogramPerMeter, (double)grampermeterQuantity.Value, GramsPerMeterTolerance);
+ Assert.Equal(LinearDensityUnit.GramPerMeter, grampermeterQuantity.Unit);
+
+ var kilogrampermeterQuantity = kilogrampermeter.ToUnit(LinearDensityUnit.KilogramPerMeter);
+ AssertEx.EqualTolerance(KilogramsPerMeterInOneKilogramPerMeter, (double)kilogrampermeterQuantity.Value, KilogramsPerMeterTolerance);
+ Assert.Equal(LinearDensityUnit.KilogramPerMeter, kilogrampermeterQuantity.Unit);
+
+ var poundperfootQuantity = kilogrampermeter.ToUnit(LinearDensityUnit.PoundPerFoot);
+ AssertEx.EqualTolerance(PoundsPerFootInOneKilogramPerMeter, (double)poundperfootQuantity.Value, PoundsPerFootTolerance);
+ Assert.Equal(LinearDensityUnit.PoundPerFoot, poundperfootQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LuminousFluxTestsBase.g.cs
index b11fb6eda6..215668412c 100644
--- a/UnitsNet.Tests/GeneratedCode/LuminousFluxTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/LuminousFluxTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(LumensInOneLumen, lumen.As(LuminousFluxUnit.Lumen), LumensTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var lumen = LuminousFlux.FromLumens(1);
+
+ var lumenQuantity = lumen.ToUnit(LuminousFluxUnit.Lumen);
+ AssertEx.EqualTolerance(LumensInOneLumen, (double)lumenQuantity.Value, LumensTolerance);
+ Assert.Equal(LuminousFluxUnit.Lumen, lumenQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LuminousIntensityTestsBase.g.cs
index f3770a9a72..999ad2424d 100644
--- a/UnitsNet.Tests/GeneratedCode/LuminousIntensityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/LuminousIntensityTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(CandelaInOneCandela, candela.As(LuminousIntensityUnit.Candela), CandelaTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var candela = LuminousIntensity.FromCandela(1);
+
+ var candelaQuantity = candela.ToUnit(LuminousIntensityUnit.Candela);
+ AssertEx.EqualTolerance(CandelaInOneCandela, (double)candelaQuantity.Value, CandelaTolerance);
+ Assert.Equal(LuminousIntensityUnit.Candela, candelaQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MagneticFieldTestsBase.g.cs
index 6f09609d4b..5dec404684 100644
--- a/UnitsNet.Tests/GeneratedCode/MagneticFieldTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/MagneticFieldTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(TeslasInOneTesla, tesla.As(MagneticFieldUnit.Tesla), TeslasTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var tesla = MagneticField.FromTeslas(1);
+
+ var teslaQuantity = tesla.ToUnit(MagneticFieldUnit.Tesla);
+ AssertEx.EqualTolerance(TeslasInOneTesla, (double)teslaQuantity.Value, TeslasTolerance);
+ Assert.Equal(MagneticFieldUnit.Tesla, teslaQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MagneticFluxTestsBase.g.cs
index 97a6ed0f42..2581511a9a 100644
--- a/UnitsNet.Tests/GeneratedCode/MagneticFluxTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/MagneticFluxTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(WebersInOneWeber, weber.As(MagneticFluxUnit.Weber), WebersTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var weber = MagneticFlux.FromWebers(1);
+
+ var weberQuantity = weber.ToUnit(MagneticFluxUnit.Weber);
+ AssertEx.EqualTolerance(WebersInOneWeber, (double)weberQuantity.Value, WebersTolerance);
+ Assert.Equal(MagneticFluxUnit.Weber, weberQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MagnetizationTestsBase.g.cs
index 631d9d8085..b51a284c06 100644
--- a/UnitsNet.Tests/GeneratedCode/MagnetizationTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/MagnetizationTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(AmperesPerMeterInOneAmperePerMeter, amperepermeter.As(MagnetizationUnit.AmperePerMeter), AmperesPerMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var amperepermeter = Magnetization.FromAmperesPerMeter(1);
+
+ var amperepermeterQuantity = amperepermeter.ToUnit(MagnetizationUnit.AmperePerMeter);
+ AssertEx.EqualTolerance(AmperesPerMeterInOneAmperePerMeter, (double)amperepermeterQuantity.Value, AmperesPerMeterTolerance);
+ Assert.Equal(MagnetizationUnit.AmperePerMeter, amperepermeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MassFlowTestsBase.g.cs
index 11e7915ee2..059579ad5e 100644
--- a/UnitsNet.Tests/GeneratedCode/MassFlowTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/MassFlowTestsBase.g.cs
@@ -148,6 +148,72 @@ public void As()
AssertEx.EqualTolerance(TonnesPerHourInOneGramPerSecond, grampersecond.As(MassFlowUnit.TonnePerHour), TonnesPerHourTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var grampersecond = MassFlow.FromGramsPerSecond(1);
+
+ var centigrampersecondQuantity = grampersecond.ToUnit(MassFlowUnit.CentigramPerSecond);
+ AssertEx.EqualTolerance(CentigramsPerSecondInOneGramPerSecond, (double)centigrampersecondQuantity.Value, CentigramsPerSecondTolerance);
+ Assert.Equal(MassFlowUnit.CentigramPerSecond, centigrampersecondQuantity.Unit);
+
+ var decagrampersecondQuantity = grampersecond.ToUnit(MassFlowUnit.DecagramPerSecond);
+ AssertEx.EqualTolerance(DecagramsPerSecondInOneGramPerSecond, (double)decagrampersecondQuantity.Value, DecagramsPerSecondTolerance);
+ Assert.Equal(MassFlowUnit.DecagramPerSecond, decagrampersecondQuantity.Unit);
+
+ var decigrampersecondQuantity = grampersecond.ToUnit(MassFlowUnit.DecigramPerSecond);
+ AssertEx.EqualTolerance(DecigramsPerSecondInOneGramPerSecond, (double)decigrampersecondQuantity.Value, DecigramsPerSecondTolerance);
+ Assert.Equal(MassFlowUnit.DecigramPerSecond, decigrampersecondQuantity.Unit);
+
+ var grampersecondQuantity = grampersecond.ToUnit(MassFlowUnit.GramPerSecond);
+ AssertEx.EqualTolerance(GramsPerSecondInOneGramPerSecond, (double)grampersecondQuantity.Value, GramsPerSecondTolerance);
+ Assert.Equal(MassFlowUnit.GramPerSecond, grampersecondQuantity.Unit);
+
+ var hectogrampersecondQuantity = grampersecond.ToUnit(MassFlowUnit.HectogramPerSecond);
+ AssertEx.EqualTolerance(HectogramsPerSecondInOneGramPerSecond, (double)hectogrampersecondQuantity.Value, HectogramsPerSecondTolerance);
+ Assert.Equal(MassFlowUnit.HectogramPerSecond, hectogrampersecondQuantity.Unit);
+
+ var kilogramperhourQuantity = grampersecond.ToUnit(MassFlowUnit.KilogramPerHour);
+ AssertEx.EqualTolerance(KilogramsPerHourInOneGramPerSecond, (double)kilogramperhourQuantity.Value, KilogramsPerHourTolerance);
+ Assert.Equal(MassFlowUnit.KilogramPerHour, kilogramperhourQuantity.Unit);
+
+ var kilogrampersecondQuantity = grampersecond.ToUnit(MassFlowUnit.KilogramPerSecond);
+ AssertEx.EqualTolerance(KilogramsPerSecondInOneGramPerSecond, (double)kilogrampersecondQuantity.Value, KilogramsPerSecondTolerance);
+ Assert.Equal(MassFlowUnit.KilogramPerSecond, kilogrampersecondQuantity.Unit);
+
+ var megapoundperhourQuantity = grampersecond.ToUnit(MassFlowUnit.MegapoundPerHour);
+ AssertEx.EqualTolerance(MegapoundsPerHourInOneGramPerSecond, (double)megapoundperhourQuantity.Value, MegapoundsPerHourTolerance);
+ Assert.Equal(MassFlowUnit.MegapoundPerHour, megapoundperhourQuantity.Unit);
+
+ var microgrampersecondQuantity = grampersecond.ToUnit(MassFlowUnit.MicrogramPerSecond);
+ AssertEx.EqualTolerance(MicrogramsPerSecondInOneGramPerSecond, (double)microgrampersecondQuantity.Value, MicrogramsPerSecondTolerance);
+ Assert.Equal(MassFlowUnit.MicrogramPerSecond, microgrampersecondQuantity.Unit);
+
+ var milligrampersecondQuantity = grampersecond.ToUnit(MassFlowUnit.MilligramPerSecond);
+ AssertEx.EqualTolerance(MilligramsPerSecondInOneGramPerSecond, (double)milligrampersecondQuantity.Value, MilligramsPerSecondTolerance);
+ Assert.Equal(MassFlowUnit.MilligramPerSecond, milligrampersecondQuantity.Unit);
+
+ var nanogrampersecondQuantity = grampersecond.ToUnit(MassFlowUnit.NanogramPerSecond);
+ AssertEx.EqualTolerance(NanogramsPerSecondInOneGramPerSecond, (double)nanogrampersecondQuantity.Value, NanogramsPerSecondTolerance);
+ Assert.Equal(MassFlowUnit.NanogramPerSecond, nanogrampersecondQuantity.Unit);
+
+ var poundperhourQuantity = grampersecond.ToUnit(MassFlowUnit.PoundPerHour);
+ AssertEx.EqualTolerance(PoundsPerHourInOneGramPerSecond, (double)poundperhourQuantity.Value, PoundsPerHourTolerance);
+ Assert.Equal(MassFlowUnit.PoundPerHour, poundperhourQuantity.Unit);
+
+ var shorttonperhourQuantity = grampersecond.ToUnit(MassFlowUnit.ShortTonPerHour);
+ AssertEx.EqualTolerance(ShortTonsPerHourInOneGramPerSecond, (double)shorttonperhourQuantity.Value, ShortTonsPerHourTolerance);
+ Assert.Equal(MassFlowUnit.ShortTonPerHour, shorttonperhourQuantity.Unit);
+
+ var tonneperdayQuantity = grampersecond.ToUnit(MassFlowUnit.TonnePerDay);
+ AssertEx.EqualTolerance(TonnesPerDayInOneGramPerSecond, (double)tonneperdayQuantity.Value, TonnesPerDayTolerance);
+ Assert.Equal(MassFlowUnit.TonnePerDay, tonneperdayQuantity.Unit);
+
+ var tonneperhourQuantity = grampersecond.ToUnit(MassFlowUnit.TonnePerHour);
+ AssertEx.EqualTolerance(TonnesPerHourInOneGramPerSecond, (double)tonneperhourQuantity.Value, TonnesPerHourTolerance);
+ Assert.Equal(MassFlowUnit.TonnePerHour, tonneperhourQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MassFluxTestsBase.g.cs
index ad7541c541..478b2ce289 100644
--- a/UnitsNet.Tests/GeneratedCode/MassFluxTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/MassFluxTestsBase.g.cs
@@ -83,6 +83,20 @@ public void As()
AssertEx.EqualTolerance(KilogramsPerSecondPerSquareMeterInOneKilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeter.As(MassFluxUnit.KilogramPerSecondPerSquareMeter), KilogramsPerSecondPerSquareMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1);
+
+ var grampersecondpersquaremeterQuantity = kilogrampersecondpersquaremeter.ToUnit(MassFluxUnit.GramPerSecondPerSquareMeter);
+ AssertEx.EqualTolerance(GramsPerSecondPerSquareMeterInOneKilogramPerSecondPerSquareMeter, (double)grampersecondpersquaremeterQuantity.Value, GramsPerSecondPerSquareMeterTolerance);
+ Assert.Equal(MassFluxUnit.GramPerSecondPerSquareMeter, grampersecondpersquaremeterQuantity.Unit);
+
+ var kilogrampersecondpersquaremeterQuantity = kilogrampersecondpersquaremeter.ToUnit(MassFluxUnit.KilogramPerSecondPerSquareMeter);
+ AssertEx.EqualTolerance(KilogramsPerSecondPerSquareMeterInOneKilogramPerSecondPerSquareMeter, (double)kilogrampersecondpersquaremeterQuantity.Value, KilogramsPerSecondPerSquareMeterTolerance);
+ Assert.Equal(MassFluxUnit.KilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MassMomentOfInertiaTestsBase.g.cs
index 4014074f71..0e5d3c566f 100644
--- a/UnitsNet.Tests/GeneratedCode/MassMomentOfInertiaTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/MassMomentOfInertiaTestsBase.g.cs
@@ -203,6 +203,116 @@ public void As()
AssertEx.EqualTolerance(TonneSquareMilimetersInOneKilogramSquareMeter, kilogramsquaremeter.As(MassMomentOfInertiaUnit.TonneSquareMilimeter), TonneSquareMilimetersTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1);
+
+ var gramsquarecentimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.GramSquareCentimeter);
+ AssertEx.EqualTolerance(GramSquareCentimetersInOneKilogramSquareMeter, (double)gramsquarecentimeterQuantity.Value, GramSquareCentimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.GramSquareCentimeter, gramsquarecentimeterQuantity.Unit);
+
+ var gramsquaredecimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.GramSquareDecimeter);
+ AssertEx.EqualTolerance(GramSquareDecimetersInOneKilogramSquareMeter, (double)gramsquaredecimeterQuantity.Value, GramSquareDecimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.GramSquareDecimeter, gramsquaredecimeterQuantity.Unit);
+
+ var gramsquaremeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.GramSquareMeter);
+ AssertEx.EqualTolerance(GramSquareMetersInOneKilogramSquareMeter, (double)gramsquaremeterQuantity.Value, GramSquareMetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.GramSquareMeter, gramsquaremeterQuantity.Unit);
+
+ var gramsquaremillimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.GramSquareMillimeter);
+ AssertEx.EqualTolerance(GramSquareMillimetersInOneKilogramSquareMeter, (double)gramsquaremillimeterQuantity.Value, GramSquareMillimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.GramSquareMillimeter, gramsquaremillimeterQuantity.Unit);
+
+ var kilogramsquarecentimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.KilogramSquareCentimeter);
+ AssertEx.EqualTolerance(KilogramSquareCentimetersInOneKilogramSquareMeter, (double)kilogramsquarecentimeterQuantity.Value, KilogramSquareCentimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.KilogramSquareCentimeter, kilogramsquarecentimeterQuantity.Unit);
+
+ var kilogramsquaredecimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.KilogramSquareDecimeter);
+ AssertEx.EqualTolerance(KilogramSquareDecimetersInOneKilogramSquareMeter, (double)kilogramsquaredecimeterQuantity.Value, KilogramSquareDecimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.KilogramSquareDecimeter, kilogramsquaredecimeterQuantity.Unit);
+
+ var kilogramsquaremeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.KilogramSquareMeter);
+ AssertEx.EqualTolerance(KilogramSquareMetersInOneKilogramSquareMeter, (double)kilogramsquaremeterQuantity.Value, KilogramSquareMetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.KilogramSquareMeter, kilogramsquaremeterQuantity.Unit);
+
+ var kilogramsquaremillimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.KilogramSquareMillimeter);
+ AssertEx.EqualTolerance(KilogramSquareMillimetersInOneKilogramSquareMeter, (double)kilogramsquaremillimeterQuantity.Value, KilogramSquareMillimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.KilogramSquareMillimeter, kilogramsquaremillimeterQuantity.Unit);
+
+ var kilotonnesquarecentimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareCentimeter);
+ AssertEx.EqualTolerance(KilotonneSquareCentimetersInOneKilogramSquareMeter, (double)kilotonnesquarecentimeterQuantity.Value, KilotonneSquareCentimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.KilotonneSquareCentimeter, kilotonnesquarecentimeterQuantity.Unit);
+
+ var kilotonnesquaredecimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareDecimeter);
+ AssertEx.EqualTolerance(KilotonneSquareDecimetersInOneKilogramSquareMeter, (double)kilotonnesquaredecimeterQuantity.Value, KilotonneSquareDecimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.KilotonneSquareDecimeter, kilotonnesquaredecimeterQuantity.Unit);
+
+ var kilotonnesquaremeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareMeter);
+ AssertEx.EqualTolerance(KilotonneSquareMetersInOneKilogramSquareMeter, (double)kilotonnesquaremeterQuantity.Value, KilotonneSquareMetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.KilotonneSquareMeter, kilotonnesquaremeterQuantity.Unit);
+
+ var kilotonnesquaremilimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareMilimeter);
+ AssertEx.EqualTolerance(KilotonneSquareMilimetersInOneKilogramSquareMeter, (double)kilotonnesquaremilimeterQuantity.Value, KilotonneSquareMilimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.KilotonneSquareMilimeter, kilotonnesquaremilimeterQuantity.Unit);
+
+ var megatonnesquarecentimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareCentimeter);
+ AssertEx.EqualTolerance(MegatonneSquareCentimetersInOneKilogramSquareMeter, (double)megatonnesquarecentimeterQuantity.Value, MegatonneSquareCentimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.MegatonneSquareCentimeter, megatonnesquarecentimeterQuantity.Unit);
+
+ var megatonnesquaredecimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareDecimeter);
+ AssertEx.EqualTolerance(MegatonneSquareDecimetersInOneKilogramSquareMeter, (double)megatonnesquaredecimeterQuantity.Value, MegatonneSquareDecimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.MegatonneSquareDecimeter, megatonnesquaredecimeterQuantity.Unit);
+
+ var megatonnesquaremeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareMeter);
+ AssertEx.EqualTolerance(MegatonneSquareMetersInOneKilogramSquareMeter, (double)megatonnesquaremeterQuantity.Value, MegatonneSquareMetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.MegatonneSquareMeter, megatonnesquaremeterQuantity.Unit);
+
+ var megatonnesquaremilimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareMilimeter);
+ AssertEx.EqualTolerance(MegatonneSquareMilimetersInOneKilogramSquareMeter, (double)megatonnesquaremilimeterQuantity.Value, MegatonneSquareMilimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.MegatonneSquareMilimeter, megatonnesquaremilimeterQuantity.Unit);
+
+ var milligramsquarecentimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.MilligramSquareCentimeter);
+ AssertEx.EqualTolerance(MilligramSquareCentimetersInOneKilogramSquareMeter, (double)milligramsquarecentimeterQuantity.Value, MilligramSquareCentimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.MilligramSquareCentimeter, milligramsquarecentimeterQuantity.Unit);
+
+ var milligramsquaredecimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.MilligramSquareDecimeter);
+ AssertEx.EqualTolerance(MilligramSquareDecimetersInOneKilogramSquareMeter, (double)milligramsquaredecimeterQuantity.Value, MilligramSquareDecimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.MilligramSquareDecimeter, milligramsquaredecimeterQuantity.Unit);
+
+ var milligramsquaremeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.MilligramSquareMeter);
+ AssertEx.EqualTolerance(MilligramSquareMetersInOneKilogramSquareMeter, (double)milligramsquaremeterQuantity.Value, MilligramSquareMetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.MilligramSquareMeter, milligramsquaremeterQuantity.Unit);
+
+ var milligramsquaremillimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.MilligramSquareMillimeter);
+ AssertEx.EqualTolerance(MilligramSquareMillimetersInOneKilogramSquareMeter, (double)milligramsquaremillimeterQuantity.Value, MilligramSquareMillimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.MilligramSquareMillimeter, milligramsquaremillimeterQuantity.Unit);
+
+ var poundsquarefootQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.PoundSquareFoot);
+ AssertEx.EqualTolerance(PoundSquareFeetInOneKilogramSquareMeter, (double)poundsquarefootQuantity.Value, PoundSquareFeetTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.PoundSquareFoot, poundsquarefootQuantity.Unit);
+
+ var poundsquareinchQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.PoundSquareInch);
+ AssertEx.EqualTolerance(PoundSquareInchesInOneKilogramSquareMeter, (double)poundsquareinchQuantity.Value, PoundSquareInchesTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.PoundSquareInch, poundsquareinchQuantity.Unit);
+
+ var tonnesquarecentimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.TonneSquareCentimeter);
+ AssertEx.EqualTolerance(TonneSquareCentimetersInOneKilogramSquareMeter, (double)tonnesquarecentimeterQuantity.Value, TonneSquareCentimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.TonneSquareCentimeter, tonnesquarecentimeterQuantity.Unit);
+
+ var tonnesquaredecimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.TonneSquareDecimeter);
+ AssertEx.EqualTolerance(TonneSquareDecimetersInOneKilogramSquareMeter, (double)tonnesquaredecimeterQuantity.Value, TonneSquareDecimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.TonneSquareDecimeter, tonnesquaredecimeterQuantity.Unit);
+
+ var tonnesquaremeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.TonneSquareMeter);
+ AssertEx.EqualTolerance(TonneSquareMetersInOneKilogramSquareMeter, (double)tonnesquaremeterQuantity.Value, TonneSquareMetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.TonneSquareMeter, tonnesquaremeterQuantity.Unit);
+
+ var tonnesquaremilimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.TonneSquareMilimeter);
+ AssertEx.EqualTolerance(TonneSquareMilimetersInOneKilogramSquareMeter, (double)tonnesquaremilimeterQuantity.Value, TonneSquareMilimetersTolerance);
+ Assert.Equal(MassMomentOfInertiaUnit.TonneSquareMilimeter, tonnesquaremilimeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MassTestsBase.g.cs
index a30ab59065..af84e2275c 100644
--- a/UnitsNet.Tests/GeneratedCode/MassTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/MassTestsBase.g.cs
@@ -178,6 +178,96 @@ public void As()
AssertEx.EqualTolerance(TonnesInOneKilogram, kilogram.As(MassUnit.Tonne), TonnesTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var kilogram = Mass.FromKilograms(1);
+
+ var centigramQuantity = kilogram.ToUnit(MassUnit.Centigram);
+ AssertEx.EqualTolerance(CentigramsInOneKilogram, (double)centigramQuantity.Value, CentigramsTolerance);
+ Assert.Equal(MassUnit.Centigram, centigramQuantity.Unit);
+
+ var decagramQuantity = kilogram.ToUnit(MassUnit.Decagram);
+ AssertEx.EqualTolerance(DecagramsInOneKilogram, (double)decagramQuantity.Value, DecagramsTolerance);
+ Assert.Equal(MassUnit.Decagram, decagramQuantity.Unit);
+
+ var decigramQuantity = kilogram.ToUnit(MassUnit.Decigram);
+ AssertEx.EqualTolerance(DecigramsInOneKilogram, (double)decigramQuantity.Value, DecigramsTolerance);
+ Assert.Equal(MassUnit.Decigram, decigramQuantity.Unit);
+
+ var gramQuantity = kilogram.ToUnit(MassUnit.Gram);
+ AssertEx.EqualTolerance(GramsInOneKilogram, (double)gramQuantity.Value, GramsTolerance);
+ Assert.Equal(MassUnit.Gram, gramQuantity.Unit);
+
+ var hectogramQuantity = kilogram.ToUnit(MassUnit.Hectogram);
+ AssertEx.EqualTolerance(HectogramsInOneKilogram, (double)hectogramQuantity.Value, HectogramsTolerance);
+ Assert.Equal(MassUnit.Hectogram, hectogramQuantity.Unit);
+
+ var kilogramQuantity = kilogram.ToUnit(MassUnit.Kilogram);
+ AssertEx.EqualTolerance(KilogramsInOneKilogram, (double)kilogramQuantity.Value, KilogramsTolerance);
+ Assert.Equal(MassUnit.Kilogram, kilogramQuantity.Unit);
+
+ var kilopoundQuantity = kilogram.ToUnit(MassUnit.Kilopound);
+ AssertEx.EqualTolerance(KilopoundsInOneKilogram, (double)kilopoundQuantity.Value, KilopoundsTolerance);
+ Assert.Equal(MassUnit.Kilopound, kilopoundQuantity.Unit);
+
+ var kilotonneQuantity = kilogram.ToUnit(MassUnit.Kilotonne);
+ AssertEx.EqualTolerance(KilotonnesInOneKilogram, (double)kilotonneQuantity.Value, KilotonnesTolerance);
+ Assert.Equal(MassUnit.Kilotonne, kilotonneQuantity.Unit);
+
+ var longhundredweightQuantity = kilogram.ToUnit(MassUnit.LongHundredweight);
+ AssertEx.EqualTolerance(LongHundredweightInOneKilogram, (double)longhundredweightQuantity.Value, LongHundredweightTolerance);
+ Assert.Equal(MassUnit.LongHundredweight, longhundredweightQuantity.Unit);
+
+ var longtonQuantity = kilogram.ToUnit(MassUnit.LongTon);
+ AssertEx.EqualTolerance(LongTonsInOneKilogram, (double)longtonQuantity.Value, LongTonsTolerance);
+ Assert.Equal(MassUnit.LongTon, longtonQuantity.Unit);
+
+ var megapoundQuantity = kilogram.ToUnit(MassUnit.Megapound);
+ AssertEx.EqualTolerance(MegapoundsInOneKilogram, (double)megapoundQuantity.Value, MegapoundsTolerance);
+ Assert.Equal(MassUnit.Megapound, megapoundQuantity.Unit);
+
+ var megatonneQuantity = kilogram.ToUnit(MassUnit.Megatonne);
+ AssertEx.EqualTolerance(MegatonnesInOneKilogram, (double)megatonneQuantity.Value, MegatonnesTolerance);
+ Assert.Equal(MassUnit.Megatonne, megatonneQuantity.Unit);
+
+ var microgramQuantity = kilogram.ToUnit(MassUnit.Microgram);
+ AssertEx.EqualTolerance(MicrogramsInOneKilogram, (double)microgramQuantity.Value, MicrogramsTolerance);
+ Assert.Equal(MassUnit.Microgram, microgramQuantity.Unit);
+
+ var milligramQuantity = kilogram.ToUnit(MassUnit.Milligram);
+ AssertEx.EqualTolerance(MilligramsInOneKilogram, (double)milligramQuantity.Value, MilligramsTolerance);
+ Assert.Equal(MassUnit.Milligram, milligramQuantity.Unit);
+
+ var nanogramQuantity = kilogram.ToUnit(MassUnit.Nanogram);
+ AssertEx.EqualTolerance(NanogramsInOneKilogram, (double)nanogramQuantity.Value, NanogramsTolerance);
+ Assert.Equal(MassUnit.Nanogram, nanogramQuantity.Unit);
+
+ var ounceQuantity = kilogram.ToUnit(MassUnit.Ounce);
+ AssertEx.EqualTolerance(OuncesInOneKilogram, (double)ounceQuantity.Value, OuncesTolerance);
+ Assert.Equal(MassUnit.Ounce, ounceQuantity.Unit);
+
+ var poundQuantity = kilogram.ToUnit(MassUnit.Pound);
+ AssertEx.EqualTolerance(PoundsInOneKilogram, (double)poundQuantity.Value, PoundsTolerance);
+ Assert.Equal(MassUnit.Pound, poundQuantity.Unit);
+
+ var shorthundredweightQuantity = kilogram.ToUnit(MassUnit.ShortHundredweight);
+ AssertEx.EqualTolerance(ShortHundredweightInOneKilogram, (double)shorthundredweightQuantity.Value, ShortHundredweightTolerance);
+ Assert.Equal(MassUnit.ShortHundredweight, shorthundredweightQuantity.Unit);
+
+ var shorttonQuantity = kilogram.ToUnit(MassUnit.ShortTon);
+ AssertEx.EqualTolerance(ShortTonsInOneKilogram, (double)shorttonQuantity.Value, ShortTonsTolerance);
+ Assert.Equal(MassUnit.ShortTon, shorttonQuantity.Unit);
+
+ var stoneQuantity = kilogram.ToUnit(MassUnit.Stone);
+ AssertEx.EqualTolerance(StoneInOneKilogram, (double)stoneQuantity.Value, StoneTolerance);
+ Assert.Equal(MassUnit.Stone, stoneQuantity.Unit);
+
+ var tonneQuantity = kilogram.ToUnit(MassUnit.Tonne);
+ AssertEx.EqualTolerance(TonnesInOneKilogram, (double)tonneQuantity.Value, TonnesTolerance);
+ Assert.Equal(MassUnit.Tonne, tonneQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MolarEnergyTestsBase.g.cs
index abe9759991..55ce91fb52 100644
--- a/UnitsNet.Tests/GeneratedCode/MolarEnergyTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/MolarEnergyTestsBase.g.cs
@@ -88,6 +88,24 @@ public void As()
AssertEx.EqualTolerance(MegajoulesPerMoleInOneJoulePerMole, joulepermole.As(MolarEnergyUnit.MegajoulePerMole), MegajoulesPerMoleTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var joulepermole = MolarEnergy.FromJoulesPerMole(1);
+
+ var joulepermoleQuantity = joulepermole.ToUnit(MolarEnergyUnit.JoulePerMole);
+ AssertEx.EqualTolerance(JoulesPerMoleInOneJoulePerMole, (double)joulepermoleQuantity.Value, JoulesPerMoleTolerance);
+ Assert.Equal(MolarEnergyUnit.JoulePerMole, joulepermoleQuantity.Unit);
+
+ var kilojoulepermoleQuantity = joulepermole.ToUnit(MolarEnergyUnit.KilojoulePerMole);
+ AssertEx.EqualTolerance(KilojoulesPerMoleInOneJoulePerMole, (double)kilojoulepermoleQuantity.Value, KilojoulesPerMoleTolerance);
+ Assert.Equal(MolarEnergyUnit.KilojoulePerMole, kilojoulepermoleQuantity.Unit);
+
+ var megajoulepermoleQuantity = joulepermole.ToUnit(MolarEnergyUnit.MegajoulePerMole);
+ AssertEx.EqualTolerance(MegajoulesPerMoleInOneJoulePerMole, (double)megajoulepermoleQuantity.Value, MegajoulesPerMoleTolerance);
+ Assert.Equal(MolarEnergyUnit.MegajoulePerMole, megajoulepermoleQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MolarEntropyTestsBase.g.cs
index 951975515f..0bce160791 100644
--- a/UnitsNet.Tests/GeneratedCode/MolarEntropyTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/MolarEntropyTestsBase.g.cs
@@ -88,6 +88,24 @@ public void As()
AssertEx.EqualTolerance(MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.MegajoulePerMoleKelvin), MegajoulesPerMoleKelvinTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1);
+
+ var joulepermolekelvinQuantity = joulepermolekelvin.ToUnit(MolarEntropyUnit.JoulePerMoleKelvin);
+ AssertEx.EqualTolerance(JoulesPerMoleKelvinInOneJoulePerMoleKelvin, (double)joulepermolekelvinQuantity.Value, JoulesPerMoleKelvinTolerance);
+ Assert.Equal(MolarEntropyUnit.JoulePerMoleKelvin, joulepermolekelvinQuantity.Unit);
+
+ var kilojoulepermolekelvinQuantity = joulepermolekelvin.ToUnit(MolarEntropyUnit.KilojoulePerMoleKelvin);
+ AssertEx.EqualTolerance(KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin, (double)kilojoulepermolekelvinQuantity.Value, KilojoulesPerMoleKelvinTolerance);
+ Assert.Equal(MolarEntropyUnit.KilojoulePerMoleKelvin, kilojoulepermolekelvinQuantity.Unit);
+
+ var megajoulepermolekelvinQuantity = joulepermolekelvin.ToUnit(MolarEntropyUnit.MegajoulePerMoleKelvin);
+ AssertEx.EqualTolerance(MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin, (double)megajoulepermolekelvinQuantity.Value, MegajoulesPerMoleKelvinTolerance);
+ Assert.Equal(MolarEntropyUnit.MegajoulePerMoleKelvin, megajoulepermolekelvinQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MolarMassTestsBase.g.cs
index d188ad6ba4..ba4f6728a8 100644
--- a/UnitsNet.Tests/GeneratedCode/MolarMassTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/MolarMassTestsBase.g.cs
@@ -133,6 +133,60 @@ public void As()
AssertEx.EqualTolerance(PoundsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.PoundPerMole), PoundsPerMoleTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var kilogrampermole = MolarMass.FromKilogramsPerMole(1);
+
+ var centigrampermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.CentigramPerMole);
+ AssertEx.EqualTolerance(CentigramsPerMoleInOneKilogramPerMole, (double)centigrampermoleQuantity.Value, CentigramsPerMoleTolerance);
+ Assert.Equal(MolarMassUnit.CentigramPerMole, centigrampermoleQuantity.Unit);
+
+ var decagrampermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.DecagramPerMole);
+ AssertEx.EqualTolerance(DecagramsPerMoleInOneKilogramPerMole, (double)decagrampermoleQuantity.Value, DecagramsPerMoleTolerance);
+ Assert.Equal(MolarMassUnit.DecagramPerMole, decagrampermoleQuantity.Unit);
+
+ var decigrampermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.DecigramPerMole);
+ AssertEx.EqualTolerance(DecigramsPerMoleInOneKilogramPerMole, (double)decigrampermoleQuantity.Value, DecigramsPerMoleTolerance);
+ Assert.Equal(MolarMassUnit.DecigramPerMole, decigrampermoleQuantity.Unit);
+
+ var grampermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.GramPerMole);
+ AssertEx.EqualTolerance(GramsPerMoleInOneKilogramPerMole, (double)grampermoleQuantity.Value, GramsPerMoleTolerance);
+ Assert.Equal(MolarMassUnit.GramPerMole, grampermoleQuantity.Unit);
+
+ var hectogrampermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.HectogramPerMole);
+ AssertEx.EqualTolerance(HectogramsPerMoleInOneKilogramPerMole, (double)hectogrampermoleQuantity.Value, HectogramsPerMoleTolerance);
+ Assert.Equal(MolarMassUnit.HectogramPerMole, hectogrampermoleQuantity.Unit);
+
+ var kilogrampermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.KilogramPerMole);
+ AssertEx.EqualTolerance(KilogramsPerMoleInOneKilogramPerMole, (double)kilogrampermoleQuantity.Value, KilogramsPerMoleTolerance);
+ Assert.Equal(MolarMassUnit.KilogramPerMole, kilogrampermoleQuantity.Unit);
+
+ var kilopoundpermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.KilopoundPerMole);
+ AssertEx.EqualTolerance(KilopoundsPerMoleInOneKilogramPerMole, (double)kilopoundpermoleQuantity.Value, KilopoundsPerMoleTolerance);
+ Assert.Equal(MolarMassUnit.KilopoundPerMole, kilopoundpermoleQuantity.Unit);
+
+ var megapoundpermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.MegapoundPerMole);
+ AssertEx.EqualTolerance(MegapoundsPerMoleInOneKilogramPerMole, (double)megapoundpermoleQuantity.Value, MegapoundsPerMoleTolerance);
+ Assert.Equal(MolarMassUnit.MegapoundPerMole, megapoundpermoleQuantity.Unit);
+
+ var microgrampermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.MicrogramPerMole);
+ AssertEx.EqualTolerance(MicrogramsPerMoleInOneKilogramPerMole, (double)microgrampermoleQuantity.Value, MicrogramsPerMoleTolerance);
+ Assert.Equal(MolarMassUnit.MicrogramPerMole, microgrampermoleQuantity.Unit);
+
+ var milligrampermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.MilligramPerMole);
+ AssertEx.EqualTolerance(MilligramsPerMoleInOneKilogramPerMole, (double)milligrampermoleQuantity.Value, MilligramsPerMoleTolerance);
+ Assert.Equal(MolarMassUnit.MilligramPerMole, milligrampermoleQuantity.Unit);
+
+ var nanogrampermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.NanogramPerMole);
+ AssertEx.EqualTolerance(NanogramsPerMoleInOneKilogramPerMole, (double)nanogrampermoleQuantity.Value, NanogramsPerMoleTolerance);
+ Assert.Equal(MolarMassUnit.NanogramPerMole, nanogrampermoleQuantity.Unit);
+
+ var poundpermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.PoundPerMole);
+ AssertEx.EqualTolerance(PoundsPerMoleInOneKilogramPerMole, (double)poundpermoleQuantity.Value, PoundsPerMoleTolerance);
+ Assert.Equal(MolarMassUnit.PoundPerMole, poundpermoleQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MolarityTestsBase.g.cs
index d2b27481d1..a41928549f 100644
--- a/UnitsNet.Tests/GeneratedCode/MolarityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/MolarityTestsBase.g.cs
@@ -113,6 +113,44 @@ public void As()
AssertEx.EqualTolerance(PicomolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.As(MolarityUnit.PicomolesPerLiter), PicomolesPerLiterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var molespercubicmeter = Molarity.FromMolesPerCubicMeter(1);
+
+ var centimolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.CentimolesPerLiter);
+ AssertEx.EqualTolerance(CentimolesPerLiterInOneMolesPerCubicMeter, (double)centimolesperliterQuantity.Value, CentimolesPerLiterTolerance);
+ Assert.Equal(MolarityUnit.CentimolesPerLiter, centimolesperliterQuantity.Unit);
+
+ var decimolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.DecimolesPerLiter);
+ AssertEx.EqualTolerance(DecimolesPerLiterInOneMolesPerCubicMeter, (double)decimolesperliterQuantity.Value, DecimolesPerLiterTolerance);
+ Assert.Equal(MolarityUnit.DecimolesPerLiter, decimolesperliterQuantity.Unit);
+
+ var micromolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.MicromolesPerLiter);
+ AssertEx.EqualTolerance(MicromolesPerLiterInOneMolesPerCubicMeter, (double)micromolesperliterQuantity.Value, MicromolesPerLiterTolerance);
+ Assert.Equal(MolarityUnit.MicromolesPerLiter, micromolesperliterQuantity.Unit);
+
+ var millimolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.MillimolesPerLiter);
+ AssertEx.EqualTolerance(MillimolesPerLiterInOneMolesPerCubicMeter, (double)millimolesperliterQuantity.Value, MillimolesPerLiterTolerance);
+ Assert.Equal(MolarityUnit.MillimolesPerLiter, millimolesperliterQuantity.Unit);
+
+ var molespercubicmeterQuantity = molespercubicmeter.ToUnit(MolarityUnit.MolesPerCubicMeter);
+ AssertEx.EqualTolerance(MolesPerCubicMeterInOneMolesPerCubicMeter, (double)molespercubicmeterQuantity.Value, MolesPerCubicMeterTolerance);
+ Assert.Equal(MolarityUnit.MolesPerCubicMeter, molespercubicmeterQuantity.Unit);
+
+ var molesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.MolesPerLiter);
+ AssertEx.EqualTolerance(MolesPerLiterInOneMolesPerCubicMeter, (double)molesperliterQuantity.Value, MolesPerLiterTolerance);
+ Assert.Equal(MolarityUnit.MolesPerLiter, molesperliterQuantity.Unit);
+
+ var nanomolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.NanomolesPerLiter);
+ AssertEx.EqualTolerance(NanomolesPerLiterInOneMolesPerCubicMeter, (double)nanomolesperliterQuantity.Value, NanomolesPerLiterTolerance);
+ Assert.Equal(MolarityUnit.NanomolesPerLiter, nanomolesperliterQuantity.Unit);
+
+ var picomolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.PicomolesPerLiter);
+ AssertEx.EqualTolerance(PicomolesPerLiterInOneMolesPerCubicMeter, (double)picomolesperliterQuantity.Value, PicomolesPerLiterTolerance);
+ Assert.Equal(MolarityUnit.PicomolesPerLiter, picomolesperliterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/PermeabilityTestsBase.g.cs
index 23aab6f023..4892f53766 100644
--- a/UnitsNet.Tests/GeneratedCode/PermeabilityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/PermeabilityTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(HenriesPerMeterInOneHenryPerMeter, henrypermeter.As(PermeabilityUnit.HenryPerMeter), HenriesPerMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var henrypermeter = Permeability.FromHenriesPerMeter(1);
+
+ var henrypermeterQuantity = henrypermeter.ToUnit(PermeabilityUnit.HenryPerMeter);
+ AssertEx.EqualTolerance(HenriesPerMeterInOneHenryPerMeter, (double)henrypermeterQuantity.Value, HenriesPerMeterTolerance);
+ Assert.Equal(PermeabilityUnit.HenryPerMeter, henrypermeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/PermittivityTestsBase.g.cs
index 4a98851193..94334a01d8 100644
--- a/UnitsNet.Tests/GeneratedCode/PermittivityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/PermittivityTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(FaradsPerMeterInOneFaradPerMeter, faradpermeter.As(PermittivityUnit.FaradPerMeter), FaradsPerMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var faradpermeter = Permittivity.FromFaradsPerMeter(1);
+
+ var faradpermeterQuantity = faradpermeter.ToUnit(PermittivityUnit.FaradPerMeter);
+ AssertEx.EqualTolerance(FaradsPerMeterInOneFaradPerMeter, (double)faradpermeterQuantity.Value, FaradsPerMeterTolerance);
+ Assert.Equal(PermittivityUnit.FaradPerMeter, faradpermeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/PowerDensityTestsBase.g.cs
index 64cfa350c2..ce8b82b95d 100644
--- a/UnitsNet.Tests/GeneratedCode/PowerDensityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/PowerDensityTestsBase.g.cs
@@ -293,6 +293,188 @@ public void As()
AssertEx.EqualTolerance(WattsPerLiterInOneWattPerCubicMeter, wattpercubicmeter.As(PowerDensityUnit.WattPerLiter), WattsPerLiterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1);
+
+ var decawattpercubicfootQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.DecawattPerCubicFoot);
+ AssertEx.EqualTolerance(DecawattsPerCubicFootInOneWattPerCubicMeter, (double)decawattpercubicfootQuantity.Value, DecawattsPerCubicFootTolerance);
+ Assert.Equal(PowerDensityUnit.DecawattPerCubicFoot, decawattpercubicfootQuantity.Unit);
+
+ var decawattpercubicinchQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.DecawattPerCubicInch);
+ AssertEx.EqualTolerance(DecawattsPerCubicInchInOneWattPerCubicMeter, (double)decawattpercubicinchQuantity.Value, DecawattsPerCubicInchTolerance);
+ Assert.Equal(PowerDensityUnit.DecawattPerCubicInch, decawattpercubicinchQuantity.Unit);
+
+ var decawattpercubicmeterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.DecawattPerCubicMeter);
+ AssertEx.EqualTolerance(DecawattsPerCubicMeterInOneWattPerCubicMeter, (double)decawattpercubicmeterQuantity.Value, DecawattsPerCubicMeterTolerance);
+ Assert.Equal(PowerDensityUnit.DecawattPerCubicMeter, decawattpercubicmeterQuantity.Unit);
+
+ var decawattperliterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.DecawattPerLiter);
+ AssertEx.EqualTolerance(DecawattsPerLiterInOneWattPerCubicMeter, (double)decawattperliterQuantity.Value, DecawattsPerLiterTolerance);
+ Assert.Equal(PowerDensityUnit.DecawattPerLiter, decawattperliterQuantity.Unit);
+
+ var deciwattpercubicfootQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.DeciwattPerCubicFoot);
+ AssertEx.EqualTolerance(DeciwattsPerCubicFootInOneWattPerCubicMeter, (double)deciwattpercubicfootQuantity.Value, DeciwattsPerCubicFootTolerance);
+ Assert.Equal(PowerDensityUnit.DeciwattPerCubicFoot, deciwattpercubicfootQuantity.Unit);
+
+ var deciwattpercubicinchQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.DeciwattPerCubicInch);
+ AssertEx.EqualTolerance(DeciwattsPerCubicInchInOneWattPerCubicMeter, (double)deciwattpercubicinchQuantity.Value, DeciwattsPerCubicInchTolerance);
+ Assert.Equal(PowerDensityUnit.DeciwattPerCubicInch, deciwattpercubicinchQuantity.Unit);
+
+ var deciwattpercubicmeterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.DeciwattPerCubicMeter);
+ AssertEx.EqualTolerance(DeciwattsPerCubicMeterInOneWattPerCubicMeter, (double)deciwattpercubicmeterQuantity.Value, DeciwattsPerCubicMeterTolerance);
+ Assert.Equal(PowerDensityUnit.DeciwattPerCubicMeter, deciwattpercubicmeterQuantity.Unit);
+
+ var deciwattperliterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.DeciwattPerLiter);
+ AssertEx.EqualTolerance(DeciwattsPerLiterInOneWattPerCubicMeter, (double)deciwattperliterQuantity.Value, DeciwattsPerLiterTolerance);
+ Assert.Equal(PowerDensityUnit.DeciwattPerLiter, deciwattperliterQuantity.Unit);
+
+ var gigawattpercubicfootQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.GigawattPerCubicFoot);
+ AssertEx.EqualTolerance(GigawattsPerCubicFootInOneWattPerCubicMeter, (double)gigawattpercubicfootQuantity.Value, GigawattsPerCubicFootTolerance);
+ Assert.Equal(PowerDensityUnit.GigawattPerCubicFoot, gigawattpercubicfootQuantity.Unit);
+
+ var gigawattpercubicinchQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.GigawattPerCubicInch);
+ AssertEx.EqualTolerance(GigawattsPerCubicInchInOneWattPerCubicMeter, (double)gigawattpercubicinchQuantity.Value, GigawattsPerCubicInchTolerance);
+ Assert.Equal(PowerDensityUnit.GigawattPerCubicInch, gigawattpercubicinchQuantity.Unit);
+
+ var gigawattpercubicmeterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.GigawattPerCubicMeter);
+ AssertEx.EqualTolerance(GigawattsPerCubicMeterInOneWattPerCubicMeter, (double)gigawattpercubicmeterQuantity.Value, GigawattsPerCubicMeterTolerance);
+ Assert.Equal(PowerDensityUnit.GigawattPerCubicMeter, gigawattpercubicmeterQuantity.Unit);
+
+ var gigawattperliterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.GigawattPerLiter);
+ AssertEx.EqualTolerance(GigawattsPerLiterInOneWattPerCubicMeter, (double)gigawattperliterQuantity.Value, GigawattsPerLiterTolerance);
+ Assert.Equal(PowerDensityUnit.GigawattPerLiter, gigawattperliterQuantity.Unit);
+
+ var kilowattpercubicfootQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.KilowattPerCubicFoot);
+ AssertEx.EqualTolerance(KilowattsPerCubicFootInOneWattPerCubicMeter, (double)kilowattpercubicfootQuantity.Value, KilowattsPerCubicFootTolerance);
+ Assert.Equal(PowerDensityUnit.KilowattPerCubicFoot, kilowattpercubicfootQuantity.Unit);
+
+ var kilowattpercubicinchQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.KilowattPerCubicInch);
+ AssertEx.EqualTolerance(KilowattsPerCubicInchInOneWattPerCubicMeter, (double)kilowattpercubicinchQuantity.Value, KilowattsPerCubicInchTolerance);
+ Assert.Equal(PowerDensityUnit.KilowattPerCubicInch, kilowattpercubicinchQuantity.Unit);
+
+ var kilowattpercubicmeterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.KilowattPerCubicMeter);
+ AssertEx.EqualTolerance(KilowattsPerCubicMeterInOneWattPerCubicMeter, (double)kilowattpercubicmeterQuantity.Value, KilowattsPerCubicMeterTolerance);
+ Assert.Equal(PowerDensityUnit.KilowattPerCubicMeter, kilowattpercubicmeterQuantity.Unit);
+
+ var kilowattperliterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.KilowattPerLiter);
+ AssertEx.EqualTolerance(KilowattsPerLiterInOneWattPerCubicMeter, (double)kilowattperliterQuantity.Value, KilowattsPerLiterTolerance);
+ Assert.Equal(PowerDensityUnit.KilowattPerLiter, kilowattperliterQuantity.Unit);
+
+ var megawattpercubicfootQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.MegawattPerCubicFoot);
+ AssertEx.EqualTolerance(MegawattsPerCubicFootInOneWattPerCubicMeter, (double)megawattpercubicfootQuantity.Value, MegawattsPerCubicFootTolerance);
+ Assert.Equal(PowerDensityUnit.MegawattPerCubicFoot, megawattpercubicfootQuantity.Unit);
+
+ var megawattpercubicinchQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.MegawattPerCubicInch);
+ AssertEx.EqualTolerance(MegawattsPerCubicInchInOneWattPerCubicMeter, (double)megawattpercubicinchQuantity.Value, MegawattsPerCubicInchTolerance);
+ Assert.Equal(PowerDensityUnit.MegawattPerCubicInch, megawattpercubicinchQuantity.Unit);
+
+ var megawattpercubicmeterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.MegawattPerCubicMeter);
+ AssertEx.EqualTolerance(MegawattsPerCubicMeterInOneWattPerCubicMeter, (double)megawattpercubicmeterQuantity.Value, MegawattsPerCubicMeterTolerance);
+ Assert.Equal(PowerDensityUnit.MegawattPerCubicMeter, megawattpercubicmeterQuantity.Unit);
+
+ var megawattperliterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.MegawattPerLiter);
+ AssertEx.EqualTolerance(MegawattsPerLiterInOneWattPerCubicMeter, (double)megawattperliterQuantity.Value, MegawattsPerLiterTolerance);
+ Assert.Equal(PowerDensityUnit.MegawattPerLiter, megawattperliterQuantity.Unit);
+
+ var microwattpercubicfootQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.MicrowattPerCubicFoot);
+ AssertEx.EqualTolerance(MicrowattsPerCubicFootInOneWattPerCubicMeter, (double)microwattpercubicfootQuantity.Value, MicrowattsPerCubicFootTolerance);
+ Assert.Equal(PowerDensityUnit.MicrowattPerCubicFoot, microwattpercubicfootQuantity.Unit);
+
+ var microwattpercubicinchQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.MicrowattPerCubicInch);
+ AssertEx.EqualTolerance(MicrowattsPerCubicInchInOneWattPerCubicMeter, (double)microwattpercubicinchQuantity.Value, MicrowattsPerCubicInchTolerance);
+ Assert.Equal(PowerDensityUnit.MicrowattPerCubicInch, microwattpercubicinchQuantity.Unit);
+
+ var microwattpercubicmeterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.MicrowattPerCubicMeter);
+ AssertEx.EqualTolerance(MicrowattsPerCubicMeterInOneWattPerCubicMeter, (double)microwattpercubicmeterQuantity.Value, MicrowattsPerCubicMeterTolerance);
+ Assert.Equal(PowerDensityUnit.MicrowattPerCubicMeter, microwattpercubicmeterQuantity.Unit);
+
+ var microwattperliterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.MicrowattPerLiter);
+ AssertEx.EqualTolerance(MicrowattsPerLiterInOneWattPerCubicMeter, (double)microwattperliterQuantity.Value, MicrowattsPerLiterTolerance);
+ Assert.Equal(PowerDensityUnit.MicrowattPerLiter, microwattperliterQuantity.Unit);
+
+ var milliwattpercubicfootQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.MilliwattPerCubicFoot);
+ AssertEx.EqualTolerance(MilliwattsPerCubicFootInOneWattPerCubicMeter, (double)milliwattpercubicfootQuantity.Value, MilliwattsPerCubicFootTolerance);
+ Assert.Equal(PowerDensityUnit.MilliwattPerCubicFoot, milliwattpercubicfootQuantity.Unit);
+
+ var milliwattpercubicinchQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.MilliwattPerCubicInch);
+ AssertEx.EqualTolerance(MilliwattsPerCubicInchInOneWattPerCubicMeter, (double)milliwattpercubicinchQuantity.Value, MilliwattsPerCubicInchTolerance);
+ Assert.Equal(PowerDensityUnit.MilliwattPerCubicInch, milliwattpercubicinchQuantity.Unit);
+
+ var milliwattpercubicmeterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.MilliwattPerCubicMeter);
+ AssertEx.EqualTolerance(MilliwattsPerCubicMeterInOneWattPerCubicMeter, (double)milliwattpercubicmeterQuantity.Value, MilliwattsPerCubicMeterTolerance);
+ Assert.Equal(PowerDensityUnit.MilliwattPerCubicMeter, milliwattpercubicmeterQuantity.Unit);
+
+ var milliwattperliterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.MilliwattPerLiter);
+ AssertEx.EqualTolerance(MilliwattsPerLiterInOneWattPerCubicMeter, (double)milliwattperliterQuantity.Value, MilliwattsPerLiterTolerance);
+ Assert.Equal(PowerDensityUnit.MilliwattPerLiter, milliwattperliterQuantity.Unit);
+
+ var nanowattpercubicfootQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.NanowattPerCubicFoot);
+ AssertEx.EqualTolerance(NanowattsPerCubicFootInOneWattPerCubicMeter, (double)nanowattpercubicfootQuantity.Value, NanowattsPerCubicFootTolerance);
+ Assert.Equal(PowerDensityUnit.NanowattPerCubicFoot, nanowattpercubicfootQuantity.Unit);
+
+ var nanowattpercubicinchQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.NanowattPerCubicInch);
+ AssertEx.EqualTolerance(NanowattsPerCubicInchInOneWattPerCubicMeter, (double)nanowattpercubicinchQuantity.Value, NanowattsPerCubicInchTolerance);
+ Assert.Equal(PowerDensityUnit.NanowattPerCubicInch, nanowattpercubicinchQuantity.Unit);
+
+ var nanowattpercubicmeterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.NanowattPerCubicMeter);
+ AssertEx.EqualTolerance(NanowattsPerCubicMeterInOneWattPerCubicMeter, (double)nanowattpercubicmeterQuantity.Value, NanowattsPerCubicMeterTolerance);
+ Assert.Equal(PowerDensityUnit.NanowattPerCubicMeter, nanowattpercubicmeterQuantity.Unit);
+
+ var nanowattperliterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.NanowattPerLiter);
+ AssertEx.EqualTolerance(NanowattsPerLiterInOneWattPerCubicMeter, (double)nanowattperliterQuantity.Value, NanowattsPerLiterTolerance);
+ Assert.Equal(PowerDensityUnit.NanowattPerLiter, nanowattperliterQuantity.Unit);
+
+ var picowattpercubicfootQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.PicowattPerCubicFoot);
+ AssertEx.EqualTolerance(PicowattsPerCubicFootInOneWattPerCubicMeter, (double)picowattpercubicfootQuantity.Value, PicowattsPerCubicFootTolerance);
+ Assert.Equal(PowerDensityUnit.PicowattPerCubicFoot, picowattpercubicfootQuantity.Unit);
+
+ var picowattpercubicinchQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.PicowattPerCubicInch);
+ AssertEx.EqualTolerance(PicowattsPerCubicInchInOneWattPerCubicMeter, (double)picowattpercubicinchQuantity.Value, PicowattsPerCubicInchTolerance);
+ Assert.Equal(PowerDensityUnit.PicowattPerCubicInch, picowattpercubicinchQuantity.Unit);
+
+ var picowattpercubicmeterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.PicowattPerCubicMeter);
+ AssertEx.EqualTolerance(PicowattsPerCubicMeterInOneWattPerCubicMeter, (double)picowattpercubicmeterQuantity.Value, PicowattsPerCubicMeterTolerance);
+ Assert.Equal(PowerDensityUnit.PicowattPerCubicMeter, picowattpercubicmeterQuantity.Unit);
+
+ var picowattperliterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.PicowattPerLiter);
+ AssertEx.EqualTolerance(PicowattsPerLiterInOneWattPerCubicMeter, (double)picowattperliterQuantity.Value, PicowattsPerLiterTolerance);
+ Assert.Equal(PowerDensityUnit.PicowattPerLiter, picowattperliterQuantity.Unit);
+
+ var terawattpercubicfootQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.TerawattPerCubicFoot);
+ AssertEx.EqualTolerance(TerawattsPerCubicFootInOneWattPerCubicMeter, (double)terawattpercubicfootQuantity.Value, TerawattsPerCubicFootTolerance);
+ Assert.Equal(PowerDensityUnit.TerawattPerCubicFoot, terawattpercubicfootQuantity.Unit);
+
+ var terawattpercubicinchQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.TerawattPerCubicInch);
+ AssertEx.EqualTolerance(TerawattsPerCubicInchInOneWattPerCubicMeter, (double)terawattpercubicinchQuantity.Value, TerawattsPerCubicInchTolerance);
+ Assert.Equal(PowerDensityUnit.TerawattPerCubicInch, terawattpercubicinchQuantity.Unit);
+
+ var terawattpercubicmeterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.TerawattPerCubicMeter);
+ AssertEx.EqualTolerance(TerawattsPerCubicMeterInOneWattPerCubicMeter, (double)terawattpercubicmeterQuantity.Value, TerawattsPerCubicMeterTolerance);
+ Assert.Equal(PowerDensityUnit.TerawattPerCubicMeter, terawattpercubicmeterQuantity.Unit);
+
+ var terawattperliterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.TerawattPerLiter);
+ AssertEx.EqualTolerance(TerawattsPerLiterInOneWattPerCubicMeter, (double)terawattperliterQuantity.Value, TerawattsPerLiterTolerance);
+ Assert.Equal(PowerDensityUnit.TerawattPerLiter, terawattperliterQuantity.Unit);
+
+ var wattpercubicfootQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.WattPerCubicFoot);
+ AssertEx.EqualTolerance(WattsPerCubicFootInOneWattPerCubicMeter, (double)wattpercubicfootQuantity.Value, WattsPerCubicFootTolerance);
+ Assert.Equal(PowerDensityUnit.WattPerCubicFoot, wattpercubicfootQuantity.Unit);
+
+ var wattpercubicinchQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.WattPerCubicInch);
+ AssertEx.EqualTolerance(WattsPerCubicInchInOneWattPerCubicMeter, (double)wattpercubicinchQuantity.Value, WattsPerCubicInchTolerance);
+ Assert.Equal(PowerDensityUnit.WattPerCubicInch, wattpercubicinchQuantity.Unit);
+
+ var wattpercubicmeterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.WattPerCubicMeter);
+ AssertEx.EqualTolerance(WattsPerCubicMeterInOneWattPerCubicMeter, (double)wattpercubicmeterQuantity.Value, WattsPerCubicMeterTolerance);
+ Assert.Equal(PowerDensityUnit.WattPerCubicMeter, wattpercubicmeterQuantity.Unit);
+
+ var wattperliterQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.WattPerLiter);
+ AssertEx.EqualTolerance(WattsPerLiterInOneWattPerCubicMeter, (double)wattperliterQuantity.Value, WattsPerLiterTolerance);
+ Assert.Equal(PowerDensityUnit.WattPerLiter, wattperliterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/PowerRatioTestsBase.g.cs
index 54fe28e3fe..d74f2cc6a9 100644
--- a/UnitsNet.Tests/GeneratedCode/PowerRatioTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/PowerRatioTestsBase.g.cs
@@ -83,6 +83,20 @@ public void As()
AssertEx.EqualTolerance(DecibelWattsInOneDecibelWatt, decibelwatt.As(PowerRatioUnit.DecibelWatt), DecibelWattsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var decibelwatt = PowerRatio.FromDecibelWatts(1);
+
+ var decibelmilliwattQuantity = decibelwatt.ToUnit(PowerRatioUnit.DecibelMilliwatt);
+ AssertEx.EqualTolerance(DecibelMilliwattsInOneDecibelWatt, (double)decibelmilliwattQuantity.Value, DecibelMilliwattsTolerance);
+ Assert.Equal(PowerRatioUnit.DecibelMilliwatt, decibelmilliwattQuantity.Unit);
+
+ var decibelwattQuantity = decibelwatt.ToUnit(PowerRatioUnit.DecibelWatt);
+ AssertEx.EqualTolerance(DecibelWattsInOneDecibelWatt, (double)decibelwattQuantity.Value, DecibelWattsTolerance);
+ Assert.Equal(PowerRatioUnit.DecibelWatt, decibelwattQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/PowerTestsBase.g.cs
index 2ad81d79fe..6620f59576 100644
--- a/UnitsNet.Tests/GeneratedCode/PowerTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/PowerTestsBase.g.cs
@@ -173,6 +173,92 @@ public void As()
AssertEx.EqualTolerance(WattsInOneWatt, watt.As(PowerUnit.Watt), WattsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var watt = Power.FromWatts(1);
+
+ var boilerhorsepowerQuantity = watt.ToUnit(PowerUnit.BoilerHorsepower);
+ AssertEx.EqualTolerance(BoilerHorsepowerInOneWatt, (double)boilerhorsepowerQuantity.Value, BoilerHorsepowerTolerance);
+ Assert.Equal(PowerUnit.BoilerHorsepower, boilerhorsepowerQuantity.Unit);
+
+ var britishthermalunitperhourQuantity = watt.ToUnit(PowerUnit.BritishThermalUnitPerHour);
+ AssertEx.EqualTolerance(BritishThermalUnitsPerHourInOneWatt, (double)britishthermalunitperhourQuantity.Value, BritishThermalUnitsPerHourTolerance);
+ Assert.Equal(PowerUnit.BritishThermalUnitPerHour, britishthermalunitperhourQuantity.Unit);
+
+ var decawattQuantity = watt.ToUnit(PowerUnit.Decawatt);
+ AssertEx.EqualTolerance(DecawattsInOneWatt, (double)decawattQuantity.Value, DecawattsTolerance);
+ Assert.Equal(PowerUnit.Decawatt, decawattQuantity.Unit);
+
+ var deciwattQuantity = watt.ToUnit(PowerUnit.Deciwatt);
+ AssertEx.EqualTolerance(DeciwattsInOneWatt, (double)deciwattQuantity.Value, DeciwattsTolerance);
+ Assert.Equal(PowerUnit.Deciwatt, deciwattQuantity.Unit);
+
+ var electricalhorsepowerQuantity = watt.ToUnit(PowerUnit.ElectricalHorsepower);
+ AssertEx.EqualTolerance(ElectricalHorsepowerInOneWatt, (double)electricalhorsepowerQuantity.Value, ElectricalHorsepowerTolerance);
+ Assert.Equal(PowerUnit.ElectricalHorsepower, electricalhorsepowerQuantity.Unit);
+
+ var femtowattQuantity = watt.ToUnit(PowerUnit.Femtowatt);
+ AssertEx.EqualTolerance(FemtowattsInOneWatt, (double)femtowattQuantity.Value, FemtowattsTolerance);
+ Assert.Equal(PowerUnit.Femtowatt, femtowattQuantity.Unit);
+
+ var gigawattQuantity = watt.ToUnit(PowerUnit.Gigawatt);
+ AssertEx.EqualTolerance(GigawattsInOneWatt, (double)gigawattQuantity.Value, GigawattsTolerance);
+ Assert.Equal(PowerUnit.Gigawatt, gigawattQuantity.Unit);
+
+ var hydraulichorsepowerQuantity = watt.ToUnit(PowerUnit.HydraulicHorsepower);
+ AssertEx.EqualTolerance(HydraulicHorsepowerInOneWatt, (double)hydraulichorsepowerQuantity.Value, HydraulicHorsepowerTolerance);
+ Assert.Equal(PowerUnit.HydraulicHorsepower, hydraulichorsepowerQuantity.Unit);
+
+ var kilobritishthermalunitperhourQuantity = watt.ToUnit(PowerUnit.KilobritishThermalUnitPerHour);
+ AssertEx.EqualTolerance(KilobritishThermalUnitsPerHourInOneWatt, (double)kilobritishthermalunitperhourQuantity.Value, KilobritishThermalUnitsPerHourTolerance);
+ Assert.Equal(PowerUnit.KilobritishThermalUnitPerHour, kilobritishthermalunitperhourQuantity.Unit);
+
+ var kilowattQuantity = watt.ToUnit(PowerUnit.Kilowatt);
+ AssertEx.EqualTolerance(KilowattsInOneWatt, (double)kilowattQuantity.Value, KilowattsTolerance);
+ Assert.Equal(PowerUnit.Kilowatt, kilowattQuantity.Unit);
+
+ var mechanicalhorsepowerQuantity = watt.ToUnit(PowerUnit.MechanicalHorsepower);
+ AssertEx.EqualTolerance(MechanicalHorsepowerInOneWatt, (double)mechanicalhorsepowerQuantity.Value, MechanicalHorsepowerTolerance);
+ Assert.Equal(PowerUnit.MechanicalHorsepower, mechanicalhorsepowerQuantity.Unit);
+
+ var megawattQuantity = watt.ToUnit(PowerUnit.Megawatt);
+ AssertEx.EqualTolerance(MegawattsInOneWatt, (double)megawattQuantity.Value, MegawattsTolerance);
+ Assert.Equal(PowerUnit.Megawatt, megawattQuantity.Unit);
+
+ var metrichorsepowerQuantity = watt.ToUnit(PowerUnit.MetricHorsepower);
+ AssertEx.EqualTolerance(MetricHorsepowerInOneWatt, (double)metrichorsepowerQuantity.Value, MetricHorsepowerTolerance);
+ Assert.Equal(PowerUnit.MetricHorsepower, metrichorsepowerQuantity.Unit);
+
+ var microwattQuantity = watt.ToUnit(PowerUnit.Microwatt);
+ AssertEx.EqualTolerance(MicrowattsInOneWatt, (double)microwattQuantity.Value, MicrowattsTolerance);
+ Assert.Equal(PowerUnit.Microwatt, microwattQuantity.Unit);
+
+ var milliwattQuantity = watt.ToUnit(PowerUnit.Milliwatt);
+ AssertEx.EqualTolerance(MilliwattsInOneWatt, (double)milliwattQuantity.Value, MilliwattsTolerance);
+ Assert.Equal(PowerUnit.Milliwatt, milliwattQuantity.Unit);
+
+ var nanowattQuantity = watt.ToUnit(PowerUnit.Nanowatt);
+ AssertEx.EqualTolerance(NanowattsInOneWatt, (double)nanowattQuantity.Value, NanowattsTolerance);
+ Assert.Equal(PowerUnit.Nanowatt, nanowattQuantity.Unit);
+
+ var petawattQuantity = watt.ToUnit(PowerUnit.Petawatt);
+ AssertEx.EqualTolerance(PetawattsInOneWatt, (double)petawattQuantity.Value, PetawattsTolerance);
+ Assert.Equal(PowerUnit.Petawatt, petawattQuantity.Unit);
+
+ var picowattQuantity = watt.ToUnit(PowerUnit.Picowatt);
+ AssertEx.EqualTolerance(PicowattsInOneWatt, (double)picowattQuantity.Value, PicowattsTolerance);
+ Assert.Equal(PowerUnit.Picowatt, picowattQuantity.Unit);
+
+ var terawattQuantity = watt.ToUnit(PowerUnit.Terawatt);
+ AssertEx.EqualTolerance(TerawattsInOneWatt, (double)terawattQuantity.Value, TerawattsTolerance);
+ Assert.Equal(PowerUnit.Terawatt, terawattQuantity.Unit);
+
+ var wattQuantity = watt.ToUnit(PowerUnit.Watt);
+ AssertEx.EqualTolerance(WattsInOneWatt, (double)wattQuantity.Value, WattsTolerance);
+ Assert.Equal(PowerUnit.Watt, wattQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/PressureChangeRateTestsBase.g.cs
index a1a58b0046..443a387f9b 100644
--- a/UnitsNet.Tests/GeneratedCode/PressureChangeRateTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/PressureChangeRateTestsBase.g.cs
@@ -93,6 +93,28 @@ public void As()
AssertEx.EqualTolerance(PascalsPerSecondInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.PascalPerSecond), PascalsPerSecondTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1);
+
+ var atmospherepersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.AtmospherePerSecond);
+ AssertEx.EqualTolerance(AtmospheresPerSecondInOnePascalPerSecond, (double)atmospherepersecondQuantity.Value, AtmospheresPerSecondTolerance);
+ Assert.Equal(PressureChangeRateUnit.AtmospherePerSecond, atmospherepersecondQuantity.Unit);
+
+ var kilopascalpersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.KilopascalPerSecond);
+ AssertEx.EqualTolerance(KilopascalsPerSecondInOnePascalPerSecond, (double)kilopascalpersecondQuantity.Value, KilopascalsPerSecondTolerance);
+ Assert.Equal(PressureChangeRateUnit.KilopascalPerSecond, kilopascalpersecondQuantity.Unit);
+
+ var megapascalpersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.MegapascalPerSecond);
+ AssertEx.EqualTolerance(MegapascalsPerSecondInOnePascalPerSecond, (double)megapascalpersecondQuantity.Value, MegapascalsPerSecondTolerance);
+ Assert.Equal(PressureChangeRateUnit.MegapascalPerSecond, megapascalpersecondQuantity.Unit);
+
+ var pascalpersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.PascalPerSecond);
+ AssertEx.EqualTolerance(PascalsPerSecondInOnePascalPerSecond, (double)pascalpersecondQuantity.Value, PascalsPerSecondTolerance);
+ Assert.Equal(PressureChangeRateUnit.PascalPerSecond, pascalpersecondQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/PressureTestsBase.g.cs
index a29dd641a0..45559a10c7 100644
--- a/UnitsNet.Tests/GeneratedCode/PressureTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/PressureTestsBase.g.cs
@@ -263,6 +263,164 @@ public void As()
AssertEx.EqualTolerance(TorrsInOnePascal, pascal.As(PressureUnit.Torr), TorrsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var pascal = Pressure.FromPascals(1);
+
+ var atmosphereQuantity = pascal.ToUnit(PressureUnit.Atmosphere);
+ AssertEx.EqualTolerance(AtmospheresInOnePascal, (double)atmosphereQuantity.Value, AtmospheresTolerance);
+ Assert.Equal(PressureUnit.Atmosphere, atmosphereQuantity.Unit);
+
+ var barQuantity = pascal.ToUnit(PressureUnit.Bar);
+ AssertEx.EqualTolerance(BarsInOnePascal, (double)barQuantity.Value, BarsTolerance);
+ Assert.Equal(PressureUnit.Bar, barQuantity.Unit);
+
+ var centibarQuantity = pascal.ToUnit(PressureUnit.Centibar);
+ AssertEx.EqualTolerance(CentibarsInOnePascal, (double)centibarQuantity.Value, CentibarsTolerance);
+ Assert.Equal(PressureUnit.Centibar, centibarQuantity.Unit);
+
+ var decapascalQuantity = pascal.ToUnit(PressureUnit.Decapascal);
+ AssertEx.EqualTolerance(DecapascalsInOnePascal, (double)decapascalQuantity.Value, DecapascalsTolerance);
+ Assert.Equal(PressureUnit.Decapascal, decapascalQuantity.Unit);
+
+ var decibarQuantity = pascal.ToUnit(PressureUnit.Decibar);
+ AssertEx.EqualTolerance(DecibarsInOnePascal, (double)decibarQuantity.Value, DecibarsTolerance);
+ Assert.Equal(PressureUnit.Decibar, decibarQuantity.Unit);
+
+ var footofheadQuantity = pascal.ToUnit(PressureUnit.FootOfHead);
+ AssertEx.EqualTolerance(FeetOfHeadInOnePascal, (double)footofheadQuantity.Value, FeetOfHeadTolerance);
+ Assert.Equal(PressureUnit.FootOfHead, footofheadQuantity.Unit);
+
+ var gigapascalQuantity = pascal.ToUnit(PressureUnit.Gigapascal);
+ AssertEx.EqualTolerance(GigapascalsInOnePascal, (double)gigapascalQuantity.Value, GigapascalsTolerance);
+ Assert.Equal(PressureUnit.Gigapascal, gigapascalQuantity.Unit);
+
+ var hectopascalQuantity = pascal.ToUnit(PressureUnit.Hectopascal);
+ AssertEx.EqualTolerance(HectopascalsInOnePascal, (double)hectopascalQuantity.Value, HectopascalsTolerance);
+ Assert.Equal(PressureUnit.Hectopascal, hectopascalQuantity.Unit);
+
+ var inchofmercuryQuantity = pascal.ToUnit(PressureUnit.InchOfMercury);
+ AssertEx.EqualTolerance(InchesOfMercuryInOnePascal, (double)inchofmercuryQuantity.Value, InchesOfMercuryTolerance);
+ Assert.Equal(PressureUnit.InchOfMercury, inchofmercuryQuantity.Unit);
+
+ var kilobarQuantity = pascal.ToUnit(PressureUnit.Kilobar);
+ AssertEx.EqualTolerance(KilobarsInOnePascal, (double)kilobarQuantity.Value, KilobarsTolerance);
+ Assert.Equal(PressureUnit.Kilobar, kilobarQuantity.Unit);
+
+ var kilogramforcepersquarecentimeterQuantity = pascal.ToUnit(PressureUnit.KilogramForcePerSquareCentimeter);
+ AssertEx.EqualTolerance(KilogramsForcePerSquareCentimeterInOnePascal, (double)kilogramforcepersquarecentimeterQuantity.Value, KilogramsForcePerSquareCentimeterTolerance);
+ Assert.Equal(PressureUnit.KilogramForcePerSquareCentimeter, kilogramforcepersquarecentimeterQuantity.Unit);
+
+ var kilogramforcepersquaremeterQuantity = pascal.ToUnit(PressureUnit.KilogramForcePerSquareMeter);
+ AssertEx.EqualTolerance(KilogramsForcePerSquareMeterInOnePascal, (double)kilogramforcepersquaremeterQuantity.Value, KilogramsForcePerSquareMeterTolerance);
+ Assert.Equal(PressureUnit.KilogramForcePerSquareMeter, kilogramforcepersquaremeterQuantity.Unit);
+
+ var kilogramforcepersquaremillimeterQuantity = pascal.ToUnit(PressureUnit.KilogramForcePerSquareMillimeter);
+ AssertEx.EqualTolerance(KilogramsForcePerSquareMillimeterInOnePascal, (double)kilogramforcepersquaremillimeterQuantity.Value, KilogramsForcePerSquareMillimeterTolerance);
+ Assert.Equal(PressureUnit.KilogramForcePerSquareMillimeter, kilogramforcepersquaremillimeterQuantity.Unit);
+
+ var kilonewtonpersquarecentimeterQuantity = pascal.ToUnit(PressureUnit.KilonewtonPerSquareCentimeter);
+ AssertEx.EqualTolerance(KilonewtonsPerSquareCentimeterInOnePascal, (double)kilonewtonpersquarecentimeterQuantity.Value, KilonewtonsPerSquareCentimeterTolerance);
+ Assert.Equal(PressureUnit.KilonewtonPerSquareCentimeter, kilonewtonpersquarecentimeterQuantity.Unit);
+
+ var kilonewtonpersquaremeterQuantity = pascal.ToUnit(PressureUnit.KilonewtonPerSquareMeter);
+ AssertEx.EqualTolerance(KilonewtonsPerSquareMeterInOnePascal, (double)kilonewtonpersquaremeterQuantity.Value, KilonewtonsPerSquareMeterTolerance);
+ Assert.Equal(PressureUnit.KilonewtonPerSquareMeter, kilonewtonpersquaremeterQuantity.Unit);
+
+ var kilonewtonpersquaremillimeterQuantity = pascal.ToUnit(PressureUnit.KilonewtonPerSquareMillimeter);
+ AssertEx.EqualTolerance(KilonewtonsPerSquareMillimeterInOnePascal, (double)kilonewtonpersquaremillimeterQuantity.Value, KilonewtonsPerSquareMillimeterTolerance);
+ Assert.Equal(PressureUnit.KilonewtonPerSquareMillimeter, kilonewtonpersquaremillimeterQuantity.Unit);
+
+ var kilopascalQuantity = pascal.ToUnit(PressureUnit.Kilopascal);
+ AssertEx.EqualTolerance(KilopascalsInOnePascal, (double)kilopascalQuantity.Value, KilopascalsTolerance);
+ Assert.Equal(PressureUnit.Kilopascal, kilopascalQuantity.Unit);
+
+ var kilopoundforcepersquarefootQuantity = pascal.ToUnit(PressureUnit.KilopoundForcePerSquareFoot);
+ AssertEx.EqualTolerance(KilopoundsForcePerSquareFootInOnePascal, (double)kilopoundforcepersquarefootQuantity.Value, KilopoundsForcePerSquareFootTolerance);
+ Assert.Equal(PressureUnit.KilopoundForcePerSquareFoot, kilopoundforcepersquarefootQuantity.Unit);
+
+ var kilopoundforcepersquareinchQuantity = pascal.ToUnit(PressureUnit.KilopoundForcePerSquareInch);
+ AssertEx.EqualTolerance(KilopoundsForcePerSquareInchInOnePascal, (double)kilopoundforcepersquareinchQuantity.Value, KilopoundsForcePerSquareInchTolerance);
+ Assert.Equal(PressureUnit.KilopoundForcePerSquareInch, kilopoundforcepersquareinchQuantity.Unit);
+
+ var megabarQuantity = pascal.ToUnit(PressureUnit.Megabar);
+ AssertEx.EqualTolerance(MegabarsInOnePascal, (double)megabarQuantity.Value, MegabarsTolerance);
+ Assert.Equal(PressureUnit.Megabar, megabarQuantity.Unit);
+
+ var meganewtonpersquaremeterQuantity = pascal.ToUnit(PressureUnit.MeganewtonPerSquareMeter);
+ AssertEx.EqualTolerance(MeganewtonsPerSquareMeterInOnePascal, (double)meganewtonpersquaremeterQuantity.Value, MeganewtonsPerSquareMeterTolerance);
+ Assert.Equal(PressureUnit.MeganewtonPerSquareMeter, meganewtonpersquaremeterQuantity.Unit);
+
+ var megapascalQuantity = pascal.ToUnit(PressureUnit.Megapascal);
+ AssertEx.EqualTolerance(MegapascalsInOnePascal, (double)megapascalQuantity.Value, MegapascalsTolerance);
+ Assert.Equal(PressureUnit.Megapascal, megapascalQuantity.Unit);
+
+ var meterofheadQuantity = pascal.ToUnit(PressureUnit.MeterOfHead);
+ AssertEx.EqualTolerance(MetersOfHeadInOnePascal, (double)meterofheadQuantity.Value, MetersOfHeadTolerance);
+ Assert.Equal(PressureUnit.MeterOfHead, meterofheadQuantity.Unit);
+
+ var micropascalQuantity = pascal.ToUnit(PressureUnit.Micropascal);
+ AssertEx.EqualTolerance(MicropascalsInOnePascal, (double)micropascalQuantity.Value, MicropascalsTolerance);
+ Assert.Equal(PressureUnit.Micropascal, micropascalQuantity.Unit);
+
+ var millibarQuantity = pascal.ToUnit(PressureUnit.Millibar);
+ AssertEx.EqualTolerance(MillibarsInOnePascal, (double)millibarQuantity.Value, MillibarsTolerance);
+ Assert.Equal(PressureUnit.Millibar, millibarQuantity.Unit);
+
+ var millimeterofmercuryQuantity = pascal.ToUnit(PressureUnit.MillimeterOfMercury);
+ AssertEx.EqualTolerance(MillimetersOfMercuryInOnePascal, (double)millimeterofmercuryQuantity.Value, MillimetersOfMercuryTolerance);
+ Assert.Equal(PressureUnit.MillimeterOfMercury, millimeterofmercuryQuantity.Unit);
+
+ var newtonpersquarecentimeterQuantity = pascal.ToUnit(PressureUnit.NewtonPerSquareCentimeter);
+ AssertEx.EqualTolerance(NewtonsPerSquareCentimeterInOnePascal, (double)newtonpersquarecentimeterQuantity.Value, NewtonsPerSquareCentimeterTolerance);
+ Assert.Equal(PressureUnit.NewtonPerSquareCentimeter, newtonpersquarecentimeterQuantity.Unit);
+
+ var newtonpersquaremeterQuantity = pascal.ToUnit(PressureUnit.NewtonPerSquareMeter);
+ AssertEx.EqualTolerance(NewtonsPerSquareMeterInOnePascal, (double)newtonpersquaremeterQuantity.Value, NewtonsPerSquareMeterTolerance);
+ Assert.Equal(PressureUnit.NewtonPerSquareMeter, newtonpersquaremeterQuantity.Unit);
+
+ var newtonpersquaremillimeterQuantity = pascal.ToUnit(PressureUnit.NewtonPerSquareMillimeter);
+ AssertEx.EqualTolerance(NewtonsPerSquareMillimeterInOnePascal, (double)newtonpersquaremillimeterQuantity.Value, NewtonsPerSquareMillimeterTolerance);
+ Assert.Equal(PressureUnit.NewtonPerSquareMillimeter, newtonpersquaremillimeterQuantity.Unit);
+
+ var pascalQuantity = pascal.ToUnit(PressureUnit.Pascal);
+ AssertEx.EqualTolerance(PascalsInOnePascal, (double)pascalQuantity.Value, PascalsTolerance);
+ Assert.Equal(PressureUnit.Pascal, pascalQuantity.Unit);
+
+ var poundforcepersquarefootQuantity = pascal.ToUnit(PressureUnit.PoundForcePerSquareFoot);
+ AssertEx.EqualTolerance(PoundsForcePerSquareFootInOnePascal, (double)poundforcepersquarefootQuantity.Value, PoundsForcePerSquareFootTolerance);
+ Assert.Equal(PressureUnit.PoundForcePerSquareFoot, poundforcepersquarefootQuantity.Unit);
+
+ var poundforcepersquareinchQuantity = pascal.ToUnit(PressureUnit.PoundForcePerSquareInch);
+ AssertEx.EqualTolerance(PoundsForcePerSquareInchInOnePascal, (double)poundforcepersquareinchQuantity.Value, PoundsForcePerSquareInchTolerance);
+ Assert.Equal(PressureUnit.PoundForcePerSquareInch, poundforcepersquareinchQuantity.Unit);
+
+ var psiQuantity = pascal.ToUnit(PressureUnit.Psi);
+ AssertEx.EqualTolerance(PsiInOnePascal, (double)psiQuantity.Value, PsiTolerance);
+ Assert.Equal(PressureUnit.Psi, psiQuantity.Unit);
+
+ var technicalatmosphereQuantity = pascal.ToUnit(PressureUnit.TechnicalAtmosphere);
+ AssertEx.EqualTolerance(TechnicalAtmospheresInOnePascal, (double)technicalatmosphereQuantity.Value, TechnicalAtmospheresTolerance);
+ Assert.Equal(PressureUnit.TechnicalAtmosphere, technicalatmosphereQuantity.Unit);
+
+ var tonneforcepersquarecentimeterQuantity = pascal.ToUnit(PressureUnit.TonneForcePerSquareCentimeter);
+ AssertEx.EqualTolerance(TonnesForcePerSquareCentimeterInOnePascal, (double)tonneforcepersquarecentimeterQuantity.Value, TonnesForcePerSquareCentimeterTolerance);
+ Assert.Equal(PressureUnit.TonneForcePerSquareCentimeter, tonneforcepersquarecentimeterQuantity.Unit);
+
+ var tonneforcepersquaremeterQuantity = pascal.ToUnit(PressureUnit.TonneForcePerSquareMeter);
+ AssertEx.EqualTolerance(TonnesForcePerSquareMeterInOnePascal, (double)tonneforcepersquaremeterQuantity.Value, TonnesForcePerSquareMeterTolerance);
+ Assert.Equal(PressureUnit.TonneForcePerSquareMeter, tonneforcepersquaremeterQuantity.Unit);
+
+ var tonneforcepersquaremillimeterQuantity = pascal.ToUnit(PressureUnit.TonneForcePerSquareMillimeter);
+ AssertEx.EqualTolerance(TonnesForcePerSquareMillimeterInOnePascal, (double)tonneforcepersquaremillimeterQuantity.Value, TonnesForcePerSquareMillimeterTolerance);
+ Assert.Equal(PressureUnit.TonneForcePerSquareMillimeter, tonneforcepersquaremillimeterQuantity.Unit);
+
+ var torrQuantity = pascal.ToUnit(PressureUnit.Torr);
+ AssertEx.EqualTolerance(TorrsInOnePascal, (double)torrQuantity.Value, TorrsTolerance);
+ Assert.Equal(PressureUnit.Torr, torrQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/RatioTestsBase.g.cs
index 8e5fc2c610..233033435e 100644
--- a/UnitsNet.Tests/GeneratedCode/RatioTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/RatioTestsBase.g.cs
@@ -103,6 +103,36 @@ public void As()
AssertEx.EqualTolerance(PercentInOneDecimalFraction, decimalfraction.As(RatioUnit.Percent), PercentTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var decimalfraction = Ratio.FromDecimalFractions(1);
+
+ var decimalfractionQuantity = decimalfraction.ToUnit(RatioUnit.DecimalFraction);
+ AssertEx.EqualTolerance(DecimalFractionsInOneDecimalFraction, (double)decimalfractionQuantity.Value, DecimalFractionsTolerance);
+ Assert.Equal(RatioUnit.DecimalFraction, decimalfractionQuantity.Unit);
+
+ var partperbillionQuantity = decimalfraction.ToUnit(RatioUnit.PartPerBillion);
+ AssertEx.EqualTolerance(PartsPerBillionInOneDecimalFraction, (double)partperbillionQuantity.Value, PartsPerBillionTolerance);
+ Assert.Equal(RatioUnit.PartPerBillion, partperbillionQuantity.Unit);
+
+ var partpermillionQuantity = decimalfraction.ToUnit(RatioUnit.PartPerMillion);
+ AssertEx.EqualTolerance(PartsPerMillionInOneDecimalFraction, (double)partpermillionQuantity.Value, PartsPerMillionTolerance);
+ Assert.Equal(RatioUnit.PartPerMillion, partpermillionQuantity.Unit);
+
+ var partperthousandQuantity = decimalfraction.ToUnit(RatioUnit.PartPerThousand);
+ AssertEx.EqualTolerance(PartsPerThousandInOneDecimalFraction, (double)partperthousandQuantity.Value, PartsPerThousandTolerance);
+ Assert.Equal(RatioUnit.PartPerThousand, partperthousandQuantity.Unit);
+
+ var partpertrillionQuantity = decimalfraction.ToUnit(RatioUnit.PartPerTrillion);
+ AssertEx.EqualTolerance(PartsPerTrillionInOneDecimalFraction, (double)partpertrillionQuantity.Value, PartsPerTrillionTolerance);
+ Assert.Equal(RatioUnit.PartPerTrillion, partpertrillionQuantity.Unit);
+
+ var percentQuantity = decimalfraction.ToUnit(RatioUnit.Percent);
+ AssertEx.EqualTolerance(PercentInOneDecimalFraction, (double)percentQuantity.Value, PercentTolerance);
+ Assert.Equal(RatioUnit.Percent, percentQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ReactiveEnergyTestsBase.g.cs
index de344b7a77..34dae7efed 100644
--- a/UnitsNet.Tests/GeneratedCode/ReactiveEnergyTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ReactiveEnergyTestsBase.g.cs
@@ -88,6 +88,24 @@ public void As()
AssertEx.EqualTolerance(VoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.As(ReactiveEnergyUnit.VoltampereReactiveHour), VoltampereReactiveHoursTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1);
+
+ var kilovoltamperereactivehourQuantity = voltamperereactivehour.ToUnit(ReactiveEnergyUnit.KilovoltampereReactiveHour);
+ AssertEx.EqualTolerance(KilovoltampereReactiveHoursInOneVoltampereReactiveHour, (double)kilovoltamperereactivehourQuantity.Value, KilovoltampereReactiveHoursTolerance);
+ Assert.Equal(ReactiveEnergyUnit.KilovoltampereReactiveHour, kilovoltamperereactivehourQuantity.Unit);
+
+ var megavoltamperereactivehourQuantity = voltamperereactivehour.ToUnit(ReactiveEnergyUnit.MegavoltampereReactiveHour);
+ AssertEx.EqualTolerance(MegavoltampereReactiveHoursInOneVoltampereReactiveHour, (double)megavoltamperereactivehourQuantity.Value, MegavoltampereReactiveHoursTolerance);
+ Assert.Equal(ReactiveEnergyUnit.MegavoltampereReactiveHour, megavoltamperereactivehourQuantity.Unit);
+
+ var voltamperereactivehourQuantity = voltamperereactivehour.ToUnit(ReactiveEnergyUnit.VoltampereReactiveHour);
+ AssertEx.EqualTolerance(VoltampereReactiveHoursInOneVoltampereReactiveHour, (double)voltamperereactivehourQuantity.Value, VoltampereReactiveHoursTolerance);
+ Assert.Equal(ReactiveEnergyUnit.VoltampereReactiveHour, voltamperereactivehourQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ReactivePowerTestsBase.g.cs
index 9aa10c6281..1e9f69710d 100644
--- a/UnitsNet.Tests/GeneratedCode/ReactivePowerTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ReactivePowerTestsBase.g.cs
@@ -93,6 +93,28 @@ public void As()
AssertEx.EqualTolerance(VoltamperesReactiveInOneVoltampereReactive, voltamperereactive.As(ReactivePowerUnit.VoltampereReactive), VoltamperesReactiveTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var voltamperereactive = ReactivePower.FromVoltamperesReactive(1);
+
+ var gigavoltamperereactiveQuantity = voltamperereactive.ToUnit(ReactivePowerUnit.GigavoltampereReactive);
+ AssertEx.EqualTolerance(GigavoltamperesReactiveInOneVoltampereReactive, (double)gigavoltamperereactiveQuantity.Value, GigavoltamperesReactiveTolerance);
+ Assert.Equal(ReactivePowerUnit.GigavoltampereReactive, gigavoltamperereactiveQuantity.Unit);
+
+ var kilovoltamperereactiveQuantity = voltamperereactive.ToUnit(ReactivePowerUnit.KilovoltampereReactive);
+ AssertEx.EqualTolerance(KilovoltamperesReactiveInOneVoltampereReactive, (double)kilovoltamperereactiveQuantity.Value, KilovoltamperesReactiveTolerance);
+ Assert.Equal(ReactivePowerUnit.KilovoltampereReactive, kilovoltamperereactiveQuantity.Unit);
+
+ var megavoltamperereactiveQuantity = voltamperereactive.ToUnit(ReactivePowerUnit.MegavoltampereReactive);
+ AssertEx.EqualTolerance(MegavoltamperesReactiveInOneVoltampereReactive, (double)megavoltamperereactiveQuantity.Value, MegavoltamperesReactiveTolerance);
+ Assert.Equal(ReactivePowerUnit.MegavoltampereReactive, megavoltamperereactiveQuantity.Unit);
+
+ var voltamperereactiveQuantity = voltamperereactive.ToUnit(ReactivePowerUnit.VoltampereReactive);
+ AssertEx.EqualTolerance(VoltamperesReactiveInOneVoltampereReactive, (double)voltamperereactiveQuantity.Value, VoltamperesReactiveTolerance);
+ Assert.Equal(ReactivePowerUnit.VoltampereReactive, voltamperereactiveQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/RotationalAccelerationTestsBase.g.cs
index b4fb9c0028..ed3b52dd9c 100644
--- a/UnitsNet.Tests/GeneratedCode/RotationalAccelerationTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/RotationalAccelerationTestsBase.g.cs
@@ -88,6 +88,24 @@ public void As()
AssertEx.EqualTolerance(RevolutionsPerMinutePerSecondInOneRadianPerSecondSquared, radianpersecondsquared.As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond), RevolutionsPerMinutePerSecondTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1);
+
+ var degreepersecondsquaredQuantity = radianpersecondsquared.ToUnit(RotationalAccelerationUnit.DegreePerSecondSquared);
+ AssertEx.EqualTolerance(DegreesPerSecondSquaredInOneRadianPerSecondSquared, (double)degreepersecondsquaredQuantity.Value, DegreesPerSecondSquaredTolerance);
+ Assert.Equal(RotationalAccelerationUnit.DegreePerSecondSquared, degreepersecondsquaredQuantity.Unit);
+
+ var radianpersecondsquaredQuantity = radianpersecondsquared.ToUnit(RotationalAccelerationUnit.RadianPerSecondSquared);
+ AssertEx.EqualTolerance(RadiansPerSecondSquaredInOneRadianPerSecondSquared, (double)radianpersecondsquaredQuantity.Value, RadiansPerSecondSquaredTolerance);
+ Assert.Equal(RotationalAccelerationUnit.RadianPerSecondSquared, radianpersecondsquaredQuantity.Unit);
+
+ var revolutionperminutepersecondQuantity = radianpersecondsquared.ToUnit(RotationalAccelerationUnit.RevolutionPerMinutePerSecond);
+ AssertEx.EqualTolerance(RevolutionsPerMinutePerSecondInOneRadianPerSecondSquared, (double)revolutionperminutepersecondQuantity.Value, RevolutionsPerMinutePerSecondTolerance);
+ Assert.Equal(RotationalAccelerationUnit.RevolutionPerMinutePerSecond, revolutionperminutepersecondQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/RotationalSpeedTestsBase.g.cs
index 63410d7311..8cdfccae9f 100644
--- a/UnitsNet.Tests/GeneratedCode/RotationalSpeedTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/RotationalSpeedTestsBase.g.cs
@@ -138,6 +138,64 @@ public void As()
AssertEx.EqualTolerance(RevolutionsPerSecondInOneRadianPerSecond, radianpersecond.As(RotationalSpeedUnit.RevolutionPerSecond), RevolutionsPerSecondTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var radianpersecond = RotationalSpeed.FromRadiansPerSecond(1);
+
+ var centiradianpersecondQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.CentiradianPerSecond);
+ AssertEx.EqualTolerance(CentiradiansPerSecondInOneRadianPerSecond, (double)centiradianpersecondQuantity.Value, CentiradiansPerSecondTolerance);
+ Assert.Equal(RotationalSpeedUnit.CentiradianPerSecond, centiradianpersecondQuantity.Unit);
+
+ var deciradianpersecondQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.DeciradianPerSecond);
+ AssertEx.EqualTolerance(DeciradiansPerSecondInOneRadianPerSecond, (double)deciradianpersecondQuantity.Value, DeciradiansPerSecondTolerance);
+ Assert.Equal(RotationalSpeedUnit.DeciradianPerSecond, deciradianpersecondQuantity.Unit);
+
+ var degreeperminuteQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.DegreePerMinute);
+ AssertEx.EqualTolerance(DegreesPerMinuteInOneRadianPerSecond, (double)degreeperminuteQuantity.Value, DegreesPerMinuteTolerance);
+ Assert.Equal(RotationalSpeedUnit.DegreePerMinute, degreeperminuteQuantity.Unit);
+
+ var degreepersecondQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.DegreePerSecond);
+ AssertEx.EqualTolerance(DegreesPerSecondInOneRadianPerSecond, (double)degreepersecondQuantity.Value, DegreesPerSecondTolerance);
+ Assert.Equal(RotationalSpeedUnit.DegreePerSecond, degreepersecondQuantity.Unit);
+
+ var microdegreepersecondQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.MicrodegreePerSecond);
+ AssertEx.EqualTolerance(MicrodegreesPerSecondInOneRadianPerSecond, (double)microdegreepersecondQuantity.Value, MicrodegreesPerSecondTolerance);
+ Assert.Equal(RotationalSpeedUnit.MicrodegreePerSecond, microdegreepersecondQuantity.Unit);
+
+ var microradianpersecondQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.MicroradianPerSecond);
+ AssertEx.EqualTolerance(MicroradiansPerSecondInOneRadianPerSecond, (double)microradianpersecondQuantity.Value, MicroradiansPerSecondTolerance);
+ Assert.Equal(RotationalSpeedUnit.MicroradianPerSecond, microradianpersecondQuantity.Unit);
+
+ var millidegreepersecondQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.MillidegreePerSecond);
+ AssertEx.EqualTolerance(MillidegreesPerSecondInOneRadianPerSecond, (double)millidegreepersecondQuantity.Value, MillidegreesPerSecondTolerance);
+ Assert.Equal(RotationalSpeedUnit.MillidegreePerSecond, millidegreepersecondQuantity.Unit);
+
+ var milliradianpersecondQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.MilliradianPerSecond);
+ AssertEx.EqualTolerance(MilliradiansPerSecondInOneRadianPerSecond, (double)milliradianpersecondQuantity.Value, MilliradiansPerSecondTolerance);
+ Assert.Equal(RotationalSpeedUnit.MilliradianPerSecond, milliradianpersecondQuantity.Unit);
+
+ var nanodegreepersecondQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.NanodegreePerSecond);
+ AssertEx.EqualTolerance(NanodegreesPerSecondInOneRadianPerSecond, (double)nanodegreepersecondQuantity.Value, NanodegreesPerSecondTolerance);
+ Assert.Equal(RotationalSpeedUnit.NanodegreePerSecond, nanodegreepersecondQuantity.Unit);
+
+ var nanoradianpersecondQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.NanoradianPerSecond);
+ AssertEx.EqualTolerance(NanoradiansPerSecondInOneRadianPerSecond, (double)nanoradianpersecondQuantity.Value, NanoradiansPerSecondTolerance);
+ Assert.Equal(RotationalSpeedUnit.NanoradianPerSecond, nanoradianpersecondQuantity.Unit);
+
+ var radianpersecondQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.RadianPerSecond);
+ AssertEx.EqualTolerance(RadiansPerSecondInOneRadianPerSecond, (double)radianpersecondQuantity.Value, RadiansPerSecondTolerance);
+ Assert.Equal(RotationalSpeedUnit.RadianPerSecond, radianpersecondQuantity.Unit);
+
+ var revolutionperminuteQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.RevolutionPerMinute);
+ AssertEx.EqualTolerance(RevolutionsPerMinuteInOneRadianPerSecond, (double)revolutionperminuteQuantity.Value, RevolutionsPerMinuteTolerance);
+ Assert.Equal(RotationalSpeedUnit.RevolutionPerMinute, revolutionperminuteQuantity.Unit);
+
+ var revolutionpersecondQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.RevolutionPerSecond);
+ AssertEx.EqualTolerance(RevolutionsPerSecondInOneRadianPerSecond, (double)revolutionpersecondQuantity.Value, RevolutionsPerSecondTolerance);
+ Assert.Equal(RotationalSpeedUnit.RevolutionPerSecond, revolutionpersecondQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/RotationalStiffnessPerLengthTestsBase.g.cs
index 730715ef79..ea007e3583 100644
--- a/UnitsNet.Tests/GeneratedCode/RotationalStiffnessPerLengthTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/RotationalStiffnessPerLengthTestsBase.g.cs
@@ -88,6 +88,24 @@ public void As()
AssertEx.EqualTolerance(NewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.As(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter), NewtonMetersPerRadianPerMeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1);
+
+ var kilonewtonmeterperradianpermeterQuantity = newtonmeterperradianpermeter.ToUnit(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter);
+ AssertEx.EqualTolerance(KilonewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, (double)kilonewtonmeterperradianpermeterQuantity.Value, KilonewtonMetersPerRadianPerMeterTolerance);
+ Assert.Equal(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, kilonewtonmeterperradianpermeterQuantity.Unit);
+
+ var meganewtonmeterperradianpermeterQuantity = newtonmeterperradianpermeter.ToUnit(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter);
+ AssertEx.EqualTolerance(MeganewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, (double)meganewtonmeterperradianpermeterQuantity.Value, MeganewtonMetersPerRadianPerMeterTolerance);
+ Assert.Equal(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, meganewtonmeterperradianpermeterQuantity.Unit);
+
+ var newtonmeterperradianpermeterQuantity = newtonmeterperradianpermeter.ToUnit(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter);
+ AssertEx.EqualTolerance(NewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, (double)newtonmeterperradianpermeterQuantity.Value, NewtonMetersPerRadianPerMeterTolerance);
+ Assert.Equal(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, newtonmeterperradianpermeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/RotationalStiffnessTestsBase.g.cs
index a9e7ffdadc..5788c2c0c5 100644
--- a/UnitsNet.Tests/GeneratedCode/RotationalStiffnessTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/RotationalStiffnessTestsBase.g.cs
@@ -88,6 +88,24 @@ public void As()
AssertEx.EqualTolerance(NewtonMetersPerRadianInOneNewtonMeterPerRadian, newtonmeterperradian.As(RotationalStiffnessUnit.NewtonMeterPerRadian), NewtonMetersPerRadianTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1);
+
+ var kilonewtonmeterperradianQuantity = newtonmeterperradian.ToUnit(RotationalStiffnessUnit.KilonewtonMeterPerRadian);
+ AssertEx.EqualTolerance(KilonewtonMetersPerRadianInOneNewtonMeterPerRadian, (double)kilonewtonmeterperradianQuantity.Value, KilonewtonMetersPerRadianTolerance);
+ Assert.Equal(RotationalStiffnessUnit.KilonewtonMeterPerRadian, kilonewtonmeterperradianQuantity.Unit);
+
+ var meganewtonmeterperradianQuantity = newtonmeterperradian.ToUnit(RotationalStiffnessUnit.MeganewtonMeterPerRadian);
+ AssertEx.EqualTolerance(MeganewtonMetersPerRadianInOneNewtonMeterPerRadian, (double)meganewtonmeterperradianQuantity.Value, MeganewtonMetersPerRadianTolerance);
+ Assert.Equal(RotationalStiffnessUnit.MeganewtonMeterPerRadian, meganewtonmeterperradianQuantity.Unit);
+
+ var newtonmeterperradianQuantity = newtonmeterperradian.ToUnit(RotationalStiffnessUnit.NewtonMeterPerRadian);
+ AssertEx.EqualTolerance(NewtonMetersPerRadianInOneNewtonMeterPerRadian, (double)newtonmeterperradianQuantity.Value, NewtonMetersPerRadianTolerance);
+ Assert.Equal(RotationalStiffnessUnit.NewtonMeterPerRadian, newtonmeterperradianQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/SolidAngleTestsBase.g.cs
index a9c77ded3b..4b7e5118f2 100644
--- a/UnitsNet.Tests/GeneratedCode/SolidAngleTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/SolidAngleTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(SteradiansInOneSteradian, steradian.As(SolidAngleUnit.Steradian), SteradiansTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var steradian = SolidAngle.FromSteradians(1);
+
+ var steradianQuantity = steradian.ToUnit(SolidAngleUnit.Steradian);
+ AssertEx.EqualTolerance(SteradiansInOneSteradian, (double)steradianQuantity.Value, SteradiansTolerance);
+ Assert.Equal(SolidAngleUnit.Steradian, steradianQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/SpecificEnergyTestsBase.g.cs
index 6d4fb73cd7..46369f7b4a 100644
--- a/UnitsNet.Tests/GeneratedCode/SpecificEnergyTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/SpecificEnergyTestsBase.g.cs
@@ -113,6 +113,44 @@ public void As()
AssertEx.EqualTolerance(WattHoursPerKilogramInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.WattHourPerKilogram), WattHoursPerKilogramTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1);
+
+ var caloriepergramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.CaloriePerGram);
+ AssertEx.EqualTolerance(CaloriesPerGramInOneJoulePerKilogram, (double)caloriepergramQuantity.Value, CaloriesPerGramTolerance);
+ Assert.Equal(SpecificEnergyUnit.CaloriePerGram, caloriepergramQuantity.Unit);
+
+ var jouleperkilogramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.JoulePerKilogram);
+ AssertEx.EqualTolerance(JoulesPerKilogramInOneJoulePerKilogram, (double)jouleperkilogramQuantity.Value, JoulesPerKilogramTolerance);
+ Assert.Equal(SpecificEnergyUnit.JoulePerKilogram, jouleperkilogramQuantity.Unit);
+
+ var kilocaloriepergramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.KilocaloriePerGram);
+ AssertEx.EqualTolerance(KilocaloriesPerGramInOneJoulePerKilogram, (double)kilocaloriepergramQuantity.Value, KilocaloriesPerGramTolerance);
+ Assert.Equal(SpecificEnergyUnit.KilocaloriePerGram, kilocaloriepergramQuantity.Unit);
+
+ var kilojouleperkilogramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.KilojoulePerKilogram);
+ AssertEx.EqualTolerance(KilojoulesPerKilogramInOneJoulePerKilogram, (double)kilojouleperkilogramQuantity.Value, KilojoulesPerKilogramTolerance);
+ Assert.Equal(SpecificEnergyUnit.KilojoulePerKilogram, kilojouleperkilogramQuantity.Unit);
+
+ var kilowatthourperkilogramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.KilowattHourPerKilogram);
+ AssertEx.EqualTolerance(KilowattHoursPerKilogramInOneJoulePerKilogram, (double)kilowatthourperkilogramQuantity.Value, KilowattHoursPerKilogramTolerance);
+ Assert.Equal(SpecificEnergyUnit.KilowattHourPerKilogram, kilowatthourperkilogramQuantity.Unit);
+
+ var megajouleperkilogramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.MegajoulePerKilogram);
+ AssertEx.EqualTolerance(MegajoulesPerKilogramInOneJoulePerKilogram, (double)megajouleperkilogramQuantity.Value, MegajoulesPerKilogramTolerance);
+ Assert.Equal(SpecificEnergyUnit.MegajoulePerKilogram, megajouleperkilogramQuantity.Unit);
+
+ var megawatthourperkilogramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.MegawattHourPerKilogram);
+ AssertEx.EqualTolerance(MegawattHoursPerKilogramInOneJoulePerKilogram, (double)megawatthourperkilogramQuantity.Value, MegawattHoursPerKilogramTolerance);
+ Assert.Equal(SpecificEnergyUnit.MegawattHourPerKilogram, megawatthourperkilogramQuantity.Unit);
+
+ var watthourperkilogramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.WattHourPerKilogram);
+ AssertEx.EqualTolerance(WattHoursPerKilogramInOneJoulePerKilogram, (double)watthourperkilogramQuantity.Value, WattHoursPerKilogramTolerance);
+ Assert.Equal(SpecificEnergyUnit.WattHourPerKilogram, watthourperkilogramQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/SpecificEntropyTestsBase.g.cs
index 87cf3a8c49..5ea6175c54 100644
--- a/UnitsNet.Tests/GeneratedCode/SpecificEntropyTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/SpecificEntropyTestsBase.g.cs
@@ -113,6 +113,44 @@ public void As()
AssertEx.EqualTolerance(MegajoulesPerKilogramKelvinInOneJoulePerKilogramKelvin, jouleperkilogramkelvin.As(SpecificEntropyUnit.MegajoulePerKilogramKelvin), MegajoulesPerKilogramKelvinTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1);
+
+ var caloriepergramkelvinQuantity = jouleperkilogramkelvin.ToUnit(SpecificEntropyUnit.CaloriePerGramKelvin);
+ AssertEx.EqualTolerance(CaloriesPerGramKelvinInOneJoulePerKilogramKelvin, (double)caloriepergramkelvinQuantity.Value, CaloriesPerGramKelvinTolerance);
+ Assert.Equal(SpecificEntropyUnit.CaloriePerGramKelvin, caloriepergramkelvinQuantity.Unit);
+
+ var jouleperkilogramdegreecelsiusQuantity = jouleperkilogramkelvin.ToUnit(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius);
+ AssertEx.EqualTolerance(JoulesPerKilogramDegreeCelsiusInOneJoulePerKilogramKelvin, (double)jouleperkilogramdegreecelsiusQuantity.Value, JoulesPerKilogramDegreeCelsiusTolerance);
+ Assert.Equal(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, jouleperkilogramdegreecelsiusQuantity.Unit);
+
+ var jouleperkilogramkelvinQuantity = jouleperkilogramkelvin.ToUnit(SpecificEntropyUnit.JoulePerKilogramKelvin);
+ AssertEx.EqualTolerance(JoulesPerKilogramKelvinInOneJoulePerKilogramKelvin, (double)jouleperkilogramkelvinQuantity.Value, JoulesPerKilogramKelvinTolerance);
+ Assert.Equal(SpecificEntropyUnit.JoulePerKilogramKelvin, jouleperkilogramkelvinQuantity.Unit);
+
+ var kilocaloriepergramkelvinQuantity = jouleperkilogramkelvin.ToUnit(SpecificEntropyUnit.KilocaloriePerGramKelvin);
+ AssertEx.EqualTolerance(KilocaloriesPerGramKelvinInOneJoulePerKilogramKelvin, (double)kilocaloriepergramkelvinQuantity.Value, KilocaloriesPerGramKelvinTolerance);
+ Assert.Equal(SpecificEntropyUnit.KilocaloriePerGramKelvin, kilocaloriepergramkelvinQuantity.Unit);
+
+ var kilojouleperkilogramdegreecelsiusQuantity = jouleperkilogramkelvin.ToUnit(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius);
+ AssertEx.EqualTolerance(KilojoulesPerKilogramDegreeCelsiusInOneJoulePerKilogramKelvin, (double)kilojouleperkilogramdegreecelsiusQuantity.Value, KilojoulesPerKilogramDegreeCelsiusTolerance);
+ Assert.Equal(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, kilojouleperkilogramdegreecelsiusQuantity.Unit);
+
+ var kilojouleperkilogramkelvinQuantity = jouleperkilogramkelvin.ToUnit(SpecificEntropyUnit.KilojoulePerKilogramKelvin);
+ AssertEx.EqualTolerance(KilojoulesPerKilogramKelvinInOneJoulePerKilogramKelvin, (double)kilojouleperkilogramkelvinQuantity.Value, KilojoulesPerKilogramKelvinTolerance);
+ Assert.Equal(SpecificEntropyUnit.KilojoulePerKilogramKelvin, kilojouleperkilogramkelvinQuantity.Unit);
+
+ var megajouleperkilogramdegreecelsiusQuantity = jouleperkilogramkelvin.ToUnit(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius);
+ AssertEx.EqualTolerance(MegajoulesPerKilogramDegreeCelsiusInOneJoulePerKilogramKelvin, (double)megajouleperkilogramdegreecelsiusQuantity.Value, MegajoulesPerKilogramDegreeCelsiusTolerance);
+ Assert.Equal(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, megajouleperkilogramdegreecelsiusQuantity.Unit);
+
+ var megajouleperkilogramkelvinQuantity = jouleperkilogramkelvin.ToUnit(SpecificEntropyUnit.MegajoulePerKilogramKelvin);
+ AssertEx.EqualTolerance(MegajoulesPerKilogramKelvinInOneJoulePerKilogramKelvin, (double)megajouleperkilogramkelvinQuantity.Value, MegajoulesPerKilogramKelvinTolerance);
+ Assert.Equal(SpecificEntropyUnit.MegajoulePerKilogramKelvin, megajouleperkilogramkelvinQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/SpecificVolumeTestsBase.g.cs
index a8abe93bc9..43de8dbddc 100644
--- a/UnitsNet.Tests/GeneratedCode/SpecificVolumeTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/SpecificVolumeTestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(CubicMetersPerKilogramInOneCubicMeterPerKilogram, cubicmeterperkilogram.As(SpecificVolumeUnit.CubicMeterPerKilogram), CubicMetersPerKilogramTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1);
+
+ var cubicmeterperkilogramQuantity = cubicmeterperkilogram.ToUnit(SpecificVolumeUnit.CubicMeterPerKilogram);
+ AssertEx.EqualTolerance(CubicMetersPerKilogramInOneCubicMeterPerKilogram, (double)cubicmeterperkilogramQuantity.Value, CubicMetersPerKilogramTolerance);
+ Assert.Equal(SpecificVolumeUnit.CubicMeterPerKilogram, cubicmeterperkilogramQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/SpecificWeightTestsBase.g.cs
index de007b84ce..f2978711dc 100644
--- a/UnitsNet.Tests/GeneratedCode/SpecificWeightTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/SpecificWeightTestsBase.g.cs
@@ -158,6 +158,80 @@ public void As()
AssertEx.EqualTolerance(TonnesForcePerCubicMillimeterInOneNewtonPerCubicMeter, newtonpercubicmeter.As(SpecificWeightUnit.TonneForcePerCubicMillimeter), TonnesForcePerCubicMillimeterTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1);
+
+ var kilogramforcepercubiccentimeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.KilogramForcePerCubicCentimeter);
+ AssertEx.EqualTolerance(KilogramsForcePerCubicCentimeterInOneNewtonPerCubicMeter, (double)kilogramforcepercubiccentimeterQuantity.Value, KilogramsForcePerCubicCentimeterTolerance);
+ Assert.Equal(SpecificWeightUnit.KilogramForcePerCubicCentimeter, kilogramforcepercubiccentimeterQuantity.Unit);
+
+ var kilogramforcepercubicmeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.KilogramForcePerCubicMeter);
+ AssertEx.EqualTolerance(KilogramsForcePerCubicMeterInOneNewtonPerCubicMeter, (double)kilogramforcepercubicmeterQuantity.Value, KilogramsForcePerCubicMeterTolerance);
+ Assert.Equal(SpecificWeightUnit.KilogramForcePerCubicMeter, kilogramforcepercubicmeterQuantity.Unit);
+
+ var kilogramforcepercubicmillimeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.KilogramForcePerCubicMillimeter);
+ AssertEx.EqualTolerance(KilogramsForcePerCubicMillimeterInOneNewtonPerCubicMeter, (double)kilogramforcepercubicmillimeterQuantity.Value, KilogramsForcePerCubicMillimeterTolerance);
+ Assert.Equal(SpecificWeightUnit.KilogramForcePerCubicMillimeter, kilogramforcepercubicmillimeterQuantity.Unit);
+
+ var kilonewtonpercubiccentimeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.KilonewtonPerCubicCentimeter);
+ AssertEx.EqualTolerance(KilonewtonsPerCubicCentimeterInOneNewtonPerCubicMeter, (double)kilonewtonpercubiccentimeterQuantity.Value, KilonewtonsPerCubicCentimeterTolerance);
+ Assert.Equal(SpecificWeightUnit.KilonewtonPerCubicCentimeter, kilonewtonpercubiccentimeterQuantity.Unit);
+
+ var kilonewtonpercubicmeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.KilonewtonPerCubicMeter);
+ AssertEx.EqualTolerance(KilonewtonsPerCubicMeterInOneNewtonPerCubicMeter, (double)kilonewtonpercubicmeterQuantity.Value, KilonewtonsPerCubicMeterTolerance);
+ Assert.Equal(SpecificWeightUnit.KilonewtonPerCubicMeter, kilonewtonpercubicmeterQuantity.Unit);
+
+ var kilonewtonpercubicmillimeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.KilonewtonPerCubicMillimeter);
+ AssertEx.EqualTolerance(KilonewtonsPerCubicMillimeterInOneNewtonPerCubicMeter, (double)kilonewtonpercubicmillimeterQuantity.Value, KilonewtonsPerCubicMillimeterTolerance);
+ Assert.Equal(SpecificWeightUnit.KilonewtonPerCubicMillimeter, kilonewtonpercubicmillimeterQuantity.Unit);
+
+ var kilopoundforcepercubicfootQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.KilopoundForcePerCubicFoot);
+ AssertEx.EqualTolerance(KilopoundsForcePerCubicFootInOneNewtonPerCubicMeter, (double)kilopoundforcepercubicfootQuantity.Value, KilopoundsForcePerCubicFootTolerance);
+ Assert.Equal(SpecificWeightUnit.KilopoundForcePerCubicFoot, kilopoundforcepercubicfootQuantity.Unit);
+
+ var kilopoundforcepercubicinchQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.KilopoundForcePerCubicInch);
+ AssertEx.EqualTolerance(KilopoundsForcePerCubicInchInOneNewtonPerCubicMeter, (double)kilopoundforcepercubicinchQuantity.Value, KilopoundsForcePerCubicInchTolerance);
+ Assert.Equal(SpecificWeightUnit.KilopoundForcePerCubicInch, kilopoundforcepercubicinchQuantity.Unit);
+
+ var meganewtonpercubicmeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.MeganewtonPerCubicMeter);
+ AssertEx.EqualTolerance(MeganewtonsPerCubicMeterInOneNewtonPerCubicMeter, (double)meganewtonpercubicmeterQuantity.Value, MeganewtonsPerCubicMeterTolerance);
+ Assert.Equal(SpecificWeightUnit.MeganewtonPerCubicMeter, meganewtonpercubicmeterQuantity.Unit);
+
+ var newtonpercubiccentimeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.NewtonPerCubicCentimeter);
+ AssertEx.EqualTolerance(NewtonsPerCubicCentimeterInOneNewtonPerCubicMeter, (double)newtonpercubiccentimeterQuantity.Value, NewtonsPerCubicCentimeterTolerance);
+ Assert.Equal(SpecificWeightUnit.NewtonPerCubicCentimeter, newtonpercubiccentimeterQuantity.Unit);
+
+ var newtonpercubicmeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.NewtonPerCubicMeter);
+ AssertEx.EqualTolerance(NewtonsPerCubicMeterInOneNewtonPerCubicMeter, (double)newtonpercubicmeterQuantity.Value, NewtonsPerCubicMeterTolerance);
+ Assert.Equal(SpecificWeightUnit.NewtonPerCubicMeter, newtonpercubicmeterQuantity.Unit);
+
+ var newtonpercubicmillimeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.NewtonPerCubicMillimeter);
+ AssertEx.EqualTolerance(NewtonsPerCubicMillimeterInOneNewtonPerCubicMeter, (double)newtonpercubicmillimeterQuantity.Value, NewtonsPerCubicMillimeterTolerance);
+ Assert.Equal(SpecificWeightUnit.NewtonPerCubicMillimeter, newtonpercubicmillimeterQuantity.Unit);
+
+ var poundforcepercubicfootQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.PoundForcePerCubicFoot);
+ AssertEx.EqualTolerance(PoundsForcePerCubicFootInOneNewtonPerCubicMeter, (double)poundforcepercubicfootQuantity.Value, PoundsForcePerCubicFootTolerance);
+ Assert.Equal(SpecificWeightUnit.PoundForcePerCubicFoot, poundforcepercubicfootQuantity.Unit);
+
+ var poundforcepercubicinchQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.PoundForcePerCubicInch);
+ AssertEx.EqualTolerance(PoundsForcePerCubicInchInOneNewtonPerCubicMeter, (double)poundforcepercubicinchQuantity.Value, PoundsForcePerCubicInchTolerance);
+ Assert.Equal(SpecificWeightUnit.PoundForcePerCubicInch, poundforcepercubicinchQuantity.Unit);
+
+ var tonneforcepercubiccentimeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.TonneForcePerCubicCentimeter);
+ AssertEx.EqualTolerance(TonnesForcePerCubicCentimeterInOneNewtonPerCubicMeter, (double)tonneforcepercubiccentimeterQuantity.Value, TonnesForcePerCubicCentimeterTolerance);
+ Assert.Equal(SpecificWeightUnit.TonneForcePerCubicCentimeter, tonneforcepercubiccentimeterQuantity.Unit);
+
+ var tonneforcepercubicmeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.TonneForcePerCubicMeter);
+ AssertEx.EqualTolerance(TonnesForcePerCubicMeterInOneNewtonPerCubicMeter, (double)tonneforcepercubicmeterQuantity.Value, TonnesForcePerCubicMeterTolerance);
+ Assert.Equal(SpecificWeightUnit.TonneForcePerCubicMeter, tonneforcepercubicmeterQuantity.Unit);
+
+ var tonneforcepercubicmillimeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.TonneForcePerCubicMillimeter);
+ AssertEx.EqualTolerance(TonnesForcePerCubicMillimeterInOneNewtonPerCubicMeter, (double)tonneforcepercubicmillimeterQuantity.Value, TonnesForcePerCubicMillimeterTolerance);
+ Assert.Equal(SpecificWeightUnit.TonneForcePerCubicMillimeter, tonneforcepercubicmillimeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/SpeedTestsBase.g.cs
index c71e370381..04ab7bf938 100644
--- a/UnitsNet.Tests/GeneratedCode/SpeedTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/SpeedTestsBase.g.cs
@@ -233,6 +233,140 @@ public void As()
AssertEx.EqualTolerance(YardsPerSecondInOneMeterPerSecond, meterpersecond.As(SpeedUnit.YardPerSecond), YardsPerSecondTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var meterpersecond = Speed.FromMetersPerSecond(1);
+
+ var centimeterperhourQuantity = meterpersecond.ToUnit(SpeedUnit.CentimeterPerHour);
+ AssertEx.EqualTolerance(CentimetersPerHourInOneMeterPerSecond, (double)centimeterperhourQuantity.Value, CentimetersPerHourTolerance);
+ Assert.Equal(SpeedUnit.CentimeterPerHour, centimeterperhourQuantity.Unit);
+
+ var centimeterperminuteQuantity = meterpersecond.ToUnit(SpeedUnit.CentimeterPerMinute);
+ AssertEx.EqualTolerance(CentimetersPerMinutesInOneMeterPerSecond, (double)centimeterperminuteQuantity.Value, CentimetersPerMinutesTolerance);
+ Assert.Equal(SpeedUnit.CentimeterPerMinute, centimeterperminuteQuantity.Unit);
+
+ var centimeterpersecondQuantity = meterpersecond.ToUnit(SpeedUnit.CentimeterPerSecond);
+ AssertEx.EqualTolerance(CentimetersPerSecondInOneMeterPerSecond, (double)centimeterpersecondQuantity.Value, CentimetersPerSecondTolerance);
+ Assert.Equal(SpeedUnit.CentimeterPerSecond, centimeterpersecondQuantity.Unit);
+
+ var decimeterperminuteQuantity = meterpersecond.ToUnit(SpeedUnit.DecimeterPerMinute);
+ AssertEx.EqualTolerance(DecimetersPerMinutesInOneMeterPerSecond, (double)decimeterperminuteQuantity.Value, DecimetersPerMinutesTolerance);
+ Assert.Equal(SpeedUnit.DecimeterPerMinute, decimeterperminuteQuantity.Unit);
+
+ var decimeterpersecondQuantity = meterpersecond.ToUnit(SpeedUnit.DecimeterPerSecond);
+ AssertEx.EqualTolerance(DecimetersPerSecondInOneMeterPerSecond, (double)decimeterpersecondQuantity.Value, DecimetersPerSecondTolerance);
+ Assert.Equal(SpeedUnit.DecimeterPerSecond, decimeterpersecondQuantity.Unit);
+
+ var footperhourQuantity = meterpersecond.ToUnit(SpeedUnit.FootPerHour);
+ AssertEx.EqualTolerance(FeetPerHourInOneMeterPerSecond, (double)footperhourQuantity.Value, FeetPerHourTolerance);
+ Assert.Equal(SpeedUnit.FootPerHour, footperhourQuantity.Unit);
+
+ var footperminuteQuantity = meterpersecond.ToUnit(SpeedUnit.FootPerMinute);
+ AssertEx.EqualTolerance(FeetPerMinuteInOneMeterPerSecond, (double)footperminuteQuantity.Value, FeetPerMinuteTolerance);
+ Assert.Equal(SpeedUnit.FootPerMinute, footperminuteQuantity.Unit);
+
+ var footpersecondQuantity = meterpersecond.ToUnit(SpeedUnit.FootPerSecond);
+ AssertEx.EqualTolerance(FeetPerSecondInOneMeterPerSecond, (double)footpersecondQuantity.Value, FeetPerSecondTolerance);
+ Assert.Equal(SpeedUnit.FootPerSecond, footpersecondQuantity.Unit);
+
+ var inchperhourQuantity = meterpersecond.ToUnit(SpeedUnit.InchPerHour);
+ AssertEx.EqualTolerance(InchesPerHourInOneMeterPerSecond, (double)inchperhourQuantity.Value, InchesPerHourTolerance);
+ Assert.Equal(SpeedUnit.InchPerHour, inchperhourQuantity.Unit);
+
+ var inchperminuteQuantity = meterpersecond.ToUnit(SpeedUnit.InchPerMinute);
+ AssertEx.EqualTolerance(InchesPerMinuteInOneMeterPerSecond, (double)inchperminuteQuantity.Value, InchesPerMinuteTolerance);
+ Assert.Equal(SpeedUnit.InchPerMinute, inchperminuteQuantity.Unit);
+
+ var inchpersecondQuantity = meterpersecond.ToUnit(SpeedUnit.InchPerSecond);
+ AssertEx.EqualTolerance(InchesPerSecondInOneMeterPerSecond, (double)inchpersecondQuantity.Value, InchesPerSecondTolerance);
+ Assert.Equal(SpeedUnit.InchPerSecond, inchpersecondQuantity.Unit);
+
+ var kilometerperhourQuantity = meterpersecond.ToUnit(SpeedUnit.KilometerPerHour);
+ AssertEx.EqualTolerance(KilometersPerHourInOneMeterPerSecond, (double)kilometerperhourQuantity.Value, KilometersPerHourTolerance);
+ Assert.Equal(SpeedUnit.KilometerPerHour, kilometerperhourQuantity.Unit);
+
+ var kilometerperminuteQuantity = meterpersecond.ToUnit(SpeedUnit.KilometerPerMinute);
+ AssertEx.EqualTolerance(KilometersPerMinutesInOneMeterPerSecond, (double)kilometerperminuteQuantity.Value, KilometersPerMinutesTolerance);
+ Assert.Equal(SpeedUnit.KilometerPerMinute, kilometerperminuteQuantity.Unit);
+
+ var kilometerpersecondQuantity = meterpersecond.ToUnit(SpeedUnit.KilometerPerSecond);
+ AssertEx.EqualTolerance(KilometersPerSecondInOneMeterPerSecond, (double)kilometerpersecondQuantity.Value, KilometersPerSecondTolerance);
+ Assert.Equal(SpeedUnit.KilometerPerSecond, kilometerpersecondQuantity.Unit);
+
+ var knotQuantity = meterpersecond.ToUnit(SpeedUnit.Knot);
+ AssertEx.EqualTolerance(KnotsInOneMeterPerSecond, (double)knotQuantity.Value, KnotsTolerance);
+ Assert.Equal(SpeedUnit.Knot, knotQuantity.Unit);
+
+ var meterperhourQuantity = meterpersecond.ToUnit(SpeedUnit.MeterPerHour);
+ AssertEx.EqualTolerance(MetersPerHourInOneMeterPerSecond, (double)meterperhourQuantity.Value, MetersPerHourTolerance);
+ Assert.Equal(SpeedUnit.MeterPerHour, meterperhourQuantity.Unit);
+
+ var meterperminuteQuantity = meterpersecond.ToUnit(SpeedUnit.MeterPerMinute);
+ AssertEx.EqualTolerance(MetersPerMinutesInOneMeterPerSecond, (double)meterperminuteQuantity.Value, MetersPerMinutesTolerance);
+ Assert.Equal(SpeedUnit.MeterPerMinute, meterperminuteQuantity.Unit);
+
+ var meterpersecondQuantity = meterpersecond.ToUnit(SpeedUnit.MeterPerSecond);
+ AssertEx.EqualTolerance(MetersPerSecondInOneMeterPerSecond, (double)meterpersecondQuantity.Value, MetersPerSecondTolerance);
+ Assert.Equal(SpeedUnit.MeterPerSecond, meterpersecondQuantity.Unit);
+
+ var micrometerperminuteQuantity = meterpersecond.ToUnit(SpeedUnit.MicrometerPerMinute);
+ AssertEx.EqualTolerance(MicrometersPerMinutesInOneMeterPerSecond, (double)micrometerperminuteQuantity.Value, MicrometersPerMinutesTolerance);
+ Assert.Equal(SpeedUnit.MicrometerPerMinute, micrometerperminuteQuantity.Unit);
+
+ var micrometerpersecondQuantity = meterpersecond.ToUnit(SpeedUnit.MicrometerPerSecond);
+ AssertEx.EqualTolerance(MicrometersPerSecondInOneMeterPerSecond, (double)micrometerpersecondQuantity.Value, MicrometersPerSecondTolerance);
+ Assert.Equal(SpeedUnit.MicrometerPerSecond, micrometerpersecondQuantity.Unit);
+
+ var mileperhourQuantity = meterpersecond.ToUnit(SpeedUnit.MilePerHour);
+ AssertEx.EqualTolerance(MilesPerHourInOneMeterPerSecond, (double)mileperhourQuantity.Value, MilesPerHourTolerance);
+ Assert.Equal(SpeedUnit.MilePerHour, mileperhourQuantity.Unit);
+
+ var millimeterperhourQuantity = meterpersecond.ToUnit(SpeedUnit.MillimeterPerHour);
+ AssertEx.EqualTolerance(MillimetersPerHourInOneMeterPerSecond, (double)millimeterperhourQuantity.Value, MillimetersPerHourTolerance);
+ Assert.Equal(SpeedUnit.MillimeterPerHour, millimeterperhourQuantity.Unit);
+
+ var millimeterperminuteQuantity = meterpersecond.ToUnit(SpeedUnit.MillimeterPerMinute);
+ AssertEx.EqualTolerance(MillimetersPerMinutesInOneMeterPerSecond, (double)millimeterperminuteQuantity.Value, MillimetersPerMinutesTolerance);
+ Assert.Equal(SpeedUnit.MillimeterPerMinute, millimeterperminuteQuantity.Unit);
+
+ var millimeterpersecondQuantity = meterpersecond.ToUnit(SpeedUnit.MillimeterPerSecond);
+ AssertEx.EqualTolerance(MillimetersPerSecondInOneMeterPerSecond, (double)millimeterpersecondQuantity.Value, MillimetersPerSecondTolerance);
+ Assert.Equal(SpeedUnit.MillimeterPerSecond, millimeterpersecondQuantity.Unit);
+
+ var nanometerperminuteQuantity = meterpersecond.ToUnit(SpeedUnit.NanometerPerMinute);
+ AssertEx.EqualTolerance(NanometersPerMinutesInOneMeterPerSecond, (double)nanometerperminuteQuantity.Value, NanometersPerMinutesTolerance);
+ Assert.Equal(SpeedUnit.NanometerPerMinute, nanometerperminuteQuantity.Unit);
+
+ var nanometerpersecondQuantity = meterpersecond.ToUnit(SpeedUnit.NanometerPerSecond);
+ AssertEx.EqualTolerance(NanometersPerSecondInOneMeterPerSecond, (double)nanometerpersecondQuantity.Value, NanometersPerSecondTolerance);
+ Assert.Equal(SpeedUnit.NanometerPerSecond, nanometerpersecondQuantity.Unit);
+
+ var ussurveyfootperhourQuantity = meterpersecond.ToUnit(SpeedUnit.UsSurveyFootPerHour);
+ AssertEx.EqualTolerance(UsSurveyFeetPerHourInOneMeterPerSecond, (double)ussurveyfootperhourQuantity.Value, UsSurveyFeetPerHourTolerance);
+ Assert.Equal(SpeedUnit.UsSurveyFootPerHour, ussurveyfootperhourQuantity.Unit);
+
+ var ussurveyfootperminuteQuantity = meterpersecond.ToUnit(SpeedUnit.UsSurveyFootPerMinute);
+ AssertEx.EqualTolerance(UsSurveyFeetPerMinuteInOneMeterPerSecond, (double)ussurveyfootperminuteQuantity.Value, UsSurveyFeetPerMinuteTolerance);
+ Assert.Equal(SpeedUnit.UsSurveyFootPerMinute, ussurveyfootperminuteQuantity.Unit);
+
+ var ussurveyfootpersecondQuantity = meterpersecond.ToUnit(SpeedUnit.UsSurveyFootPerSecond);
+ AssertEx.EqualTolerance(UsSurveyFeetPerSecondInOneMeterPerSecond, (double)ussurveyfootpersecondQuantity.Value, UsSurveyFeetPerSecondTolerance);
+ Assert.Equal(SpeedUnit.UsSurveyFootPerSecond, ussurveyfootpersecondQuantity.Unit);
+
+ var yardperhourQuantity = meterpersecond.ToUnit(SpeedUnit.YardPerHour);
+ AssertEx.EqualTolerance(YardsPerHourInOneMeterPerSecond, (double)yardperhourQuantity.Value, YardsPerHourTolerance);
+ Assert.Equal(SpeedUnit.YardPerHour, yardperhourQuantity.Unit);
+
+ var yardperminuteQuantity = meterpersecond.ToUnit(SpeedUnit.YardPerMinute);
+ AssertEx.EqualTolerance(YardsPerMinuteInOneMeterPerSecond, (double)yardperminuteQuantity.Value, YardsPerMinuteTolerance);
+ Assert.Equal(SpeedUnit.YardPerMinute, yardperminuteQuantity.Unit);
+
+ var yardpersecondQuantity = meterpersecond.ToUnit(SpeedUnit.YardPerSecond);
+ AssertEx.EqualTolerance(YardsPerSecondInOneMeterPerSecond, (double)yardpersecondQuantity.Value, YardsPerSecondTolerance);
+ Assert.Equal(SpeedUnit.YardPerSecond, yardpersecondQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TemperatureChangeRateTestsBase.g.cs
index bd878fa709..02494705c1 100644
--- a/UnitsNet.Tests/GeneratedCode/TemperatureChangeRateTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/TemperatureChangeRateTestsBase.g.cs
@@ -123,6 +123,52 @@ public void As()
AssertEx.EqualTolerance(NanodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.As(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond), NanodegreesCelsiusPerSecondTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1);
+
+ var centidegreecelsiuspersecondQuantity = degreecelsiuspersecond.ToUnit(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond);
+ AssertEx.EqualTolerance(CentidegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, (double)centidegreecelsiuspersecondQuantity.Value, CentidegreesCelsiusPerSecondTolerance);
+ Assert.Equal(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, centidegreecelsiuspersecondQuantity.Unit);
+
+ var decadegreecelsiuspersecondQuantity = degreecelsiuspersecond.ToUnit(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond);
+ AssertEx.EqualTolerance(DecadegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, (double)decadegreecelsiuspersecondQuantity.Value, DecadegreesCelsiusPerSecondTolerance);
+ Assert.Equal(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, decadegreecelsiuspersecondQuantity.Unit);
+
+ var decidegreecelsiuspersecondQuantity = degreecelsiuspersecond.ToUnit(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond);
+ AssertEx.EqualTolerance(DecidegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, (double)decidegreecelsiuspersecondQuantity.Value, DecidegreesCelsiusPerSecondTolerance);
+ Assert.Equal(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, decidegreecelsiuspersecondQuantity.Unit);
+
+ var degreecelsiusperminuteQuantity = degreecelsiuspersecond.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerMinute);
+ AssertEx.EqualTolerance(DegreesCelsiusPerMinuteInOneDegreeCelsiusPerSecond, (double)degreecelsiusperminuteQuantity.Value, DegreesCelsiusPerMinuteTolerance);
+ Assert.Equal(TemperatureChangeRateUnit.DegreeCelsiusPerMinute, degreecelsiusperminuteQuantity.Unit);
+
+ var degreecelsiuspersecondQuantity = degreecelsiuspersecond.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerSecond);
+ AssertEx.EqualTolerance(DegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, (double)degreecelsiuspersecondQuantity.Value, DegreesCelsiusPerSecondTolerance);
+ Assert.Equal(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, degreecelsiuspersecondQuantity.Unit);
+
+ var hectodegreecelsiuspersecondQuantity = degreecelsiuspersecond.ToUnit(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond);
+ AssertEx.EqualTolerance(HectodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, (double)hectodegreecelsiuspersecondQuantity.Value, HectodegreesCelsiusPerSecondTolerance);
+ Assert.Equal(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, hectodegreecelsiuspersecondQuantity.Unit);
+
+ var kilodegreecelsiuspersecondQuantity = degreecelsiuspersecond.ToUnit(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond);
+ AssertEx.EqualTolerance(KilodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, (double)kilodegreecelsiuspersecondQuantity.Value, KilodegreesCelsiusPerSecondTolerance);
+ Assert.Equal(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, kilodegreecelsiuspersecondQuantity.Unit);
+
+ var microdegreecelsiuspersecondQuantity = degreecelsiuspersecond.ToUnit(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond);
+ AssertEx.EqualTolerance(MicrodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, (double)microdegreecelsiuspersecondQuantity.Value, MicrodegreesCelsiusPerSecondTolerance);
+ Assert.Equal(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, microdegreecelsiuspersecondQuantity.Unit);
+
+ var millidegreecelsiuspersecondQuantity = degreecelsiuspersecond.ToUnit(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond);
+ AssertEx.EqualTolerance(MillidegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, (double)millidegreecelsiuspersecondQuantity.Value, MillidegreesCelsiusPerSecondTolerance);
+ Assert.Equal(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, millidegreecelsiuspersecondQuantity.Unit);
+
+ var nanodegreecelsiuspersecondQuantity = degreecelsiuspersecond.ToUnit(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond);
+ AssertEx.EqualTolerance(NanodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, (double)nanodegreecelsiuspersecondQuantity.Value, NanodegreesCelsiusPerSecondTolerance);
+ Assert.Equal(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, nanodegreecelsiuspersecondQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TemperatureDeltaTestsBase.g.cs
index f56110c854..7301a34b76 100644
--- a/UnitsNet.Tests/GeneratedCode/TemperatureDeltaTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/TemperatureDeltaTestsBase.g.cs
@@ -153,6 +153,76 @@ public void As()
AssertEx.EqualTolerance(KelvinsDeltaInOneKelvin, kelvin.As(TemperatureDeltaUnit.KelvinDelta), KelvinsDeltaTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var kelvin = TemperatureDelta.FromKelvins(1);
+
+ var degreecelsiusQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeCelsius);
+ AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, (double)degreecelsiusQuantity.Value, DegreesCelsiusTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeCelsius, degreecelsiusQuantity.Unit);
+
+ var degreecelsiusdeltaQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeCelsiusDelta);
+ AssertEx.EqualTolerance(DegreesCelsiusDeltaInOneKelvin, (double)degreecelsiusdeltaQuantity.Value, DegreesCelsiusDeltaTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeCelsiusDelta, degreecelsiusdeltaQuantity.Unit);
+
+ var degreedelisleQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeDelisle);
+ AssertEx.EqualTolerance(DegreesDelisleInOneKelvin, (double)degreedelisleQuantity.Value, DegreesDelisleTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeDelisle, degreedelisleQuantity.Unit);
+
+ var degreedelisledeltaQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeDelisleDelta);
+ AssertEx.EqualTolerance(DegreesDelisleDeltaInOneKelvin, (double)degreedelisledeltaQuantity.Value, DegreesDelisleDeltaTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeDelisleDelta, degreedelisledeltaQuantity.Unit);
+
+ var degreefahrenheitQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeFahrenheit);
+ AssertEx.EqualTolerance(DegreesFahrenheitInOneKelvin, (double)degreefahrenheitQuantity.Value, DegreesFahrenheitTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeFahrenheit, degreefahrenheitQuantity.Unit);
+
+ var degreefahrenheitdeltaQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeFahrenheitDelta);
+ AssertEx.EqualTolerance(DegreesFahrenheitDeltaInOneKelvin, (double)degreefahrenheitdeltaQuantity.Value, DegreesFahrenheitDeltaTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeFahrenheitDelta, degreefahrenheitdeltaQuantity.Unit);
+
+ var degreenewtonQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeNewton);
+ AssertEx.EqualTolerance(DegreesNewtonInOneKelvin, (double)degreenewtonQuantity.Value, DegreesNewtonTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeNewton, degreenewtonQuantity.Unit);
+
+ var degreenewtondeltaQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeNewtonDelta);
+ AssertEx.EqualTolerance(DegreesNewtonDeltaInOneKelvin, (double)degreenewtondeltaQuantity.Value, DegreesNewtonDeltaTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeNewtonDelta, degreenewtondeltaQuantity.Unit);
+
+ var degreerankineQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeRankine);
+ AssertEx.EqualTolerance(DegreesRankineInOneKelvin, (double)degreerankineQuantity.Value, DegreesRankineTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeRankine, degreerankineQuantity.Unit);
+
+ var degreerankinedeltaQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeRankineDelta);
+ AssertEx.EqualTolerance(DegreesRankineDeltaInOneKelvin, (double)degreerankinedeltaQuantity.Value, DegreesRankineDeltaTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeRankineDelta, degreerankinedeltaQuantity.Unit);
+
+ var degreereaumurQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeReaumur);
+ AssertEx.EqualTolerance(DegreesReaumurInOneKelvin, (double)degreereaumurQuantity.Value, DegreesReaumurTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeReaumur, degreereaumurQuantity.Unit);
+
+ var degreereaumurdeltaQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeReaumurDelta);
+ AssertEx.EqualTolerance(DegreesReaumurDeltaInOneKelvin, (double)degreereaumurdeltaQuantity.Value, DegreesReaumurDeltaTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeReaumurDelta, degreereaumurdeltaQuantity.Unit);
+
+ var degreeroemerQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeRoemer);
+ AssertEx.EqualTolerance(DegreesRoemerInOneKelvin, (double)degreeroemerQuantity.Value, DegreesRoemerTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeRoemer, degreeroemerQuantity.Unit);
+
+ var degreeroemerdeltaQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeRoemerDelta);
+ AssertEx.EqualTolerance(DegreesRoemerDeltaInOneKelvin, (double)degreeroemerdeltaQuantity.Value, DegreesRoemerDeltaTolerance);
+ Assert.Equal(TemperatureDeltaUnit.DegreeRoemerDelta, degreeroemerdeltaQuantity.Unit);
+
+ var kelvinQuantity = kelvin.ToUnit(TemperatureDeltaUnit.Kelvin);
+ AssertEx.EqualTolerance(KelvinsInOneKelvin, (double)kelvinQuantity.Value, KelvinsTolerance);
+ Assert.Equal(TemperatureDeltaUnit.Kelvin, kelvinQuantity.Unit);
+
+ var kelvindeltaQuantity = kelvin.ToUnit(TemperatureDeltaUnit.KelvinDelta);
+ AssertEx.EqualTolerance(KelvinsDeltaInOneKelvin, (double)kelvindeltaQuantity.Value, KelvinsDeltaTolerance);
+ Assert.Equal(TemperatureDeltaUnit.KelvinDelta, kelvindeltaQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TemperatureTestsBase.g.cs
index 65d3ff8d17..e994a1d227 100644
--- a/UnitsNet.Tests/GeneratedCode/TemperatureTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/TemperatureTestsBase.g.cs
@@ -113,6 +113,44 @@ public void As()
AssertEx.EqualTolerance(KelvinsInOneKelvin, kelvin.As(TemperatureUnit.Kelvin), KelvinsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var kelvin = Temperature.FromKelvins(1);
+
+ var degreecelsiusQuantity = kelvin.ToUnit(TemperatureUnit.DegreeCelsius);
+ AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, (double)degreecelsiusQuantity.Value, DegreesCelsiusTolerance);
+ Assert.Equal(TemperatureUnit.DegreeCelsius, degreecelsiusQuantity.Unit);
+
+ var degreedelisleQuantity = kelvin.ToUnit(TemperatureUnit.DegreeDelisle);
+ AssertEx.EqualTolerance(DegreesDelisleInOneKelvin, (double)degreedelisleQuantity.Value, DegreesDelisleTolerance);
+ Assert.Equal(TemperatureUnit.DegreeDelisle, degreedelisleQuantity.Unit);
+
+ var degreefahrenheitQuantity = kelvin.ToUnit(TemperatureUnit.DegreeFahrenheit);
+ AssertEx.EqualTolerance(DegreesFahrenheitInOneKelvin, (double)degreefahrenheitQuantity.Value, DegreesFahrenheitTolerance);
+ Assert.Equal(TemperatureUnit.DegreeFahrenheit, degreefahrenheitQuantity.Unit);
+
+ var degreenewtonQuantity = kelvin.ToUnit(TemperatureUnit.DegreeNewton);
+ AssertEx.EqualTolerance(DegreesNewtonInOneKelvin, (double)degreenewtonQuantity.Value, DegreesNewtonTolerance);
+ Assert.Equal(TemperatureUnit.DegreeNewton, degreenewtonQuantity.Unit);
+
+ var degreerankineQuantity = kelvin.ToUnit(TemperatureUnit.DegreeRankine);
+ AssertEx.EqualTolerance(DegreesRankineInOneKelvin, (double)degreerankineQuantity.Value, DegreesRankineTolerance);
+ Assert.Equal(TemperatureUnit.DegreeRankine, degreerankineQuantity.Unit);
+
+ var degreereaumurQuantity = kelvin.ToUnit(TemperatureUnit.DegreeReaumur);
+ AssertEx.EqualTolerance(DegreesReaumurInOneKelvin, (double)degreereaumurQuantity.Value, DegreesReaumurTolerance);
+ Assert.Equal(TemperatureUnit.DegreeReaumur, degreereaumurQuantity.Unit);
+
+ var degreeroemerQuantity = kelvin.ToUnit(TemperatureUnit.DegreeRoemer);
+ AssertEx.EqualTolerance(DegreesRoemerInOneKelvin, (double)degreeroemerQuantity.Value, DegreesRoemerTolerance);
+ Assert.Equal(TemperatureUnit.DegreeRoemer, degreeroemerQuantity.Unit);
+
+ var kelvinQuantity = kelvin.ToUnit(TemperatureUnit.Kelvin);
+ AssertEx.EqualTolerance(KelvinsInOneKelvin, (double)kelvinQuantity.Value, KelvinsTolerance);
+ Assert.Equal(TemperatureUnit.Kelvin, kelvinQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ThermalConductivityTestsBase.g.cs
index 26b0f559b7..fa43c80a6a 100644
--- a/UnitsNet.Tests/GeneratedCode/ThermalConductivityTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ThermalConductivityTestsBase.g.cs
@@ -83,6 +83,20 @@ public void As()
AssertEx.EqualTolerance(WattsPerMeterKelvinInOneWattPerMeterKelvin, wattpermeterkelvin.As(ThermalConductivityUnit.WattPerMeterKelvin), WattsPerMeterKelvinTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1);
+
+ var btuperhourfootfahrenheitQuantity = wattpermeterkelvin.ToUnit(ThermalConductivityUnit.BtuPerHourFootFahrenheit);
+ AssertEx.EqualTolerance(BtusPerHourFootFahrenheitInOneWattPerMeterKelvin, (double)btuperhourfootfahrenheitQuantity.Value, BtusPerHourFootFahrenheitTolerance);
+ Assert.Equal(ThermalConductivityUnit.BtuPerHourFootFahrenheit, btuperhourfootfahrenheitQuantity.Unit);
+
+ var wattpermeterkelvinQuantity = wattpermeterkelvin.ToUnit(ThermalConductivityUnit.WattPerMeterKelvin);
+ AssertEx.EqualTolerance(WattsPerMeterKelvinInOneWattPerMeterKelvin, (double)wattpermeterkelvinQuantity.Value, WattsPerMeterKelvinTolerance);
+ Assert.Equal(ThermalConductivityUnit.WattPerMeterKelvin, wattpermeterkelvinQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ThermalResistanceTestsBase.g.cs
index 941b384cf8..59361b3451 100644
--- a/UnitsNet.Tests/GeneratedCode/ThermalResistanceTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/ThermalResistanceTestsBase.g.cs
@@ -98,6 +98,32 @@ public void As()
AssertEx.EqualTolerance(SquareMeterKelvinsPerKilowattInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.As(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt), SquareMeterKelvinsPerKilowattTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1);
+
+ var hoursquarefeetdegreefahrenheitperbtuQuantity = squaremeterkelvinperkilowatt.ToUnit(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu);
+ AssertEx.EqualTolerance(HourSquareFeetDegreesFahrenheitPerBtuInOneSquareMeterKelvinPerKilowatt, (double)hoursquarefeetdegreefahrenheitperbtuQuantity.Value, HourSquareFeetDegreesFahrenheitPerBtuTolerance);
+ Assert.Equal(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, hoursquarefeetdegreefahrenheitperbtuQuantity.Unit);
+
+ var squarecentimeterhourdegreecelsiusperkilocalorieQuantity = squaremeterkelvinperkilowatt.ToUnit(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie);
+ AssertEx.EqualTolerance(SquareCentimeterHourDegreesCelsiusPerKilocalorieInOneSquareMeterKelvinPerKilowatt, (double)squarecentimeterhourdegreecelsiusperkilocalorieQuantity.Value, SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance);
+ Assert.Equal(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, squarecentimeterhourdegreecelsiusperkilocalorieQuantity.Unit);
+
+ var squarecentimeterkelvinperwattQuantity = squaremeterkelvinperkilowatt.ToUnit(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt);
+ AssertEx.EqualTolerance(SquareCentimeterKelvinsPerWattInOneSquareMeterKelvinPerKilowatt, (double)squarecentimeterkelvinperwattQuantity.Value, SquareCentimeterKelvinsPerWattTolerance);
+ Assert.Equal(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, squarecentimeterkelvinperwattQuantity.Unit);
+
+ var squaremeterdegreecelsiusperwattQuantity = squaremeterkelvinperkilowatt.ToUnit(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt);
+ AssertEx.EqualTolerance(SquareMeterDegreesCelsiusPerWattInOneSquareMeterKelvinPerKilowatt, (double)squaremeterdegreecelsiusperwattQuantity.Value, SquareMeterDegreesCelsiusPerWattTolerance);
+ Assert.Equal(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, squaremeterdegreecelsiusperwattQuantity.Unit);
+
+ var squaremeterkelvinperkilowattQuantity = squaremeterkelvinperkilowatt.ToUnit(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt);
+ AssertEx.EqualTolerance(SquareMeterKelvinsPerKilowattInOneSquareMeterKelvinPerKilowatt, (double)squaremeterkelvinperkilowattQuantity.Value, SquareMeterKelvinsPerKilowattTolerance);
+ Assert.Equal(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowattQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TorqueTestsBase.g.cs
index 6eae8d9ab2..0298718a6a 100644
--- a/UnitsNet.Tests/GeneratedCode/TorqueTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/TorqueTestsBase.g.cs
@@ -178,6 +178,96 @@ public void As()
AssertEx.EqualTolerance(TonneForceMillimetersInOneNewtonMeter, newtonmeter.As(TorqueUnit.TonneForceMillimeter), TonneForceMillimetersTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var newtonmeter = Torque.FromNewtonMeters(1);
+
+ var kilogramforcecentimeterQuantity = newtonmeter.ToUnit(TorqueUnit.KilogramForceCentimeter);
+ AssertEx.EqualTolerance(KilogramForceCentimetersInOneNewtonMeter, (double)kilogramforcecentimeterQuantity.Value, KilogramForceCentimetersTolerance);
+ Assert.Equal(TorqueUnit.KilogramForceCentimeter, kilogramforcecentimeterQuantity.Unit);
+
+ var kilogramforcemeterQuantity = newtonmeter.ToUnit(TorqueUnit.KilogramForceMeter);
+ AssertEx.EqualTolerance(KilogramForceMetersInOneNewtonMeter, (double)kilogramforcemeterQuantity.Value, KilogramForceMetersTolerance);
+ Assert.Equal(TorqueUnit.KilogramForceMeter, kilogramforcemeterQuantity.Unit);
+
+ var kilogramforcemillimeterQuantity = newtonmeter.ToUnit(TorqueUnit.KilogramForceMillimeter);
+ AssertEx.EqualTolerance(KilogramForceMillimetersInOneNewtonMeter, (double)kilogramforcemillimeterQuantity.Value, KilogramForceMillimetersTolerance);
+ Assert.Equal(TorqueUnit.KilogramForceMillimeter, kilogramforcemillimeterQuantity.Unit);
+
+ var kilonewtoncentimeterQuantity = newtonmeter.ToUnit(TorqueUnit.KilonewtonCentimeter);
+ AssertEx.EqualTolerance(KilonewtonCentimetersInOneNewtonMeter, (double)kilonewtoncentimeterQuantity.Value, KilonewtonCentimetersTolerance);
+ Assert.Equal(TorqueUnit.KilonewtonCentimeter, kilonewtoncentimeterQuantity.Unit);
+
+ var kilonewtonmeterQuantity = newtonmeter.ToUnit(TorqueUnit.KilonewtonMeter);
+ AssertEx.EqualTolerance(KilonewtonMetersInOneNewtonMeter, (double)kilonewtonmeterQuantity.Value, KilonewtonMetersTolerance);
+ Assert.Equal(TorqueUnit.KilonewtonMeter, kilonewtonmeterQuantity.Unit);
+
+ var kilonewtonmillimeterQuantity = newtonmeter.ToUnit(TorqueUnit.KilonewtonMillimeter);
+ AssertEx.EqualTolerance(KilonewtonMillimetersInOneNewtonMeter, (double)kilonewtonmillimeterQuantity.Value, KilonewtonMillimetersTolerance);
+ Assert.Equal(TorqueUnit.KilonewtonMillimeter, kilonewtonmillimeterQuantity.Unit);
+
+ var kilopoundforcefootQuantity = newtonmeter.ToUnit(TorqueUnit.KilopoundForceFoot);
+ AssertEx.EqualTolerance(KilopoundForceFeetInOneNewtonMeter, (double)kilopoundforcefootQuantity.Value, KilopoundForceFeetTolerance);
+ Assert.Equal(TorqueUnit.KilopoundForceFoot, kilopoundforcefootQuantity.Unit);
+
+ var kilopoundforceinchQuantity = newtonmeter.ToUnit(TorqueUnit.KilopoundForceInch);
+ AssertEx.EqualTolerance(KilopoundForceInchesInOneNewtonMeter, (double)kilopoundforceinchQuantity.Value, KilopoundForceInchesTolerance);
+ Assert.Equal(TorqueUnit.KilopoundForceInch, kilopoundforceinchQuantity.Unit);
+
+ var meganewtoncentimeterQuantity = newtonmeter.ToUnit(TorqueUnit.MeganewtonCentimeter);
+ AssertEx.EqualTolerance(MeganewtonCentimetersInOneNewtonMeter, (double)meganewtoncentimeterQuantity.Value, MeganewtonCentimetersTolerance);
+ Assert.Equal(TorqueUnit.MeganewtonCentimeter, meganewtoncentimeterQuantity.Unit);
+
+ var meganewtonmeterQuantity = newtonmeter.ToUnit(TorqueUnit.MeganewtonMeter);
+ AssertEx.EqualTolerance(MeganewtonMetersInOneNewtonMeter, (double)meganewtonmeterQuantity.Value, MeganewtonMetersTolerance);
+ Assert.Equal(TorqueUnit.MeganewtonMeter, meganewtonmeterQuantity.Unit);
+
+ var meganewtonmillimeterQuantity = newtonmeter.ToUnit(TorqueUnit.MeganewtonMillimeter);
+ AssertEx.EqualTolerance(MeganewtonMillimetersInOneNewtonMeter, (double)meganewtonmillimeterQuantity.Value, MeganewtonMillimetersTolerance);
+ Assert.Equal(TorqueUnit.MeganewtonMillimeter, meganewtonmillimeterQuantity.Unit);
+
+ var megapoundforcefootQuantity = newtonmeter.ToUnit(TorqueUnit.MegapoundForceFoot);
+ AssertEx.EqualTolerance(MegapoundForceFeetInOneNewtonMeter, (double)megapoundforcefootQuantity.Value, MegapoundForceFeetTolerance);
+ Assert.Equal(TorqueUnit.MegapoundForceFoot, megapoundforcefootQuantity.Unit);
+
+ var megapoundforceinchQuantity = newtonmeter.ToUnit(TorqueUnit.MegapoundForceInch);
+ AssertEx.EqualTolerance(MegapoundForceInchesInOneNewtonMeter, (double)megapoundforceinchQuantity.Value, MegapoundForceInchesTolerance);
+ Assert.Equal(TorqueUnit.MegapoundForceInch, megapoundforceinchQuantity.Unit);
+
+ var newtoncentimeterQuantity = newtonmeter.ToUnit(TorqueUnit.NewtonCentimeter);
+ AssertEx.EqualTolerance(NewtonCentimetersInOneNewtonMeter, (double)newtoncentimeterQuantity.Value, NewtonCentimetersTolerance);
+ Assert.Equal(TorqueUnit.NewtonCentimeter, newtoncentimeterQuantity.Unit);
+
+ var newtonmeterQuantity = newtonmeter.ToUnit(TorqueUnit.NewtonMeter);
+ AssertEx.EqualTolerance(NewtonMetersInOneNewtonMeter, (double)newtonmeterQuantity.Value, NewtonMetersTolerance);
+ Assert.Equal(TorqueUnit.NewtonMeter, newtonmeterQuantity.Unit);
+
+ var newtonmillimeterQuantity = newtonmeter.ToUnit(TorqueUnit.NewtonMillimeter);
+ AssertEx.EqualTolerance(NewtonMillimetersInOneNewtonMeter, (double)newtonmillimeterQuantity.Value, NewtonMillimetersTolerance);
+ Assert.Equal(TorqueUnit.NewtonMillimeter, newtonmillimeterQuantity.Unit);
+
+ var poundforcefootQuantity = newtonmeter.ToUnit(TorqueUnit.PoundForceFoot);
+ AssertEx.EqualTolerance(PoundForceFeetInOneNewtonMeter, (double)poundforcefootQuantity.Value, PoundForceFeetTolerance);
+ Assert.Equal(TorqueUnit.PoundForceFoot, poundforcefootQuantity.Unit);
+
+ var poundforceinchQuantity = newtonmeter.ToUnit(TorqueUnit.PoundForceInch);
+ AssertEx.EqualTolerance(PoundForceInchesInOneNewtonMeter, (double)poundforceinchQuantity.Value, PoundForceInchesTolerance);
+ Assert.Equal(TorqueUnit.PoundForceInch, poundforceinchQuantity.Unit);
+
+ var tonneforcecentimeterQuantity = newtonmeter.ToUnit(TorqueUnit.TonneForceCentimeter);
+ AssertEx.EqualTolerance(TonneForceCentimetersInOneNewtonMeter, (double)tonneforcecentimeterQuantity.Value, TonneForceCentimetersTolerance);
+ Assert.Equal(TorqueUnit.TonneForceCentimeter, tonneforcecentimeterQuantity.Unit);
+
+ var tonneforcemeterQuantity = newtonmeter.ToUnit(TorqueUnit.TonneForceMeter);
+ AssertEx.EqualTolerance(TonneForceMetersInOneNewtonMeter, (double)tonneforcemeterQuantity.Value, TonneForceMetersTolerance);
+ Assert.Equal(TorqueUnit.TonneForceMeter, tonneforcemeterQuantity.Unit);
+
+ var tonneforcemillimeterQuantity = newtonmeter.ToUnit(TorqueUnit.TonneForceMillimeter);
+ AssertEx.EqualTolerance(TonneForceMillimetersInOneNewtonMeter, (double)tonneforcemillimeterQuantity.Value, TonneForceMillimetersTolerance);
+ Assert.Equal(TorqueUnit.TonneForceMillimeter, tonneforcemillimeterQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/VitaminATestsBase.g.cs
index 6c2e89f2a4..83cae54300 100644
--- a/UnitsNet.Tests/GeneratedCode/VitaminATestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/VitaminATestsBase.g.cs
@@ -78,6 +78,16 @@ public void As()
AssertEx.EqualTolerance(InternationalUnitsInOneInternationalUnit, internationalunit.As(VitaminAUnit.InternationalUnit), InternationalUnitsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var internationalunit = VitaminA.FromInternationalUnits(1);
+
+ var internationalunitQuantity = internationalunit.ToUnit(VitaminAUnit.InternationalUnit);
+ AssertEx.EqualTolerance(InternationalUnitsInOneInternationalUnit, (double)internationalunitQuantity.Value, InternationalUnitsTolerance);
+ Assert.Equal(VitaminAUnit.InternationalUnit, internationalunitQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/VolumeFlowTestsBase.g.cs
index acaefc41e3..65c56b9b19 100644
--- a/UnitsNet.Tests/GeneratedCode/VolumeFlowTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/VolumeFlowTestsBase.g.cs
@@ -193,6 +193,108 @@ public void As()
AssertEx.EqualTolerance(UsGallonsPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.UsGallonsPerSecond), UsGallonsPerSecondTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1);
+
+ var centilitersperminuteQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CentilitersPerMinute);
+ AssertEx.EqualTolerance(CentilitersPerMinuteInOneCubicMeterPerSecond, (double)centilitersperminuteQuantity.Value, CentilitersPerMinuteTolerance);
+ Assert.Equal(VolumeFlowUnit.CentilitersPerMinute, centilitersperminuteQuantity.Unit);
+
+ var cubicdecimeterperminuteQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CubicDecimeterPerMinute);
+ AssertEx.EqualTolerance(CubicDecimetersPerMinuteInOneCubicMeterPerSecond, (double)cubicdecimeterperminuteQuantity.Value, CubicDecimetersPerMinuteTolerance);
+ Assert.Equal(VolumeFlowUnit.CubicDecimeterPerMinute, cubicdecimeterperminuteQuantity.Unit);
+
+ var cubicfootperhourQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CubicFootPerHour);
+ AssertEx.EqualTolerance(CubicFeetPerHourInOneCubicMeterPerSecond, (double)cubicfootperhourQuantity.Value, CubicFeetPerHourTolerance);
+ Assert.Equal(VolumeFlowUnit.CubicFootPerHour, cubicfootperhourQuantity.Unit);
+
+ var cubicfootperminuteQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CubicFootPerMinute);
+ AssertEx.EqualTolerance(CubicFeetPerMinuteInOneCubicMeterPerSecond, (double)cubicfootperminuteQuantity.Value, CubicFeetPerMinuteTolerance);
+ Assert.Equal(VolumeFlowUnit.CubicFootPerMinute, cubicfootperminuteQuantity.Unit);
+
+ var cubicfootpersecondQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CubicFootPerSecond);
+ AssertEx.EqualTolerance(CubicFeetPerSecondInOneCubicMeterPerSecond, (double)cubicfootpersecondQuantity.Value, CubicFeetPerSecondTolerance);
+ Assert.Equal(VolumeFlowUnit.CubicFootPerSecond, cubicfootpersecondQuantity.Unit);
+
+ var cubicmeterperhourQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CubicMeterPerHour);
+ AssertEx.EqualTolerance(CubicMetersPerHourInOneCubicMeterPerSecond, (double)cubicmeterperhourQuantity.Value, CubicMetersPerHourTolerance);
+ Assert.Equal(VolumeFlowUnit.CubicMeterPerHour, cubicmeterperhourQuantity.Unit);
+
+ var cubicmeterperminuteQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CubicMeterPerMinute);
+ AssertEx.EqualTolerance(CubicMetersPerMinuteInOneCubicMeterPerSecond, (double)cubicmeterperminuteQuantity.Value, CubicMetersPerMinuteTolerance);
+ Assert.Equal(VolumeFlowUnit.CubicMeterPerMinute, cubicmeterperminuteQuantity.Unit);
+
+ var cubicmeterpersecondQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CubicMeterPerSecond);
+ AssertEx.EqualTolerance(CubicMetersPerSecondInOneCubicMeterPerSecond, (double)cubicmeterpersecondQuantity.Value, CubicMetersPerSecondTolerance);
+ Assert.Equal(VolumeFlowUnit.CubicMeterPerSecond, cubicmeterpersecondQuantity.Unit);
+
+ var cubicyardperhourQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CubicYardPerHour);
+ AssertEx.EqualTolerance(CubicYardsPerHourInOneCubicMeterPerSecond, (double)cubicyardperhourQuantity.Value, CubicYardsPerHourTolerance);
+ Assert.Equal(VolumeFlowUnit.CubicYardPerHour, cubicyardperhourQuantity.Unit);
+
+ var cubicyardperminuteQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CubicYardPerMinute);
+ AssertEx.EqualTolerance(CubicYardsPerMinuteInOneCubicMeterPerSecond, (double)cubicyardperminuteQuantity.Value, CubicYardsPerMinuteTolerance);
+ Assert.Equal(VolumeFlowUnit.CubicYardPerMinute, cubicyardperminuteQuantity.Unit);
+
+ var cubicyardpersecondQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.CubicYardPerSecond);
+ AssertEx.EqualTolerance(CubicYardsPerSecondInOneCubicMeterPerSecond, (double)cubicyardpersecondQuantity.Value, CubicYardsPerSecondTolerance);
+ Assert.Equal(VolumeFlowUnit.CubicYardPerSecond, cubicyardpersecondQuantity.Unit);
+
+ var decilitersperminuteQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.DecilitersPerMinute);
+ AssertEx.EqualTolerance(DecilitersPerMinuteInOneCubicMeterPerSecond, (double)decilitersperminuteQuantity.Value, DecilitersPerMinuteTolerance);
+ Assert.Equal(VolumeFlowUnit.DecilitersPerMinute, decilitersperminuteQuantity.Unit);
+
+ var kilolitersperminuteQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.KilolitersPerMinute);
+ AssertEx.EqualTolerance(KilolitersPerMinuteInOneCubicMeterPerSecond, (double)kilolitersperminuteQuantity.Value, KilolitersPerMinuteTolerance);
+ Assert.Equal(VolumeFlowUnit.KilolitersPerMinute, kilolitersperminuteQuantity.Unit);
+
+ var litersperhourQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.LitersPerHour);
+ AssertEx.EqualTolerance(LitersPerHourInOneCubicMeterPerSecond, (double)litersperhourQuantity.Value, LitersPerHourTolerance);
+ Assert.Equal(VolumeFlowUnit.LitersPerHour, litersperhourQuantity.Unit);
+
+ var litersperminuteQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.LitersPerMinute);
+ AssertEx.EqualTolerance(LitersPerMinuteInOneCubicMeterPerSecond, (double)litersperminuteQuantity.Value, LitersPerMinuteTolerance);
+ Assert.Equal(VolumeFlowUnit.LitersPerMinute, litersperminuteQuantity.Unit);
+
+ var literspersecondQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.LitersPerSecond);
+ AssertEx.EqualTolerance(LitersPerSecondInOneCubicMeterPerSecond, (double)literspersecondQuantity.Value, LitersPerSecondTolerance);
+ Assert.Equal(VolumeFlowUnit.LitersPerSecond, literspersecondQuantity.Unit);
+
+ var microlitersperminuteQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.MicrolitersPerMinute);
+ AssertEx.EqualTolerance(MicrolitersPerMinuteInOneCubicMeterPerSecond, (double)microlitersperminuteQuantity.Value, MicrolitersPerMinuteTolerance);
+ Assert.Equal(VolumeFlowUnit.MicrolitersPerMinute, microlitersperminuteQuantity.Unit);
+
+ var millilitersperminuteQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.MillilitersPerMinute);
+ AssertEx.EqualTolerance(MillilitersPerMinuteInOneCubicMeterPerSecond, (double)millilitersperminuteQuantity.Value, MillilitersPerMinuteTolerance);
+ Assert.Equal(VolumeFlowUnit.MillilitersPerMinute, millilitersperminuteQuantity.Unit);
+
+ var millionusgallonsperdayQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.MillionUsGallonsPerDay);
+ AssertEx.EqualTolerance(MillionUsGallonsPerDayInOneCubicMeterPerSecond, (double)millionusgallonsperdayQuantity.Value, MillionUsGallonsPerDayTolerance);
+ Assert.Equal(VolumeFlowUnit.MillionUsGallonsPerDay, millionusgallonsperdayQuantity.Unit);
+
+ var nanolitersperminuteQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.NanolitersPerMinute);
+ AssertEx.EqualTolerance(NanolitersPerMinuteInOneCubicMeterPerSecond, (double)nanolitersperminuteQuantity.Value, NanolitersPerMinuteTolerance);
+ Assert.Equal(VolumeFlowUnit.NanolitersPerMinute, nanolitersperminuteQuantity.Unit);
+
+ var oilbarrelsperdayQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.OilBarrelsPerDay);
+ AssertEx.EqualTolerance(OilBarrelsPerDayInOneCubicMeterPerSecond, (double)oilbarrelsperdayQuantity.Value, OilBarrelsPerDayTolerance);
+ Assert.Equal(VolumeFlowUnit.OilBarrelsPerDay, oilbarrelsperdayQuantity.Unit);
+
+ var usgallonsperhourQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.UsGallonsPerHour);
+ AssertEx.EqualTolerance(UsGallonsPerHourInOneCubicMeterPerSecond, (double)usgallonsperhourQuantity.Value, UsGallonsPerHourTolerance);
+ Assert.Equal(VolumeFlowUnit.UsGallonsPerHour, usgallonsperhourQuantity.Unit);
+
+ var usgallonsperminuteQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.UsGallonsPerMinute);
+ AssertEx.EqualTolerance(UsGallonsPerMinuteInOneCubicMeterPerSecond, (double)usgallonsperminuteQuantity.Value, UsGallonsPerMinuteTolerance);
+ Assert.Equal(VolumeFlowUnit.UsGallonsPerMinute, usgallonsperminuteQuantity.Unit);
+
+ var usgallonspersecondQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.UsGallonsPerSecond);
+ AssertEx.EqualTolerance(UsGallonsPerSecondInOneCubicMeterPerSecond, (double)usgallonspersecondQuantity.Value, UsGallonsPerSecondTolerance);
+ Assert.Equal(VolumeFlowUnit.UsGallonsPerSecond, usgallonspersecondQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet.Tests/GeneratedCode/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/VolumeTestsBase.g.cs
index 15917d0924..c16b31f816 100644
--- a/UnitsNet.Tests/GeneratedCode/VolumeTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/VolumeTestsBase.g.cs
@@ -293,6 +293,188 @@ public void As()
AssertEx.EqualTolerance(UsTeaspoonsInOneCubicMeter, cubicmeter.As(VolumeUnit.UsTeaspoon), UsTeaspoonsTolerance);
}
+ [Fact]
+ public void ToUnit()
+ {
+ var cubicmeter = Volume.FromCubicMeters(1);
+
+ var autablespoonQuantity = cubicmeter.ToUnit(VolumeUnit.AuTablespoon);
+ AssertEx.EqualTolerance(AuTablespoonsInOneCubicMeter, (double)autablespoonQuantity.Value, AuTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.AuTablespoon, autablespoonQuantity.Unit);
+
+ var centiliterQuantity = cubicmeter.ToUnit(VolumeUnit.Centiliter);
+ AssertEx.EqualTolerance(CentilitersInOneCubicMeter, (double)centiliterQuantity.Value, CentilitersTolerance);
+ Assert.Equal(VolumeUnit.Centiliter, centiliterQuantity.Unit);
+
+ var cubiccentimeterQuantity = cubicmeter.ToUnit(VolumeUnit.CubicCentimeter);
+ AssertEx.EqualTolerance(CubicCentimetersInOneCubicMeter, (double)cubiccentimeterQuantity.Value, CubicCentimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicCentimeter, cubiccentimeterQuantity.Unit);
+
+ var cubicdecimeterQuantity = cubicmeter.ToUnit(VolumeUnit.CubicDecimeter);
+ AssertEx.EqualTolerance(CubicDecimetersInOneCubicMeter, (double)cubicdecimeterQuantity.Value, CubicDecimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicDecimeter, cubicdecimeterQuantity.Unit);
+
+ var cubicfootQuantity = cubicmeter.ToUnit(VolumeUnit.CubicFoot);
+ AssertEx.EqualTolerance(CubicFeetInOneCubicMeter, (double)cubicfootQuantity.Value, CubicFeetTolerance);
+ Assert.Equal(VolumeUnit.CubicFoot, cubicfootQuantity.Unit);
+
+ var cubicinchQuantity = cubicmeter.ToUnit(VolumeUnit.CubicInch);
+ AssertEx.EqualTolerance(CubicInchesInOneCubicMeter, (double)cubicinchQuantity.Value, CubicInchesTolerance);
+ Assert.Equal(VolumeUnit.CubicInch, cubicinchQuantity.Unit);
+
+ var cubickilometerQuantity = cubicmeter.ToUnit(VolumeUnit.CubicKilometer);
+ AssertEx.EqualTolerance(CubicKilometersInOneCubicMeter, (double)cubickilometerQuantity.Value, CubicKilometersTolerance);
+ Assert.Equal(VolumeUnit.CubicKilometer, cubickilometerQuantity.Unit);
+
+ var cubicmeterQuantity = cubicmeter.ToUnit(VolumeUnit.CubicMeter);
+ AssertEx.EqualTolerance(CubicMetersInOneCubicMeter, (double)cubicmeterQuantity.Value, CubicMetersTolerance);
+ Assert.Equal(VolumeUnit.CubicMeter, cubicmeterQuantity.Unit);
+
+ var cubicmicrometerQuantity = cubicmeter.ToUnit(VolumeUnit.CubicMicrometer);
+ AssertEx.EqualTolerance(CubicMicrometersInOneCubicMeter, (double)cubicmicrometerQuantity.Value, CubicMicrometersTolerance);
+ Assert.Equal(VolumeUnit.CubicMicrometer, cubicmicrometerQuantity.Unit);
+
+ var cubicmileQuantity = cubicmeter.ToUnit(VolumeUnit.CubicMile);
+ AssertEx.EqualTolerance(CubicMilesInOneCubicMeter, (double)cubicmileQuantity.Value, CubicMilesTolerance);
+ Assert.Equal(VolumeUnit.CubicMile, cubicmileQuantity.Unit);
+
+ var cubicmillimeterQuantity = cubicmeter.ToUnit(VolumeUnit.CubicMillimeter);
+ AssertEx.EqualTolerance(CubicMillimetersInOneCubicMeter, (double)cubicmillimeterQuantity.Value, CubicMillimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicMillimeter, cubicmillimeterQuantity.Unit);
+
+ var cubicyardQuantity = cubicmeter.ToUnit(VolumeUnit.CubicYard);
+ AssertEx.EqualTolerance(CubicYardsInOneCubicMeter, (double)cubicyardQuantity.Value, CubicYardsTolerance);
+ Assert.Equal(VolumeUnit.CubicYard, cubicyardQuantity.Unit);
+
+ var deciliterQuantity = cubicmeter.ToUnit(VolumeUnit.Deciliter);
+ AssertEx.EqualTolerance(DecilitersInOneCubicMeter, (double)deciliterQuantity.Value, DecilitersTolerance);
+ Assert.Equal(VolumeUnit.Deciliter, deciliterQuantity.Unit);
+
+ var hectocubicfootQuantity = cubicmeter.ToUnit(VolumeUnit.HectocubicFoot);
+ AssertEx.EqualTolerance(HectocubicFeetInOneCubicMeter, (double)hectocubicfootQuantity.Value, HectocubicFeetTolerance);
+ Assert.Equal(VolumeUnit.HectocubicFoot, hectocubicfootQuantity.Unit);
+
+ var hectocubicmeterQuantity = cubicmeter.ToUnit(VolumeUnit.HectocubicMeter);
+ AssertEx.EqualTolerance(HectocubicMetersInOneCubicMeter, (double)hectocubicmeterQuantity.Value, HectocubicMetersTolerance);
+ Assert.Equal(VolumeUnit.HectocubicMeter, hectocubicmeterQuantity.Unit);
+
+ var hectoliterQuantity = cubicmeter.ToUnit(VolumeUnit.Hectoliter);
+ AssertEx.EqualTolerance(HectolitersInOneCubicMeter, (double)hectoliterQuantity.Value, HectolitersTolerance);
+ Assert.Equal(VolumeUnit.Hectoliter, hectoliterQuantity.Unit);
+
+ var imperialbeerbarrelQuantity = cubicmeter.ToUnit(VolumeUnit.ImperialBeerBarrel);
+ AssertEx.EqualTolerance(ImperialBeerBarrelsInOneCubicMeter, (double)imperialbeerbarrelQuantity.Value, ImperialBeerBarrelsTolerance);
+ Assert.Equal(VolumeUnit.ImperialBeerBarrel, imperialbeerbarrelQuantity.Unit);
+
+ var imperialgallonQuantity = cubicmeter.ToUnit(VolumeUnit.ImperialGallon);
+ AssertEx.EqualTolerance(ImperialGallonsInOneCubicMeter, (double)imperialgallonQuantity.Value, ImperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.ImperialGallon, imperialgallonQuantity.Unit);
+
+ var imperialounceQuantity = cubicmeter.ToUnit(VolumeUnit.ImperialOunce);
+ AssertEx.EqualTolerance(ImperialOuncesInOneCubicMeter, (double)imperialounceQuantity.Value, ImperialOuncesTolerance);
+ Assert.Equal(VolumeUnit.ImperialOunce, imperialounceQuantity.Unit);
+
+ var kilocubicfootQuantity = cubicmeter.ToUnit(VolumeUnit.KilocubicFoot);
+ AssertEx.EqualTolerance(KilocubicFeetInOneCubicMeter, (double)kilocubicfootQuantity.Value, KilocubicFeetTolerance);
+ Assert.Equal(VolumeUnit.KilocubicFoot, kilocubicfootQuantity.Unit);
+
+ var kilocubicmeterQuantity = cubicmeter.ToUnit(VolumeUnit.KilocubicMeter);
+ AssertEx.EqualTolerance(KilocubicMetersInOneCubicMeter, (double)kilocubicmeterQuantity.Value, KilocubicMetersTolerance);
+ Assert.Equal(VolumeUnit.KilocubicMeter, kilocubicmeterQuantity.Unit);
+
+ var kiloimperialgallonQuantity = cubicmeter.ToUnit(VolumeUnit.KiloimperialGallon);
+ AssertEx.EqualTolerance(KiloimperialGallonsInOneCubicMeter, (double)kiloimperialgallonQuantity.Value, KiloimperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.KiloimperialGallon, kiloimperialgallonQuantity.Unit);
+
+ var kilousgallonQuantity = cubicmeter.ToUnit(VolumeUnit.KilousGallon);
+ AssertEx.EqualTolerance(KilousGallonsInOneCubicMeter, (double)kilousgallonQuantity.Value, KilousGallonsTolerance);
+ Assert.Equal(VolumeUnit.KilousGallon, kilousgallonQuantity.Unit);
+
+ var literQuantity = cubicmeter.ToUnit(VolumeUnit.Liter);
+ AssertEx.EqualTolerance(LitersInOneCubicMeter, (double)literQuantity.Value, LitersTolerance);
+ Assert.Equal(VolumeUnit.Liter, literQuantity.Unit);
+
+ var megacubicfootQuantity = cubicmeter.ToUnit(VolumeUnit.MegacubicFoot);
+ AssertEx.EqualTolerance(MegacubicFeetInOneCubicMeter, (double)megacubicfootQuantity.Value, MegacubicFeetTolerance);
+ Assert.Equal(VolumeUnit.MegacubicFoot, megacubicfootQuantity.Unit);
+
+ var megaimperialgallonQuantity = cubicmeter.ToUnit(VolumeUnit.MegaimperialGallon);
+ AssertEx.EqualTolerance(MegaimperialGallonsInOneCubicMeter, (double)megaimperialgallonQuantity.Value, MegaimperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.MegaimperialGallon, megaimperialgallonQuantity.Unit);
+
+ var megausgallonQuantity = cubicmeter.ToUnit(VolumeUnit.MegausGallon);
+ AssertEx.EqualTolerance(MegausGallonsInOneCubicMeter, (double)megausgallonQuantity.Value, MegausGallonsTolerance);
+ Assert.Equal(VolumeUnit.MegausGallon, megausgallonQuantity.Unit);
+
+ var metriccupQuantity = cubicmeter.ToUnit(VolumeUnit.MetricCup);
+ AssertEx.EqualTolerance(MetricCupsInOneCubicMeter, (double)metriccupQuantity.Value, MetricCupsTolerance);
+ Assert.Equal(VolumeUnit.MetricCup, metriccupQuantity.Unit);
+
+ var metricteaspoonQuantity = cubicmeter.ToUnit(VolumeUnit.MetricTeaspoon);
+ AssertEx.EqualTolerance(MetricTeaspoonsInOneCubicMeter, (double)metricteaspoonQuantity.Value, MetricTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTeaspoon, metricteaspoonQuantity.Unit);
+
+ var microliterQuantity = cubicmeter.ToUnit(VolumeUnit.Microliter);
+ AssertEx.EqualTolerance(MicrolitersInOneCubicMeter, (double)microliterQuantity.Value, MicrolitersTolerance);
+ Assert.Equal(VolumeUnit.Microliter, microliterQuantity.Unit);
+
+ var milliliterQuantity = cubicmeter.ToUnit(VolumeUnit.Milliliter);
+ AssertEx.EqualTolerance(MillilitersInOneCubicMeter, (double)milliliterQuantity.Value, MillilitersTolerance);
+ Assert.Equal(VolumeUnit.Milliliter, milliliterQuantity.Unit);
+
+ var oilbarrelQuantity = cubicmeter.ToUnit(VolumeUnit.OilBarrel);
+ AssertEx.EqualTolerance(OilBarrelsInOneCubicMeter, (double)oilbarrelQuantity.Value, OilBarrelsTolerance);
+ Assert.Equal(VolumeUnit.OilBarrel, oilbarrelQuantity.Unit);
+
+ var tablespoonQuantity = cubicmeter.ToUnit(VolumeUnit.Tablespoon);
+ AssertEx.EqualTolerance(TablespoonsInOneCubicMeter, (double)tablespoonQuantity.Value, TablespoonsTolerance);
+ Assert.Equal(VolumeUnit.Tablespoon, tablespoonQuantity.Unit);
+
+ var teaspoonQuantity = cubicmeter.ToUnit(VolumeUnit.Teaspoon);
+ AssertEx.EqualTolerance(TeaspoonsInOneCubicMeter, (double)teaspoonQuantity.Value, TeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.Teaspoon, teaspoonQuantity.Unit);
+
+ var uktablespoonQuantity = cubicmeter.ToUnit(VolumeUnit.UkTablespoon);
+ AssertEx.EqualTolerance(UkTablespoonsInOneCubicMeter, (double)uktablespoonQuantity.Value, UkTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.UkTablespoon, uktablespoonQuantity.Unit);
+
+ var usbeerbarrelQuantity = cubicmeter.ToUnit(VolumeUnit.UsBeerBarrel);
+ AssertEx.EqualTolerance(UsBeerBarrelsInOneCubicMeter, (double)usbeerbarrelQuantity.Value, UsBeerBarrelsTolerance);
+ Assert.Equal(VolumeUnit.UsBeerBarrel, usbeerbarrelQuantity.Unit);
+
+ var uscustomarycupQuantity = cubicmeter.ToUnit(VolumeUnit.UsCustomaryCup);
+ AssertEx.EqualTolerance(UsCustomaryCupsInOneCubicMeter, (double)uscustomarycupQuantity.Value, UsCustomaryCupsTolerance);
+ Assert.Equal(VolumeUnit.UsCustomaryCup, uscustomarycupQuantity.Unit);
+
+ var usgallonQuantity = cubicmeter.ToUnit(VolumeUnit.UsGallon);
+ AssertEx.EqualTolerance(UsGallonsInOneCubicMeter, (double)usgallonQuantity.Value, UsGallonsTolerance);
+ Assert.Equal(VolumeUnit.UsGallon, usgallonQuantity.Unit);
+
+ var uslegalcupQuantity = cubicmeter.ToUnit(VolumeUnit.UsLegalCup);
+ AssertEx.EqualTolerance(UsLegalCupsInOneCubicMeter, (double)uslegalcupQuantity.Value, UsLegalCupsTolerance);
+ Assert.Equal(VolumeUnit.UsLegalCup, uslegalcupQuantity.Unit);
+
+ var usounceQuantity = cubicmeter.ToUnit(VolumeUnit.UsOunce);
+ AssertEx.EqualTolerance(UsOuncesInOneCubicMeter, (double)usounceQuantity.Value, UsOuncesTolerance);
+ Assert.Equal(VolumeUnit.UsOunce, usounceQuantity.Unit);
+
+ var uspintQuantity = cubicmeter.ToUnit(VolumeUnit.UsPint);
+ AssertEx.EqualTolerance(UsPintsInOneCubicMeter, (double)uspintQuantity.Value, UsPintsTolerance);
+ Assert.Equal(VolumeUnit.UsPint, uspintQuantity.Unit);
+
+ var usquartQuantity = cubicmeter.ToUnit(VolumeUnit.UsQuart);
+ AssertEx.EqualTolerance(UsQuartsInOneCubicMeter, (double)usquartQuantity.Value, UsQuartsTolerance);
+ Assert.Equal(VolumeUnit.UsQuart, usquartQuantity.Unit);
+
+ var ustablespoonQuantity = cubicmeter.ToUnit(VolumeUnit.UsTablespoon);
+ AssertEx.EqualTolerance(UsTablespoonsInOneCubicMeter, (double)ustablespoonQuantity.Value, UsTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.UsTablespoon, ustablespoonQuantity.Unit);
+
+ var usteaspoonQuantity = cubicmeter.ToUnit(VolumeUnit.UsTeaspoon);
+ AssertEx.EqualTolerance(UsTeaspoonsInOneCubicMeter, (double)usteaspoonQuantity.Value, UsTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.UsTeaspoon, usteaspoonQuantity.Unit);
+ }
+
[Fact]
public void ConversionRoundTrip()
{
diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs
index ffb4efb346..e7e20845d8 100644
--- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs
@@ -869,6 +869,16 @@ public double As(AccelerationUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Acceleration to another Acceleration with the unit representation .
+ ///
+ /// A Acceleration with the specified unit.
+ public Acceleration ToUnit(AccelerationUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Acceleration(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs
index 9a1cff74f5..0fc5dc7536 100644
--- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs
@@ -902,6 +902,16 @@ public double As(AmountOfSubstanceUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this AmountOfSubstance to another AmountOfSubstance with the unit representation .
+ ///
+ /// A AmountOfSubstance with the specified unit.
+ public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new AmountOfSubstance(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs
index a7a12dd7cd..aa8d246eb9 100644
--- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs
@@ -570,6 +570,16 @@ public double As(AmplitudeRatioUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this AmplitudeRatio to another AmplitudeRatio with the unit representation .
+ ///
+ /// A AmplitudeRatio with the specified unit.
+ public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new AmplitudeRatio(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs
index 9efb317486..42519887f5 100644
--- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs
@@ -892,6 +892,16 @@ public double As(AngleUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Angle to another Angle with the unit representation .
+ ///
+ /// A Angle with the specified unit.
+ public Angle ToUnit(AngleUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Angle(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs
index 4d5e7e6ca1..54982144bd 100644
--- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs
@@ -539,6 +539,16 @@ public double As(ApparentEnergyUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ApparentEnergy to another ApparentEnergy with the unit representation .
+ ///
+ /// A ApparentEnergy with the specified unit.
+ public ApparentEnergy ToUnit(ApparentEnergyUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ApparentEnergy(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs
index 9a6587f150..65e21f0a9b 100644
--- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs
@@ -572,6 +572,16 @@ public double As(ApparentPowerUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ApparentPower to another ApparentPower with the unit representation .
+ ///
+ /// A ApparentPower with the specified unit.
+ public ApparentPower ToUnit(ApparentPowerUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ApparentPower(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs
index 7c1dcfa74d..492081b32b 100644
--- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs
@@ -869,6 +869,16 @@ public double As(AreaUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Area to another Area with the unit representation .
+ ///
+ /// A Area with the specified unit.
+ public Area ToUnit(AreaUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Area(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs
index 07d24c4d27..1f37f43fc0 100644
--- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs
@@ -473,6 +473,16 @@ public double As(AreaDensityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this AreaDensity to another AreaDensity with the unit representation .
+ ///
+ /// A AreaDensity with the specified unit.
+ public AreaDensity ToUnit(AreaDensityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new AreaDensity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs
index b0c403112e..6c119c7ef9 100644
--- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs
@@ -638,6 +638,16 @@ public double As(AreaMomentOfInertiaUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this AreaMomentOfInertia to another AreaMomentOfInertia with the unit representation .
+ ///
+ /// A AreaMomentOfInertia with the specified unit.
+ public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new AreaMomentOfInertia(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs
index 8af4a1cc6a..5f3889646d 100644
--- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs
@@ -1285,6 +1285,16 @@ public double As(BitRateUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this BitRate to another BitRate with the unit representation .
+ ///
+ /// A BitRate with the specified unit.
+ public BitRate ToUnit(BitRateUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new BitRate(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs
index 7392078cec..905e1c0034 100644
--- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs
@@ -539,6 +539,16 @@ public double As(BrakeSpecificFuelConsumptionUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this BrakeSpecificFuelConsumption to another BrakeSpecificFuelConsumption with the unit representation .
+ ///
+ /// A BrakeSpecificFuelConsumption with the specified unit.
+ public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new BrakeSpecificFuelConsumption(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs
index b8a03a1fef..f2e91b6ec3 100644
--- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs
@@ -473,6 +473,16 @@ public double As(CapacitanceUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Capacitance to another Capacitance with the unit representation .
+ ///
+ /// A Capacitance with the specified unit.
+ public Capacitance ToUnit(CapacitanceUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Capacitance(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs
index ac37cce4c5..5d49e29f02 100644
--- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs
@@ -1694,6 +1694,16 @@ public double As(DensityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Density to another Density with the unit representation .
+ ///
+ /// A Density with the specified unit.
+ public Density ToUnit(DensityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Density(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs
index 9debe7c16e..f04710f991 100644
--- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs
@@ -838,6 +838,16 @@ public double As(DurationUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Duration to another Duration with the unit representation .
+ ///
+ /// A Duration with the specified unit.
+ public Duration ToUnit(DurationUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Duration(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs
index eb43518e9e..099c30a2e2 100644
--- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs
@@ -638,6 +638,16 @@ public double As(DynamicViscosityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this DynamicViscosity to another DynamicViscosity with the unit representation .
+ ///
+ /// A DynamicViscosity with the specified unit.
+ public DynamicViscosity ToUnit(DynamicViscosityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new DynamicViscosity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs
index 9d1ef0267a..807b4f37e4 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs
@@ -572,6 +572,16 @@ public double As(ElectricAdmittanceUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricAdmittance to another ElectricAdmittance with the unit representation .
+ ///
+ /// A ElectricAdmittance with the specified unit.
+ public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricAdmittance(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs
index 02ce7a1530..4731d44632 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs
@@ -473,6 +473,16 @@ public double As(ElectricChargeUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricCharge to another ElectricCharge with the unit representation .
+ ///
+ /// A ElectricCharge with the specified unit.
+ public ElectricCharge ToUnit(ElectricChargeUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricCharge(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs
index 9632e9e839..d72e04c40b 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs
@@ -473,6 +473,16 @@ public double As(ElectricChargeDensityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricChargeDensity to another ElectricChargeDensity with the unit representation .
+ ///
+ /// A ElectricChargeDensity with the specified unit.
+ public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricChargeDensity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs
index 6d3675e414..fec10f938e 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs
@@ -539,6 +539,16 @@ public double As(ElectricConductanceUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricConductance to another ElectricConductance with the unit representation .
+ ///
+ /// A ElectricConductance with the specified unit.
+ public ElectricConductance ToUnit(ElectricConductanceUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricConductance(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs
index c460552515..a9d89dddd1 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs
@@ -473,6 +473,16 @@ public double As(ElectricConductivityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricConductivity to another ElectricConductivity with the unit representation .
+ ///
+ /// A ElectricConductivity with the specified unit.
+ public ElectricConductivity ToUnit(ElectricConductivityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricConductivity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs
index 4d971f10c6..7887f2d07c 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs
@@ -671,6 +671,16 @@ public double As(ElectricCurrentUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricCurrent to another ElectricCurrent with the unit representation .
+ ///
+ /// A ElectricCurrent with the specified unit.
+ public ElectricCurrent ToUnit(ElectricCurrentUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricCurrent(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs
index d266edfc91..5542ec04eb 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs
@@ -473,6 +473,16 @@ public double As(ElectricCurrentDensityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricCurrentDensity to another ElectricCurrentDensity with the unit representation .
+ ///
+ /// A ElectricCurrentDensity with the specified unit.
+ public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricCurrentDensity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs
index bd0e0bc17f..ccc1bbdf8e 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs
@@ -473,6 +473,16 @@ public double As(ElectricCurrentGradientUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricCurrentGradient to another ElectricCurrentGradient with the unit representation .
+ ///
+ /// A ElectricCurrentGradient with the specified unit.
+ public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricCurrentGradient(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs
index 1c374b55d5..49ef2fb146 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs
@@ -473,6 +473,16 @@ public double As(ElectricFieldUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricField to another ElectricField with the unit representation .
+ ///
+ /// A ElectricField with the specified unit.
+ public ElectricField ToUnit(ElectricFieldUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricField(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs
index f6863d8cae..62f6dbb8f3 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs
@@ -473,6 +473,16 @@ public double As(ElectricInductanceUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricInductance to another ElectricInductance with the unit representation .
+ ///
+ /// A ElectricInductance with the specified unit.
+ public ElectricInductance ToUnit(ElectricInductanceUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricInductance(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs
index 4047fa033b..413290eaa8 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs
@@ -605,6 +605,16 @@ public double As(ElectricPotentialUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricPotential to another ElectricPotential with the unit representation .
+ ///
+ /// A ElectricPotential with the specified unit.
+ public ElectricPotential ToUnit(ElectricPotentialUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricPotential(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs
index d30390aca1..931fc0d829 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs
@@ -595,6 +595,16 @@ public double As(ElectricPotentialAcUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricPotentialAc to another ElectricPotentialAc with the unit representation .
+ ///
+ /// A ElectricPotentialAc with the specified unit.
+ public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricPotentialAc(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs
index f96ca4a691..48cae36a0d 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs
@@ -595,6 +595,16 @@ public double As(ElectricPotentialDcUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricPotentialDc to another ElectricPotentialDc with the unit representation .
+ ///
+ /// A ElectricPotentialDc with the specified unit.
+ public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricPotentialDc(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs
index 774c12af2b..e2fe573728 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs
@@ -572,6 +572,16 @@ public double As(ElectricResistanceUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricResistance to another ElectricResistance with the unit representation .
+ ///
+ /// A ElectricResistance with the specified unit.
+ public ElectricResistance ToUnit(ElectricResistanceUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricResistance(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs
index def2d61634..f6c14c75c0 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs
@@ -572,6 +572,16 @@ public double As(ElectricResistivityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ElectricResistivity to another ElectricResistivity with the unit representation .
+ ///
+ /// A ElectricResistivity with the specified unit.
+ public ElectricResistivity ToUnit(ElectricResistivityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ElectricResistivity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs
index 2dcc0d6a22..fb271c295a 100644
--- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs
@@ -1166,6 +1166,16 @@ public double As(EnergyUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Energy to another Energy with the unit representation .
+ ///
+ /// A Energy with the specified unit.
+ public Energy ToUnit(EnergyUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Energy(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs
index 66ed7c573e..ffd91dde8b 100644
--- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs
@@ -671,6 +671,16 @@ public double As(EntropyUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Entropy to another Entropy with the unit representation .
+ ///
+ /// A Entropy with the specified unit.
+ public Entropy ToUnit(EntropyUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Entropy(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Flow.g.cs b/UnitsNet/GeneratedCode/Quantities/Flow.g.cs
index 7a37407c43..9c8bf6cdf0 100644
--- a/UnitsNet/GeneratedCode/Quantities/Flow.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Flow.g.cs
@@ -1250,6 +1250,16 @@ public double As(FlowUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Flow to another Flow with the unit representation .
+ ///
+ /// A Flow with the specified unit.
+ public Flow ToUnit(FlowUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Flow(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs
index 95d0a90169..0bc9876143 100644
--- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs
@@ -770,6 +770,16 @@ public double As(ForceUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Force to another Force with the unit representation .
+ ///
+ /// A Force with the specified unit.
+ public Force ToUnit(ForceUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Force(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs
index 3481ea1b7b..bba1c249b8 100644
--- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs
@@ -803,6 +803,16 @@ public double As(ForceChangeRateUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ForceChangeRate to another ForceChangeRate with the unit representation .
+ ///
+ /// A ForceChangeRate with the specified unit.
+ public ForceChangeRate ToUnit(ForceChangeRateUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ForceChangeRate(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs
index bf624c1ab1..01f27b939d 100644
--- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs
@@ -737,6 +737,16 @@ public double As(ForcePerLengthUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ForcePerLength to another ForcePerLength with the unit representation .
+ ///
+ /// A ForcePerLength with the specified unit.
+ public ForcePerLength ToUnit(ForcePerLengthUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ForcePerLength(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs
index 20e6d19bb8..9c3bd60f3b 100644
--- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs
@@ -704,6 +704,16 @@ public double As(FrequencyUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Frequency to another Frequency with the unit representation .
+ ///
+ /// A Frequency with the specified unit.
+ public Frequency ToUnit(FrequencyUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Frequency(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs
index 3b50c84e81..f035000e83 100644
--- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs
@@ -968,6 +968,16 @@ public double As(HeatFluxUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this HeatFlux to another HeatFlux with the unit representation .
+ ///
+ /// A HeatFlux with the specified unit.
+ public HeatFlux ToUnit(HeatFluxUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new HeatFlux(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs
index 5320e3a572..9758064f1d 100644
--- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs
@@ -506,6 +506,16 @@ public double As(HeatTransferCoefficientUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this HeatTransferCoefficient to another HeatTransferCoefficient with the unit representation .
+ ///
+ /// A HeatTransferCoefficient with the specified unit.
+ public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new HeatTransferCoefficient(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs
index 5cf4a34c80..5648946221 100644
--- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs
@@ -572,6 +572,16 @@ public double As(IlluminanceUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Illuminance to another Illuminance with the unit representation .
+ ///
+ /// A Illuminance with the specified unit.
+ public Illuminance ToUnit(IlluminanceUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Illuminance(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs
index f553ba2c41..9ec8164943 100644
--- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs
@@ -1285,6 +1285,16 @@ public double As(InformationUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Information to another Information with the unit representation .
+ ///
+ /// A Information with the specified unit.
+ public Information ToUnit(InformationUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Information(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs
index aad6ed68bc..8b0e630380 100644
--- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs
@@ -506,6 +506,16 @@ public double As(IrradianceUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Irradiance to another Irradiance with the unit representation .
+ ///
+ /// A Irradiance with the specified unit.
+ public Irradiance ToUnit(IrradianceUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Irradiance(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs
index be1a7a34c1..bd61be9a2c 100644
--- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs
@@ -539,6 +539,16 @@ public double As(IrradiationUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Irradiation to another Irradiation with the unit representation .
+ ///
+ /// A Irradiation with the specified unit.
+ public Irradiation ToUnit(IrradiationUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Irradiation(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs
index 9c6a3b3a14..b27b7b6e75 100644
--- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs
@@ -704,6 +704,16 @@ public double As(KinematicViscosityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this KinematicViscosity to another KinematicViscosity with the unit representation .
+ ///
+ /// A KinematicViscosity with the specified unit.
+ public KinematicViscosity ToUnit(KinematicViscosityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new KinematicViscosity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs
index 3b62e8ab8f..571a4d31fc 100644
--- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs
@@ -473,6 +473,16 @@ public double As(LapseRateUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this LapseRate to another LapseRate with the unit representation .
+ ///
+ /// A LapseRate with the specified unit.
+ public LapseRate ToUnit(LapseRateUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new LapseRate(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs
index 6ec217de99..f39fbffa12 100644
--- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs
@@ -1166,6 +1166,16 @@ public double As(LengthUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Length to another Length with the unit representation .
+ ///
+ /// A Length with the specified unit.
+ public Length ToUnit(LengthUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Length(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs
index 0272576eb9..4a09b9810d 100644
--- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs
@@ -504,6 +504,16 @@ public double As(LevelUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Level to another Level with the unit representation .
+ ///
+ /// A Level with the specified unit.
+ public Level ToUnit(LevelUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Level(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs
index 530404a8b1..7deae00ea3 100644
--- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs
@@ -539,6 +539,16 @@ public double As(LinearDensityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this LinearDensity to another LinearDensity with the unit representation .
+ ///
+ /// A LinearDensity with the specified unit.
+ public LinearDensity ToUnit(LinearDensityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new LinearDensity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs
index e5b0824289..718444cb10 100644
--- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs
@@ -473,6 +473,16 @@ public double As(LuminousFluxUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this LuminousFlux to another LuminousFlux with the unit representation .
+ ///
+ /// A LuminousFlux with the specified unit.
+ public LuminousFlux ToUnit(LuminousFluxUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new LuminousFlux(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs
index e09c6e8bc4..f03387900e 100644
--- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs
@@ -473,6 +473,16 @@ public double As(LuminousIntensityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this LuminousIntensity to another LuminousIntensity with the unit representation .
+ ///
+ /// A LuminousIntensity with the specified unit.
+ public LuminousIntensity ToUnit(LuminousIntensityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new LuminousIntensity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs
index 2d99bec49a..2a00c13d0c 100644
--- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs
@@ -473,6 +473,16 @@ public double As(MagneticFieldUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this MagneticField to another MagneticField with the unit representation .
+ ///
+ /// A MagneticField with the specified unit.
+ public MagneticField ToUnit(MagneticFieldUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new MagneticField(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs
index 5aa54390b0..6647147d5e 100644
--- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs
@@ -473,6 +473,16 @@ public double As(MagneticFluxUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this MagneticFlux to another MagneticFlux with the unit representation .
+ ///
+ /// A MagneticFlux with the specified unit.
+ public MagneticFlux ToUnit(MagneticFluxUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new MagneticFlux(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs
index 5e208e1397..685093c23a 100644
--- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs
@@ -473,6 +473,16 @@ public double As(MagnetizationUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Magnetization to another Magnetization with the unit representation .
+ ///
+ /// A Magnetization with the specified unit.
+ public Magnetization ToUnit(MagnetizationUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Magnetization(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs
index 45b86bb45f..c793e03af0 100644
--- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs
@@ -1133,6 +1133,16 @@ public double As(MassUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Mass to another Mass with the unit representation .
+ ///
+ /// A Mass with the specified unit.
+ public Mass ToUnit(MassUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Mass(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs
index ca3e0047ea..ec3cc79a86 100644
--- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs
@@ -935,6 +935,16 @@ public double As(MassFlowUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this MassFlow to another MassFlow with the unit representation .
+ ///
+ /// A MassFlow with the specified unit.
+ public MassFlow ToUnit(MassFlowUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new MassFlow(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs
index 2a789d653b..e7a9d0bcb4 100644
--- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs
@@ -506,6 +506,16 @@ public double As(MassFluxUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this MassFlux to another MassFlux with the unit representation .
+ ///
+ /// A MassFlux with the specified unit.
+ public MassFlux ToUnit(MassFluxUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new MassFlux(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs
index 7623ec9998..e4b1f6ac62 100644
--- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs
@@ -1298,6 +1298,16 @@ public double As(MassMomentOfInertiaUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this MassMomentOfInertia to another MassMomentOfInertia with the unit representation .
+ ///
+ /// A MassMomentOfInertia with the specified unit.
+ public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new MassMomentOfInertia(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs
index 0710bf2d28..252fca6a0c 100644
--- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs
@@ -539,6 +539,16 @@ public double As(MolarEnergyUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this MolarEnergy to another MolarEnergy with the unit representation .
+ ///
+ /// A MolarEnergy with the specified unit.
+ public MolarEnergy ToUnit(MolarEnergyUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new MolarEnergy(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs
index a4aa33e97d..c2370b839e 100644
--- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs
@@ -539,6 +539,16 @@ public double As(MolarEntropyUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this MolarEntropy to another MolarEntropy with the unit representation .
+ ///
+ /// A MolarEntropy with the specified unit.
+ public MolarEntropy ToUnit(MolarEntropyUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new MolarEntropy(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs
index 1407774c5e..f13e3cfbf3 100644
--- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs
@@ -836,6 +836,16 @@ public double As(MolarMassUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this MolarMass to another MolarMass with the unit representation .
+ ///
+ /// A MolarMass with the specified unit.
+ public MolarMass ToUnit(MolarMassUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new MolarMass(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs
index c77046510d..b154a1705e 100644
--- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs
@@ -704,6 +704,16 @@ public double As(MolarityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Molarity to another Molarity with the unit representation .
+ ///
+ /// A Molarity with the specified unit.
+ public Molarity ToUnit(MolarityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Molarity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs
index 17c130af91..ba301a33cd 100644
--- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs
@@ -473,6 +473,16 @@ public double As(PermeabilityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Permeability to another Permeability with the unit representation .
+ ///
+ /// A Permeability with the specified unit.
+ public Permeability ToUnit(PermeabilityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Permeability(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs
index 7b5061024f..20e0298b76 100644
--- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs
@@ -473,6 +473,16 @@ public double As(PermittivityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Permittivity to another Permittivity with the unit representation .
+ ///
+ /// A Permittivity with the specified unit.
+ public Permittivity ToUnit(PermittivityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Permittivity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs
index beea35c12f..93dfd3bbe1 100644
--- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs
@@ -1097,6 +1097,16 @@ public double As(PowerUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Power to another Power with the unit representation .
+ ///
+ /// A Power with the specified unit.
+ public Power ToUnit(PowerUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Power(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs
index b4912582ba..13c4d52c3a 100644
--- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs
@@ -1892,6 +1892,16 @@ public double As(PowerDensityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this PowerDensity to another PowerDensity with the unit representation .
+ ///
+ /// A PowerDensity with the specified unit.
+ public PowerDensity ToUnit(PowerDensityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new PowerDensity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs
index f3e547d630..640732a8b9 100644
--- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs
@@ -504,6 +504,16 @@ public double As(PowerRatioUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this PowerRatio to another PowerRatio with the unit representation .
+ ///
+ /// A PowerRatio with the specified unit.
+ public PowerRatio ToUnit(PowerRatioUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new PowerRatio(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs
index 1d7127e3c9..393f781e16 100644
--- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs
@@ -1695,6 +1695,16 @@ public double As(PressureUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Pressure to another Pressure with the unit representation .
+ ///
+ /// A Pressure with the specified unit.
+ public Pressure ToUnit(PressureUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Pressure(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs
index 3b0188c512..0e8c8c9b63 100644
--- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs
@@ -572,6 +572,16 @@ public double As(PressureChangeRateUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this PressureChangeRate to another PressureChangeRate with the unit representation .
+ ///
+ /// A PressureChangeRate with the specified unit.
+ public PressureChangeRate ToUnit(PressureChangeRateUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new PressureChangeRate(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs
index e35f6381b0..cbea7ccb83 100644
--- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs
@@ -628,6 +628,16 @@ public double As(RatioUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Ratio to another Ratio with the unit representation .
+ ///
+ /// A Ratio with the specified unit.
+ public Ratio ToUnit(RatioUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Ratio(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs
index ce413a8b62..f4a6ac7ad7 100644
--- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs
@@ -539,6 +539,16 @@ public double As(ReactiveEnergyUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ReactiveEnergy to another ReactiveEnergy with the unit representation .
+ ///
+ /// A ReactiveEnergy with the specified unit.
+ public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ReactiveEnergy(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs
index 4821c69156..ca375852c1 100644
--- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs
@@ -572,6 +572,16 @@ public double As(ReactivePowerUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ReactivePower to another ReactivePower with the unit representation .
+ ///
+ /// A ReactivePower with the specified unit.
+ public ReactivePower ToUnit(ReactivePowerUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ReactivePower(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs
index 0e3b6a631a..7b66ab215e 100644
--- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs
@@ -539,6 +539,16 @@ public double As(RotationalAccelerationUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this RotationalAcceleration to another RotationalAcceleration with the unit representation .
+ ///
+ /// A RotationalAcceleration with the specified unit.
+ public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new RotationalAcceleration(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs
index 5845b087b3..7584156b54 100644
--- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs
@@ -869,6 +869,16 @@ public double As(RotationalSpeedUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this RotationalSpeed to another RotationalSpeed with the unit representation .
+ ///
+ /// A RotationalSpeed with the specified unit.
+ public RotationalSpeed ToUnit(RotationalSpeedUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new RotationalSpeed(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs
index 55a0a83d8b..9160f77c98 100644
--- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs
@@ -539,6 +539,16 @@ public double As(RotationalStiffnessUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this RotationalStiffness to another RotationalStiffness with the unit representation .
+ ///
+ /// A RotationalStiffness with the specified unit.
+ public RotationalStiffness ToUnit(RotationalStiffnessUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new RotationalStiffness(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs
index e32c7cb4fd..e2509b6516 100644
--- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs
@@ -539,6 +539,16 @@ public double As(RotationalStiffnessPerLengthUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this RotationalStiffnessPerLength to another RotationalStiffnessPerLength with the unit representation .
+ ///
+ /// A RotationalStiffnessPerLength with the specified unit.
+ public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new RotationalStiffnessPerLength(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs
index 237dc70b4f..d1376ece5c 100644
--- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs
@@ -463,6 +463,16 @@ public double As(SolidAngleUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this SolidAngle to another SolidAngle with the unit representation .
+ ///
+ /// A SolidAngle with the specified unit.
+ public SolidAngle ToUnit(SolidAngleUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new SolidAngle(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs
index 987b57bf05..23e2eb41d9 100644
--- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs
@@ -704,6 +704,16 @@ public double As(SpecificEnergyUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this SpecificEnergy to another SpecificEnergy with the unit representation .
+ ///
+ /// A SpecificEnergy with the specified unit.
+ public SpecificEnergy ToUnit(SpecificEnergyUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new SpecificEnergy(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs
index 0dcd6051ad..94d81f0ea0 100644
--- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs
@@ -704,6 +704,16 @@ public double As(SpecificEntropyUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this SpecificEntropy to another SpecificEntropy with the unit representation .
+ ///
+ /// A SpecificEntropy with the specified unit.
+ public SpecificEntropy ToUnit(SpecificEntropyUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new SpecificEntropy(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs
index 1630e31363..74d04c39c2 100644
--- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs
@@ -473,6 +473,16 @@ public double As(SpecificVolumeUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this SpecificVolume to another SpecificVolume with the unit representation .
+ ///
+ /// A SpecificVolume with the specified unit.
+ public SpecificVolume ToUnit(SpecificVolumeUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new SpecificVolume(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs
index 128a27ea2f..fe455c3c83 100644
--- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs
@@ -1001,6 +1001,16 @@ public double As(SpecificWeightUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this SpecificWeight to another SpecificWeight with the unit representation .
+ ///
+ /// A SpecificWeight with the specified unit.
+ public SpecificWeight ToUnit(SpecificWeightUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new SpecificWeight(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs
index 08d04bbbcf..8a233d9dbe 100644
--- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs
@@ -1496,6 +1496,16 @@ public double As(SpeedUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Speed to another Speed with the unit representation .
+ ///
+ /// A Speed with the specified unit.
+ public Speed ToUnit(SpeedUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Speed(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs
index 6b82adb8eb..ef70148d82 100644
--- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs
@@ -662,6 +662,16 @@ public double As(TemperatureUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Temperature to another Temperature with the unit representation .
+ ///
+ /// A Temperature with the specified unit.
+ public Temperature ToUnit(TemperatureUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Temperature(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs
index 0a8d13fcb0..f67a8206b2 100644
--- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs
@@ -770,6 +770,16 @@ public double As(TemperatureChangeRateUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this TemperatureChangeRate to another TemperatureChangeRate with the unit representation .
+ ///
+ /// A TemperatureChangeRate with the specified unit.
+ public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new TemperatureChangeRate(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs
index 2d171630a6..7c0b46a212 100644
--- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs
@@ -966,6 +966,16 @@ public double As(TemperatureDeltaUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this TemperatureDelta to another TemperatureDelta with the unit representation .
+ ///
+ /// A TemperatureDelta with the specified unit.
+ public TemperatureDelta ToUnit(TemperatureDeltaUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new TemperatureDelta(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs
index 17296e9cff..6265198b76 100644
--- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs
@@ -506,6 +506,16 @@ public double As(ThermalConductivityUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ThermalConductivity to another ThermalConductivity with the unit representation .
+ ///
+ /// A ThermalConductivity with the specified unit.
+ public ThermalConductivity ToUnit(ThermalConductivityUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ThermalConductivity(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs
index 82e6acf64b..cace0781e7 100644
--- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs
@@ -605,6 +605,16 @@ public double As(ThermalResistanceUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this ThermalResistance to another ThermalResistance with the unit representation .
+ ///
+ /// A ThermalResistance with the specified unit.
+ public ThermalResistance ToUnit(ThermalResistanceUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new ThermalResistance(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs
index a95e3a3944..1b39c61651 100644
--- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs
@@ -1133,6 +1133,16 @@ public double As(TorqueUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Torque to another Torque with the unit representation .
+ ///
+ /// A Torque with the specified unit.
+ public Torque ToUnit(TorqueUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Torque(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs
index ac1575f261..3fa2401a5d 100644
--- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs
@@ -463,6 +463,16 @@ public double As(VitaminAUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this VitaminA to another VitaminA with the unit representation .
+ ///
+ /// A VitaminA with the specified unit.
+ public VitaminA ToUnit(VitaminAUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new VitaminA(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs
index 6bcb28713b..6738fda05d 100644
--- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs
@@ -1894,6 +1894,16 @@ public double As(VolumeUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this Volume to another Volume with the unit representation .
+ ///
+ /// A Volume with the specified unit.
+ public Volume ToUnit(VolumeUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new Volume(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs
index 032745217f..2fa2823e56 100644
--- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs
@@ -1232,6 +1232,16 @@ public double As(VolumeFlowUnit unit)
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this VolumeFlow to another VolumeFlow with the unit representation .
+ ///
+ /// A VolumeFlow with the specified unit.
+ public VolumeFlow ToUnit(VolumeFlowUnit unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new VolumeFlow(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/Scripts/Include-GenerateQuantitySourceCodeCommon.ps1 b/UnitsNet/Scripts/Include-GenerateQuantitySourceCodeCommon.ps1
index a3d28839e9..51b37cdd41 100644
--- a/UnitsNet/Scripts/Include-GenerateQuantitySourceCodeCommon.ps1
+++ b/UnitsNet/Scripts/Include-GenerateQuantitySourceCodeCommon.ps1
@@ -540,6 +540,16 @@ namespace UnitsNet
return Convert.ToDouble(converted);
}
+ ///
+ /// Converts this $quantityName to another $quantityName with the unit representation .
+ ///
+ /// A $quantityName with the specified unit.
+ public $quantityName ToUnit($unitEnumName unit)
+ {
+ var convertedValue = AsBaseNumericType(unit);
+ return new $quantityName(convertedValue, unit);
+ }
+
///
/// Converts the current value + unit to the base unit.
/// This is typically the first step in converting from one unit to another.
diff --git a/UnitsNet/Scripts/Include-GenerateUnitTestBaseClassSourceCode.ps1 b/UnitsNet/Scripts/Include-GenerateUnitTestBaseClassSourceCode.ps1
index b0d68819f8..b0712f23e0 100644
--- a/UnitsNet/Scripts/Include-GenerateUnitTestBaseClassSourceCode.ps1
+++ b/UnitsNet/Scripts/Include-GenerateUnitTestBaseClassSourceCode.ps1
@@ -1,4 +1,4 @@
-function GenerateUnitTestBaseClassSourceCode($quantity)
+function GenerateUnitTestBaseClassSourceCode($quantity)
{
$quantityName = $quantity.Name;
$baseType = $quantity.BaseType;
@@ -99,6 +99,21 @@ namespace UnitsNet.Tests
"@; }@"
}
+ [Fact]
+ public void ToUnit()
+ {
+ var $baseUnitVariableName = $quantityName.From$baseUnitPluralName(1);
+"@; foreach ($unit in $units)
+{
+ $asQuantityVariableName = "$($unit.SingularName.ToLowerInvariant())Quantity";
+@"
+
+ var $asQuantityVariableName = $baseUnitVariableName.ToUnit($($quantityName)Unit.$($unit.SingularName));
+ AssertEx.EqualTolerance($($unit.PluralName)InOne$($baseUnit.SingularName), (double)$asQuantityVariableName.Value, $($unit.PluralName)Tolerance);
+ Assert.Equal($($quantityName)Unit.$($unit.SingularName), $asQuantityVariableName.Unit);
+"@; }@"
+ }
+
[Fact]
public void ConversionRoundTrip()
{