From e6e0f64dcf43511b6397ef410f18d7371a82aee0 Mon Sep 17 00:00:00 2001 From: Andrew Meservy Date: Thu, 17 Oct 2024 14:26:59 +0200 Subject: [PATCH] Add KelvinPerMinute to TemperatureChangeRateUnit --- .../TemperatureChangeRate.json | 13 ++++ Common/UnitEnumValues.g.json | 3 +- .../Quantities/TemperatureChangeRate.g.cs | 13 ++++ .../Units/TemperatureChangeRateUnit.g.cs | 1 + ...ToTemperatureChangeRateExtensionsTest.g.cs | 4 ++ ...mberToTemperatureChangeRateExtensions.g.cs | 8 +++ .../CustomCode/TemperatureChangeRateTests.cs | 2 + .../TemperatureChangeRateTestsBase.g.cs | 67 ++++++++++++++----- .../Quantities/TemperatureChangeRate.g.cs | 20 ++++++ .../Resources/TemperatureChangeRate.restext | 1 + .../Units/TemperatureChangeRateUnit.g.cs | 1 + generate-code.bat | 1 + 12 files changed, 118 insertions(+), 16 deletions(-) diff --git a/Common/UnitDefinitions/TemperatureChangeRate.json b/Common/UnitDefinitions/TemperatureChangeRate.json index 6359b24f2f..da26786b52 100644 --- a/Common/UnitDefinitions/TemperatureChangeRate.json +++ b/Common/UnitDefinitions/TemperatureChangeRate.json @@ -31,6 +31,19 @@ "Abbreviations": [ "°C/min" ] } ] + }, + { + "SingularName": "DegreeKelvinPerMinute", + "PluralName": "DegreesKelvinPerMinute", + "FromUnitToBaseFunc": "({x} / 60) - 273.15", + "FromBaseToUnitFunc": "({x} + 273.15) * 60", + "Prefixes": [], + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "K/min" ] + } + ] } ] } diff --git a/Common/UnitEnumValues.g.json b/Common/UnitEnumValues.g.json index e58a8e2198..4bbaa6ad24 100644 --- a/Common/UnitEnumValues.g.json +++ b/Common/UnitEnumValues.g.json @@ -1451,7 +1451,8 @@ "KilodegreeCelsiusPerSecond": 7, "MicrodegreeCelsiusPerSecond": 8, "MillidegreeCelsiusPerSecond": 9, - "NanodegreeCelsiusPerSecond": 10 + "NanodegreeCelsiusPerSecond": 10, + "DegreeKelvinPerMinute": 20 }, "TemperatureDelta": { "DegreeCelsius": 1, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 9f624ec62e..16c287bebe 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -104,6 +104,11 @@ public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) /// public double DegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond); + /// + /// Gets a value of this quantity converted into + /// + public double DegreesKelvinPerMinute => As(TemperatureChangeRateUnit.DegreeKelvinPerMinute); + /// /// Gets a value of this quantity converted into /// @@ -163,6 +168,12 @@ public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) /// If value is NaN or Infinity. public static TemperatureChangeRate FromDegreesCelsiusPerSecond(double degreescelsiuspersecond) => new TemperatureChangeRate(degreescelsiuspersecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond); + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static TemperatureChangeRate FromDegreesKelvinPerMinute(double degreeskelvinperminute) => new TemperatureChangeRate(degreeskelvinperminute, TemperatureChangeRateUnit.DegreeKelvinPerMinute); + /// /// Creates a from . /// @@ -238,6 +249,7 @@ private double GetValueInBaseUnit() TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond => (_value) * 1e-1d, TemperatureChangeRateUnit.DegreeCelsiusPerMinute => _value / 60, TemperatureChangeRateUnit.DegreeCelsiusPerSecond => _value, + TemperatureChangeRateUnit.DegreeKelvinPerMinute => (_value / 60) - 273.15, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond => (_value) * 1e2d, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond => (_value) * 1e3d, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond => (_value) * 1e-6d, @@ -261,6 +273,7 @@ private double GetValueAs(TemperatureChangeRateUnit unit) TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond => (baseUnitValue) / 1e-1d, TemperatureChangeRateUnit.DegreeCelsiusPerMinute => baseUnitValue * 60, TemperatureChangeRateUnit.DegreeCelsiusPerSecond => baseUnitValue, + TemperatureChangeRateUnit.DegreeKelvinPerMinute => (baseUnitValue + 273.15) * 60, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond => (baseUnitValue) / 1e2d, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond => (baseUnitValue) / 1e3d, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond => (baseUnitValue) / 1e-6d, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs index b06ed41185..ca88789b40 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs @@ -30,6 +30,7 @@ public enum TemperatureChangeRateUnit DecidegreeCelsiusPerSecond = 3, DegreeCelsiusPerMinute = 4, DegreeCelsiusPerSecond = 5, + DegreeKelvinPerMinute = 20, HectodegreeCelsiusPerSecond = 6, KilodegreeCelsiusPerSecond = 7, MicrodegreeCelsiusPerSecond = 8, diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureChangeRateExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureChangeRateExtensionsTest.g.cs index 548a058084..ef6888642a 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureChangeRateExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureChangeRateExtensionsTest.g.cs @@ -44,6 +44,10 @@ public void NumberToDegreesCelsiusPerMinuteTest() => public void NumberToDegreesCelsiusPerSecondTest() => Assert.Equal(TemperatureChangeRate.FromDegreesCelsiusPerSecond(2), 2.DegreesCelsiusPerSecond()); + [Fact] + public void NumberToDegreesKelvinPerMinuteTest() => + Assert.Equal(TemperatureChangeRate.FromDegreesKelvinPerMinute(2), 2.DegreesKelvinPerMinute()); + [Fact] public void NumberToHectodegreesCelsiusPerSecondTest() => Assert.Equal(TemperatureChangeRate.FromHectodegreesCelsiusPerSecond(2), 2.HectodegreesCelsiusPerSecond()); diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureChangeRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureChangeRateExtensions.g.cs index 98d8dfae29..f2447bb8b8 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureChangeRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureChangeRateExtensions.g.cs @@ -72,6 +72,14 @@ public static TemperatureChangeRate DegreesCelsiusPerSecond(this T value) #endif => TemperatureChangeRate.FromDegreesCelsiusPerSecond(Convert.ToDouble(value)); + /// + public static TemperatureChangeRate DegreesKelvinPerMinute(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => TemperatureChangeRate.FromDegreesKelvinPerMinute(Convert.ToDouble(value)); + /// public static TemperatureChangeRate HectodegreesCelsiusPerSecond(this T value) where T : notnull diff --git a/UnitsNet.Tests/CustomCode/TemperatureChangeRateTests.cs b/UnitsNet.Tests/CustomCode/TemperatureChangeRateTests.cs index e4c0da0547..c5a84cab4f 100644 --- a/UnitsNet.Tests/CustomCode/TemperatureChangeRateTests.cs +++ b/UnitsNet.Tests/CustomCode/TemperatureChangeRateTests.cs @@ -29,6 +29,8 @@ public class TemperatureChangeRateTests : TemperatureChangeRateTestsBase protected override double DegreesCelsiusPerMinuteInOneDegreeCelsiusPerSecond => 60; + protected override double DegreesKelvinPerMinuteInOneDegreeCelsiusPerSecond => 16449; + [Fact] public void TemperatureChangeRateMultipliedWithTimeSpanEqualsTemperatureDelta() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 39797721f2..4d79c471f0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -43,6 +43,7 @@ public abstract partial class TemperatureChangeRateTestsBase : QuantityTestsBase protected abstract double DecidegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond { get; } protected abstract double DegreesCelsiusPerMinuteInOneDegreeCelsiusPerSecond { get; } protected abstract double DegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond { get; } + protected abstract double DegreesKelvinPerMinuteInOneDegreeCelsiusPerSecond { get; } protected abstract double HectodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond { get; } protected abstract double KilodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond { get; } protected abstract double MicrodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond { get; } @@ -55,6 +56,7 @@ public abstract partial class TemperatureChangeRateTestsBase : QuantityTestsBase protected virtual double DecidegreesCelsiusPerSecondTolerance { get { return 1e-5; } } protected virtual double DegreesCelsiusPerMinuteTolerance { get { return 1e-5; } } protected virtual double DegreesCelsiusPerSecondTolerance { get { return 1e-5; } } + protected virtual double DegreesKelvinPerMinuteTolerance { get { return 1e-5; } } protected virtual double HectodegreesCelsiusPerSecondTolerance { get { return 1e-5; } } protected virtual double KilodegreesCelsiusPerSecondTolerance { get { return 1e-5; } } protected virtual double MicrodegreesCelsiusPerSecondTolerance { get { return 1e-5; } } @@ -71,6 +73,7 @@ public abstract partial class TemperatureChangeRateTestsBase : QuantityTestsBase TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond => (DecidegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, DecidegreesCelsiusPerSecondTolerance), TemperatureChangeRateUnit.DegreeCelsiusPerMinute => (DegreesCelsiusPerMinuteInOneDegreeCelsiusPerSecond, DegreesCelsiusPerMinuteTolerance), TemperatureChangeRateUnit.DegreeCelsiusPerSecond => (DegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, DegreesCelsiusPerSecondTolerance), + TemperatureChangeRateUnit.DegreeKelvinPerMinute => (DegreesKelvinPerMinuteInOneDegreeCelsiusPerSecond, DegreesKelvinPerMinuteTolerance), TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond => (HectodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, HectodegreesCelsiusPerSecondTolerance), TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond => (KilodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, KilodegreesCelsiusPerSecondTolerance), TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond => (MicrodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, MicrodegreesCelsiusPerSecondTolerance), @@ -87,6 +90,7 @@ public abstract partial class TemperatureChangeRateTestsBase : QuantityTestsBase new object[] { TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond }, new object[] { TemperatureChangeRateUnit.DegreeCelsiusPerMinute }, new object[] { TemperatureChangeRateUnit.DegreeCelsiusPerSecond }, + new object[] { TemperatureChangeRateUnit.DegreeKelvinPerMinute }, new object[] { TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond }, new object[] { TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond }, new object[] { TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond }, @@ -159,6 +163,7 @@ public void DegreeCelsiusPerSecondToTemperatureChangeRateUnits() AssertEx.EqualTolerance(DecidegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.DecidegreesCelsiusPerSecond, DecidegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(DegreesCelsiusPerMinuteInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.DegreesCelsiusPerMinute, DegreesCelsiusPerMinuteTolerance); AssertEx.EqualTolerance(DegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(DegreesKelvinPerMinuteInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.DegreesKelvinPerMinute, DegreesKelvinPerMinuteTolerance); AssertEx.EqualTolerance(HectodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.HectodegreesCelsiusPerSecond, HectodegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(KilodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.KilodegreesCelsiusPerSecond, KilodegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(MicrodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.MicrodegreesCelsiusPerSecond, MicrodegreesCelsiusPerSecondTolerance); @@ -189,25 +194,29 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() AssertEx.EqualTolerance(1, quantity04.DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); Assert.Equal(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity04.Unit); - var quantity05 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); - AssertEx.EqualTolerance(1, quantity05.HectodegreesCelsiusPerSecond, HectodegreesCelsiusPerSecondTolerance); - Assert.Equal(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, quantity05.Unit); + var quantity05 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.DegreeKelvinPerMinute); + AssertEx.EqualTolerance(1, quantity05.DegreesKelvinPerMinute, DegreesKelvinPerMinuteTolerance); + Assert.Equal(TemperatureChangeRateUnit.DegreeKelvinPerMinute, quantity05.Unit); - var quantity06 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); - AssertEx.EqualTolerance(1, quantity06.KilodegreesCelsiusPerSecond, KilodegreesCelsiusPerSecondTolerance); - Assert.Equal(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, quantity06.Unit); + var quantity06 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); + AssertEx.EqualTolerance(1, quantity06.HectodegreesCelsiusPerSecond, HectodegreesCelsiusPerSecondTolerance); + Assert.Equal(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, quantity06.Unit); - var quantity07 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); - AssertEx.EqualTolerance(1, quantity07.MicrodegreesCelsiusPerSecond, MicrodegreesCelsiusPerSecondTolerance); - Assert.Equal(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, quantity07.Unit); + var quantity07 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); + AssertEx.EqualTolerance(1, quantity07.KilodegreesCelsiusPerSecond, KilodegreesCelsiusPerSecondTolerance); + Assert.Equal(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, quantity07.Unit); - var quantity08 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); - AssertEx.EqualTolerance(1, quantity08.MillidegreesCelsiusPerSecond, MillidegreesCelsiusPerSecondTolerance); - Assert.Equal(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, quantity08.Unit); + var quantity08 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); + AssertEx.EqualTolerance(1, quantity08.MicrodegreesCelsiusPerSecond, MicrodegreesCelsiusPerSecondTolerance); + Assert.Equal(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, quantity08.Unit); - var quantity09 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); - AssertEx.EqualTolerance(1, quantity09.NanodegreesCelsiusPerSecond, NanodegreesCelsiusPerSecondTolerance); - Assert.Equal(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, quantity09.Unit); + var quantity09 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); + AssertEx.EqualTolerance(1, quantity09.MillidegreesCelsiusPerSecond, MillidegreesCelsiusPerSecondTolerance); + Assert.Equal(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, quantity09.Unit); + + var quantity10 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); + AssertEx.EqualTolerance(1, quantity10.NanodegreesCelsiusPerSecond, NanodegreesCelsiusPerSecondTolerance); + Assert.Equal(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, quantity10.Unit); } @@ -233,6 +242,7 @@ public void As() AssertEx.EqualTolerance(DecidegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.As(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond), DecidegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(DegreesCelsiusPerMinuteInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.As(TemperatureChangeRateUnit.DegreeCelsiusPerMinute), DegreesCelsiusPerMinuteTolerance); AssertEx.EqualTolerance(DegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond), DegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(DegreesKelvinPerMinuteInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.As(TemperatureChangeRateUnit.DegreeKelvinPerMinute), DegreesKelvinPerMinuteTolerance); AssertEx.EqualTolerance(HectodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.As(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond), HectodegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(KilodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.As(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond), KilodegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(MicrodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.As(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond), MicrodegreesCelsiusPerSecondTolerance); @@ -295,6 +305,13 @@ public void Parse() Assert.Equal(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, parsed.Unit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsed = TemperatureChangeRate.Parse("1 K/min", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.DegreesKelvinPerMinute, DegreesKelvinPerMinuteTolerance); + Assert.Equal(TemperatureChangeRateUnit.DegreeKelvinPerMinute, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsed = TemperatureChangeRate.Parse("1 h°C/s", CultureInfo.GetCultureInfo("en-US")); @@ -365,6 +382,12 @@ public void TryParse() Assert.Equal(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, parsed.Unit); } + { + Assert.True(TemperatureChangeRate.TryParse("1 K/min", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DegreesKelvinPerMinute, DegreesKelvinPerMinuteTolerance); + Assert.Equal(TemperatureChangeRateUnit.DegreeKelvinPerMinute, parsed.Unit); + } + { Assert.True(TemperatureChangeRate.TryParse("1 h°C/s", CultureInfo.GetCultureInfo("en-US"), out var parsed)); AssertEx.EqualTolerance(1, parsed.HectodegreesCelsiusPerSecond, HectodegreesCelsiusPerSecondTolerance); @@ -430,6 +453,12 @@ public void ParseUnit() Assert.Equal(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, parsedUnit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsedUnit = TemperatureChangeRate.ParseUnit("K/min", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(TemperatureChangeRateUnit.DegreeKelvinPerMinute, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsedUnit = TemperatureChangeRate.ParseUnit("h°C/s", CultureInfo.GetCultureInfo("en-US")); @@ -490,6 +519,11 @@ public void TryParseUnit() Assert.Equal(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, parsedUnit); } + { + Assert.True(TemperatureChangeRate.TryParseUnit("K/min", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(TemperatureChangeRateUnit.DegreeKelvinPerMinute, parsedUnit); + } + { Assert.True(TemperatureChangeRate.TryParseUnit("h°C/s", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); Assert.Equal(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, parsedUnit); @@ -568,6 +602,7 @@ public void ConversionRoundTrip() AssertEx.EqualTolerance(1, TemperatureChangeRate.FromDecidegreesCelsiusPerSecond(degreecelsiuspersecond.DecidegreesCelsiusPerSecond).DegreesCelsiusPerSecond, DecidegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(1, TemperatureChangeRate.FromDegreesCelsiusPerMinute(degreecelsiuspersecond.DegreesCelsiusPerMinute).DegreesCelsiusPerSecond, DegreesCelsiusPerMinuteTolerance); AssertEx.EqualTolerance(1, TemperatureChangeRate.FromDegreesCelsiusPerSecond(degreecelsiuspersecond.DegreesCelsiusPerSecond).DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(1, TemperatureChangeRate.FromDegreesKelvinPerMinute(degreecelsiuspersecond.DegreesKelvinPerMinute).DegreesCelsiusPerSecond, DegreesKelvinPerMinuteTolerance); AssertEx.EqualTolerance(1, TemperatureChangeRate.FromHectodegreesCelsiusPerSecond(degreecelsiuspersecond.HectodegreesCelsiusPerSecond).DegreesCelsiusPerSecond, HectodegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(1, TemperatureChangeRate.FromKilodegreesCelsiusPerSecond(degreecelsiuspersecond.KilodegreesCelsiusPerSecond).DegreesCelsiusPerSecond, KilodegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(1, TemperatureChangeRate.FromMicrodegreesCelsiusPerSecond(degreecelsiuspersecond.MicrodegreesCelsiusPerSecond).DegreesCelsiusPerSecond, MicrodegreesCelsiusPerSecondTolerance); @@ -727,6 +762,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() Assert.Equal("1 d°C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond).ToString()); Assert.Equal("1 °C/min", new TemperatureChangeRate(1, TemperatureChangeRateUnit.DegreeCelsiusPerMinute).ToString()); Assert.Equal("1 °C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.DegreeCelsiusPerSecond).ToString()); + Assert.Equal("1 K/min", new TemperatureChangeRate(1, TemperatureChangeRateUnit.DegreeKelvinPerMinute).ToString()); Assert.Equal("1 h°C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond).ToString()); Assert.Equal("1 k°C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond).ToString()); Assert.Equal("1 µ°C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond).ToString()); @@ -750,6 +786,7 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture Assert.Equal("1 d°C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond).ToString(swedishCulture)); Assert.Equal("1 °C/min", new TemperatureChangeRate(1, TemperatureChangeRateUnit.DegreeCelsiusPerMinute).ToString(swedishCulture)); Assert.Equal("1 °C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.DegreeCelsiusPerSecond).ToString(swedishCulture)); + Assert.Equal("1 K/min", new TemperatureChangeRate(1, TemperatureChangeRateUnit.DegreeKelvinPerMinute).ToString(swedishCulture)); Assert.Equal("1 h°C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond).ToString(swedishCulture)); Assert.Equal("1 k°C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond).ToString(swedishCulture)); Assert.Equal("1 µ°C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond).ToString(swedishCulture)); diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 3c23a22401..bf2cd4d3f6 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -72,6 +72,7 @@ static TemperatureChangeRate() new UnitInfo(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, "DecidegreesCelsiusPerSecond", BaseUnits.Undefined, "TemperatureChangeRate"), new UnitInfo(TemperatureChangeRateUnit.DegreeCelsiusPerMinute, "DegreesCelsiusPerMinute", BaseUnits.Undefined, "TemperatureChangeRate"), new UnitInfo(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, "DegreesCelsiusPerSecond", BaseUnits.Undefined, "TemperatureChangeRate"), + new UnitInfo(TemperatureChangeRateUnit.DegreeKelvinPerMinute, "DegreesKelvinPerMinute", BaseUnits.Undefined, "TemperatureChangeRate"), new UnitInfo(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, "HectodegreesCelsiusPerSecond", BaseUnits.Undefined, "TemperatureChangeRate"), new UnitInfo(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, "KilodegreesCelsiusPerSecond", BaseUnits.Undefined, "TemperatureChangeRate"), new UnitInfo(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, "MicrodegreesCelsiusPerSecond", BaseUnits.Undefined, "TemperatureChangeRate"), @@ -205,6 +206,11 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// public double DegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond); + /// + /// Gets a value of this quantity converted into + /// + public double DegreesKelvinPerMinute => As(TemperatureChangeRateUnit.DegreeKelvinPerMinute); + /// /// Gets a value of this quantity converted into /// @@ -245,6 +251,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity => quantity.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity => quantity.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerMinute, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity => quantity.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeKelvinPerMinute, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity => quantity.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); unitConverter.SetConversionFunction(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity => quantity.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); unitConverter.SetConversionFunction(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity => quantity.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); unitConverter.SetConversionFunction(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity => quantity.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); @@ -259,6 +266,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, quantity => quantity.ToUnit(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond)); unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, quantity => quantity.ToUnit(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond)); unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerMinute, quantity => quantity.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerMinute)); + unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeKelvinPerMinute, quantity => quantity.ToUnit(TemperatureChangeRateUnit.DegreeKelvinPerMinute)); unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, quantity => quantity.ToUnit(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond)); unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, quantity => quantity.ToUnit(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond)); unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, quantity => quantity.ToUnit(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond)); @@ -341,6 +349,16 @@ public static TemperatureChangeRate FromDegreesCelsiusPerSecond(QuantityValue de return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerSecond); } + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static TemperatureChangeRate FromDegreesKelvinPerMinute(QuantityValue degreeskelvinperminute) + { + double value = (double) degreeskelvinperminute; + return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeKelvinPerMinute); + } + /// /// Creates a from . /// @@ -888,6 +906,7 @@ private bool TryToUnit(TemperatureChangeRateUnit unit, [NotNullWhen(true)] out T (TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e1d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), (TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e-1d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), (TemperatureChangeRateUnit.DegreeCelsiusPerMinute, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate(_value / 60, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.DegreeKelvinPerMinute, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value / 60) - 273.15, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), (TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e2d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), (TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e3d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), (TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e-6d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), @@ -899,6 +918,7 @@ private bool TryToUnit(TemperatureChangeRateUnit unit, [NotNullWhen(true)] out T (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e1d, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond), (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e-1d, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond), (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerMinute) => new TemperatureChangeRate(_value * 60, TemperatureChangeRateUnit.DegreeCelsiusPerMinute), + (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeKelvinPerMinute) => new TemperatureChangeRate((_value + 273.15) * 60, TemperatureChangeRateUnit.DegreeKelvinPerMinute), (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e2d, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond), (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e3d, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond), (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e-6d, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond), diff --git a/UnitsNet/GeneratedCode/Resources/TemperatureChangeRate.restext b/UnitsNet/GeneratedCode/Resources/TemperatureChangeRate.restext index b7d07466de..2ae216f794 100644 --- a/UnitsNet/GeneratedCode/Resources/TemperatureChangeRate.restext +++ b/UnitsNet/GeneratedCode/Resources/TemperatureChangeRate.restext @@ -3,6 +3,7 @@ DecadegreesCelsiusPerSecond=da°C/s DecidegreesCelsiusPerSecond=d°C/s DegreesCelsiusPerMinute=°C/min DegreesCelsiusPerSecond=°C/s +DegreesKelvinPerMinute=K/min HectodegreesCelsiusPerSecond=h°C/s KilodegreesCelsiusPerSecond=k°C/s MicrodegreesCelsiusPerSecond=µ°C/s diff --git a/UnitsNet/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs b/UnitsNet/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs index b06ed41185..ca88789b40 100644 --- a/UnitsNet/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs @@ -30,6 +30,7 @@ public enum TemperatureChangeRateUnit DecidegreeCelsiusPerSecond = 3, DegreeCelsiusPerMinute = 4, DegreeCelsiusPerSecond = 5, + DegreeKelvinPerMinute = 20, HectodegreeCelsiusPerSecond = 6, KilodegreeCelsiusPerSecond = 7, MicrodegreeCelsiusPerSecond = 8, diff --git a/generate-code.bat b/generate-code.bat index 26f3ccc04a..5cfd45c76e 100644 --- a/generate-code.bat +++ b/generate-code.bat @@ -1,3 +1,4 @@ @echo off SET scriptdir=%~dp0 dotnet run --project "%scriptdir%/CodeGen" +pause