Skip to content

Commit 1d719a8

Browse files
Ferit Tunçerangularsen
authored andcommitted
Add TemperatureDelta times SpecificEntropy equals SpecificEnergy (#355)
1 parent d5a30b1 commit 1d719a8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3939
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4040
// THE SOFTWARE.
41-
41+
using System;
42+
using Xunit;
4243

4344
namespace UnitsNet.Tests.CustomCode
4445
{
@@ -61,5 +62,12 @@ public class TemperatureDeltaTests : TemperatureDeltaTestsBase
6162
protected override double DegreesReaumurInOneKelvin => 0.8;
6263
protected override double DegreesRoemerInOneKelvin => 21 / 40d;
6364
protected override double KelvinsInOneKelvin => 1;
65+
66+
[Fact]
67+
public void TemperatureDeltaTimesSpecificEntropyEqualsSpecificEnergy()
68+
{
69+
SpecificEnergy specificEnergy = SpecificEntropy.FromJoulesPerKilogramKelvin(10) * TemperatureDelta.FromKelvins(6);
70+
Assert.Equal(specificEnergy, SpecificEnergy.FromJoulesPerKilogram(60));
71+
}
6472
}
6573
}

UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ public partial struct TemperatureDelta
3838
{
3939
return LapseRate.FromDegreesCelciusPerKilometer(left.DegreesCelsiusDelta / right.Kilometers);
4040
}
41+
42+
public static SpecificEnergy operator *(SpecificEntropy specificEntropy, TemperatureDelta temperatureDelta)
43+
{
44+
return SpecificEnergy.FromJoulesPerKilogram(specificEntropy.JoulesPerKilogramKelvin * temperatureDelta.Kelvins);
45+
}
46+
47+
public static SpecificEnergy operator *(TemperatureDelta temperatureDelta, SpecificEntropy specificEntropy)
48+
{
49+
return specificEntropy * temperatureDelta;
50+
}
4151
#endif
4252
}
4353
}

0 commit comments

Comments
 (0)