|
1 | 1 | // Copyright (c) 2013 Andreas Gullberg Larsen ([email protected]).
|
2 | 2 | // https://github.com/angularsen/UnitsNet
|
3 |
| -// |
| 3 | +// |
4 | 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
|
5 | 5 | // of this software and associated documentation files (the "Software"), to deal
|
6 | 6 | // in the Software without restriction, including without limitation the rights
|
7 | 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8 | 8 | // copies of the Software, and to permit persons to whom the Software is
|
9 | 9 | // furnished to do so, subject to the following conditions:
|
10 |
| -// |
| 10 | +// |
11 | 11 | // The above copyright notice and this permission notice shall be included in
|
12 | 12 | // all copies or substantial portions of the Software.
|
13 |
| -// |
| 13 | +// |
14 | 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15 | 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16 | 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
@@ -45,46 +45,6 @@ public class TemperatureTests : TemperatureTestsBase
|
45 | 45 |
|
46 | 46 | protected override double KelvinsInOneKelvin => 1;
|
47 | 47 |
|
48 |
| - [SuppressMessage("ReSharper", "ImpureMethodCallOnReadonlyValueField", |
49 |
| - Justification = "R# incorrectly identifies method as impure, due to internal method calls.")] |
50 |
| - [Theory] |
51 |
| - [InlineData(TemperatureUnit.DegreeCelsius, 10, 1, "10 °C")] |
52 |
| - [InlineData(TemperatureUnit.DegreeCelsius, 10, 5, "2 °C")] |
53 |
| - [InlineData(TemperatureUnit.DegreeCelsius, 10, -10, "-1 °C")] |
54 |
| - [InlineData(TemperatureUnit.DegreeFahrenheit, 10, 1, "10 °F")] |
55 |
| - [InlineData(TemperatureUnit.DegreeFahrenheit, 10, 5, "2 °F")] |
56 |
| - [InlineData(TemperatureUnit.DegreeFahrenheit, 10, -10, "-1 °F")] |
57 |
| - public void DividedByTemperatureDeltaEqualsTemperature(TemperatureUnit unit, int temperatureVal, int divisor, string expected) |
58 |
| - { |
59 |
| - Temperature temperature = Temperature.From(temperatureVal, unit); |
60 |
| - |
61 |
| - // Act |
62 |
| - Temperature resultTemp = temperature.Divide(divisor, unit); |
63 |
| - |
64 |
| - string actual = resultTemp.ToUnit(unit).ToString(CultureInfo.InvariantCulture, "{0:0} {1}"); |
65 |
| - Assert.Equal(expected, actual); |
66 |
| - } |
67 |
| - |
68 |
| - [SuppressMessage("ReSharper", "ImpureMethodCallOnReadonlyValueField", |
69 |
| - Justification = "R# incorrectly identifies method as impure, due to internal method calls.")] |
70 |
| - [Theory] |
71 |
| - [InlineData(TemperatureUnit.DegreeCelsius, 10, 0, "0 °C")] |
72 |
| - [InlineData(TemperatureUnit.DegreeCelsius, 10, 5, "50 °C")] |
73 |
| - [InlineData(TemperatureUnit.DegreeCelsius, 10, -5, "-50 °C")] |
74 |
| - [InlineData(TemperatureUnit.DegreeFahrenheit, 10, 0, "0 °F")] |
75 |
| - [InlineData(TemperatureUnit.DegreeFahrenheit, 10, 5, "50 °F")] |
76 |
| - [InlineData(TemperatureUnit.DegreeFahrenheit, 10, -5, "-50 °F")] |
77 |
| - public void MultiplyByTemperatureDeltaEqualsTemperature(TemperatureUnit unit, int temperatureVal, int factor, string expected) |
78 |
| - { |
79 |
| - Temperature temperature = Temperature.From(temperatureVal, unit); |
80 |
| - |
81 |
| - // Act |
82 |
| - Temperature resultTemp = temperature.Multiply(factor, unit); |
83 |
| - |
84 |
| - string actual = resultTemp.ToUnit(unit).ToString(CultureInfo.InvariantCulture, "{0:0} {1}"); |
85 |
| - Assert.Equal(expected, actual); |
86 |
| - } |
87 |
| - |
88 | 48 | [Theory]
|
89 | 49 | [InlineData(TemperatureUnit.DegreeCelsius, -10, 0, "-10 °C")]
|
90 | 50 | [InlineData(TemperatureUnit.DegreeCelsius, -10, 10, "0 °C")]
|
@@ -141,5 +101,24 @@ public void TemperaturePlusTemperatureDeltaEqualsTemperature(TemperatureUnit uni
|
141 | 101 | string actual = resultTemp.ToUnit(unit).ToString(CultureInfo.InvariantCulture, "{0:0} {1}");
|
142 | 102 | Assert.Equal(expected, actual);
|
143 | 103 | }
|
| 104 | + |
| 105 | + [Theory] |
| 106 | + [InlineData(TemperatureUnit.DegreeCelsius, 30, 20, "10 ∆°C")] |
| 107 | + [InlineData(TemperatureUnit.DegreeCelsius, 20, 30, "-10 ∆°C")] |
| 108 | + [InlineData(TemperatureUnit.DegreeFahrenheit, 30, 20, "10 ∆°F")] |
| 109 | + [InlineData(TemperatureUnit.DegreeFahrenheit, 20, 30, "-10 ∆°F")] |
| 110 | + [InlineData(TemperatureUnit.Kelvin, 30, 20, "10 ∆K")] |
| 111 | + [InlineData(TemperatureUnit.Kelvin, 20, 30, "-10 ∆K")] |
| 112 | + public void ToDelta_ReturnsDeltaOfTwoTemperaturesInSameUnit(TemperatureUnit unit, int value, int otherValue, string expected) |
| 113 | + { |
| 114 | + Temperature temperature = Temperature.From(value, unit); |
| 115 | + Temperature otherTemperature = Temperature.From(otherValue, unit); |
| 116 | + |
| 117 | + // Act |
| 118 | + var delta = temperature.ToDelta(otherTemperature); |
| 119 | + |
| 120 | + // Assert |
| 121 | + Assert.Equal(expected, delta.ToString(CultureInfo.InvariantCulture, "{0:0} {1}")); |
| 122 | + } |
144 | 123 | }
|
145 | 124 | }
|
0 commit comments