From e1c8592600ca2feea11d7be2053dac0576b5f6e7 Mon Sep 17 00:00:00 2001 From: Tim Borcherding Date: Mon, 26 Feb 2024 13:50:41 +0100 Subject: [PATCH 1/3] Add operator to convert from TemperatureDelta to TemperatureChangeRate. --- UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs | 14 ++++++++++++++ .../Quantities/TemperatureDelta.extra.cs | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs b/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs index 320609c8eb..83e6d42105 100644 --- a/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs +++ b/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs @@ -64,5 +64,19 @@ public void TemperatureDeltaTimesEntropyEqualsEnergy() Energy energy = TemperatureDelta.FromKelvins(20) * Entropy.FromJoulesPerKelvin(4); Assert.Equal(Energy.FromJoules(80), energy); } + + [Fact] + public void TemperatureDeltaDevidedByTimeSpanEqualsTemperatureChangeRate() + { + TemperatureChangeRate changeRate = TemperatureDelta.FromKelvins(20) / TimeSpan.FromSeconds(2); ; + Assert.Equal(TemperatureChangeRate.FromDegreesCelsiusPerSecond(10), changeRate); + } + + [Fact] + public void TemperatureDeltaDevidedByDurationEqualsTemperatureChangeRate() + { + TemperatureChangeRate changeRate = TemperatureDelta.FromKelvins(20) / Duration.FromSeconds(2); ; + Assert.Equal(TemperatureChangeRate.FromDegreesCelsiusPerSecond(10), changeRate); + } } } diff --git a/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs b/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs index e126f14d29..baa8d3e805 100644 --- a/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs +++ b/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs @@ -1,6 +1,8 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. +using System; + namespace UnitsNet { public partial struct TemperatureDelta @@ -40,5 +42,17 @@ public partial struct TemperatureDelta { return temperatureDelta.Kelvins * cte.PerKelvin; } + + /// Get from divided by . + public static TemperatureChangeRate operator /(TemperatureDelta temperatureDelta, TimeSpan timespan) + { + return TemperatureChangeRate.FromDegreesCelsiusPerSecond(temperatureDelta.Kelvins / timespan.TotalSeconds); + } + + /// Get from divided by . + public static TemperatureChangeRate operator /(TemperatureDelta temperatureDelta, Duration duration) + { + return TemperatureChangeRate.FromDegreesCelsiusPerSecond(temperatureDelta.Kelvins / duration.Seconds); + } } } From be2118af88de14116b04aa5b47e3a9dbead2ce7e Mon Sep 17 00:00:00 2001 From: Tim Borcherding Date: Mon, 26 Feb 2024 14:22:36 +0100 Subject: [PATCH 2/3] Fixed spelling error in TemperatureDeltaTests. --- UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs b/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs index 83e6d42105..ac8e045949 100644 --- a/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs +++ b/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs @@ -66,14 +66,14 @@ public void TemperatureDeltaTimesEntropyEqualsEnergy() } [Fact] - public void TemperatureDeltaDevidedByTimeSpanEqualsTemperatureChangeRate() + public void TemperatureDeltaDividedByTimeSpanEqualsTemperatureChangeRate() { TemperatureChangeRate changeRate = TemperatureDelta.FromKelvins(20) / TimeSpan.FromSeconds(2); ; Assert.Equal(TemperatureChangeRate.FromDegreesCelsiusPerSecond(10), changeRate); } [Fact] - public void TemperatureDeltaDevidedByDurationEqualsTemperatureChangeRate() + public void TemperatureDeltaDividedByDurationEqualsTemperatureChangeRate() { TemperatureChangeRate changeRate = TemperatureDelta.FromKelvins(20) / Duration.FromSeconds(2); ; Assert.Equal(TemperatureChangeRate.FromDegreesCelsiusPerSecond(10), changeRate); From cbcac79527e1caaa790dac196d295ec627bd7581 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Fri, 1 Mar 2024 21:13:29 +0100 Subject: [PATCH 3/3] Minor fix --- UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs b/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs index ac8e045949..abf2d33e35 100644 --- a/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs +++ b/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs @@ -68,14 +68,14 @@ public void TemperatureDeltaTimesEntropyEqualsEnergy() [Fact] public void TemperatureDeltaDividedByTimeSpanEqualsTemperatureChangeRate() { - TemperatureChangeRate changeRate = TemperatureDelta.FromKelvins(20) / TimeSpan.FromSeconds(2); ; + TemperatureChangeRate changeRate = TemperatureDelta.FromKelvins(20) / TimeSpan.FromSeconds(2); Assert.Equal(TemperatureChangeRate.FromDegreesCelsiusPerSecond(10), changeRate); } [Fact] public void TemperatureDeltaDividedByDurationEqualsTemperatureChangeRate() { - TemperatureChangeRate changeRate = TemperatureDelta.FromKelvins(20) / Duration.FromSeconds(2); ; + TemperatureChangeRate changeRate = TemperatureDelta.FromKelvins(20) / Duration.FromSeconds(2); Assert.Equal(TemperatureChangeRate.FromDegreesCelsiusPerSecond(10), changeRate); } }