public void TemperatureConvertsFromKelvin() { Temperature T1 = new Temperature(20, TemperatureUnit.Kelvin); Assert.AreEqual(-423.67, (double)T1.As(TemperatureUnit.DegreeFahrenheit), 0.00000001); Assert.AreEqual(20, T1.As(TemperatureUnit.Kelvin)); Assert.AreEqual(-253.15, T1.As(TemperatureUnit.DegreeCelsius)); }
public void TemperatureConvertsFromFahrenheit() { Temperature T1 = new Temperature(20, TemperatureUnit.DegreeFahrenheit); Assert.AreEqual(266.48333333333335, (double)T1.As(TemperatureUnit.Kelvin), 0.0000001); Assert.AreEqual(-6.666667, (double)T1.As(TemperatureUnit.DegreeCelsius), 0.00001); Assert.AreEqual(20, T1.As(TemperatureUnit.DegreeFahrenheit)); }
public void TemperatureConvertsFromCelsius() { Temperature T1 = new Temperature(20, TemperatureUnit.DegreeCelsius); Debug.Print($"{T1}"); Assert.AreEqual(293.15, T1.As(TemperatureUnit.Kelvin)); Assert.AreEqual(20, T1.As(TemperatureUnit.DegreeCelsius)); Assert.AreEqual(68, (double)T1.As(TemperatureUnit.DegreeFahrenheit), 0.000001); }
public void TemperatureCelsiusTimesDouble() { Temperature T1 = new Temperature(20, TemperatureUnit.DegreeCelsius); T1 *= 10; Assert.AreEqual(2658.35, T1.As(TemperatureUnit.DegreeCelsius)); Assert.AreEqual(2931.5, T1.As(TemperatureUnit.Kelvin)); }
public void TemperatureCelsiusDivideDouble() { Temperature T1 = new Temperature(20, TemperatureUnit.DegreeCelsius); T1 /= 10; Assert.AreEqual(-243.835, T1.As(TemperatureUnit.DegreeCelsius)); Assert.AreEqual(29.315, T1.As(TemperatureUnit.Kelvin)); }
public void TemperatureConvertsFromCelsiusJSON() { Temperature T1 = new Temperature(20, TemperatureUnit.DegreeCelsius); string jsonstring = JsonConvert.SerializeObject(T1); Temperature JSON = JsonConvert.DeserializeObject <Temperature>(jsonstring); Assert.AreEqual(293.15, JSON.As(TemperatureUnit.Kelvin)); Assert.AreEqual(20, JSON.As(TemperatureUnit.DegreeCelsius)); Assert.AreEqual(68, (double)JSON.As(TemperatureUnit.DegreeFahrenheit), 0.000001); }
public void TemperatureKelvinTimesDouble() { Temperature T1 = new Temperature(20, TemperatureUnit.Kelvin); T1 *= 10; Assert.AreEqual(200, T1.As(TemperatureUnit.Kelvin)); }
public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { var quantity = new Temperature(value: 1, unit: Temperature.BaseUnit); Func <object> AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) { var value = (double)AsWithSIUnitSystem(); Assert.Equal(1, value); } else { Assert.Throws <ArgumentException>(AsWithSIUnitSystem); } }
public void TemperatureAdd() { Temperature T1 = new Temperature(20, TemperatureUnit.DegreeCelsius); Temperature T2 = new Temperature(293.15, TemperatureUnit.Kelvin); Temperature T3 = new Temperature(68, TemperatureUnit.DegreeFahrenheit); //Debug.WriteLine($"{T1}"); Temperature T4 = T1 + T1; Temperature T5 = T2 + T2; Temperature T6 = T3 + T3; Assert.AreEqual(586.3, (double)T4.As(TemperatureUnit.Kelvin), 0.0000001); Assert.AreEqual(313.15, (double)T5.As(TemperatureUnit.DegreeCelsius), 0.00001); Assert.AreEqual(595.67, (double)T6.As(TemperatureUnit.DegreeFahrenheit)); }
public void TemperatureAdd2() { Temperature T1 = new Temperature(0, TemperatureUnit.DegreeCelsius); Temperature T2 = new Temperature(0, TemperatureUnit.Kelvin); Temperature T3 = new Temperature(0, TemperatureUnit.DegreeFahrenheit); //Debug.WriteLine($"{T1}"); Temperature T4 = T1 + T1; Temperature T5 = T2 + T2; Temperature T6 = T3 + T3; Assert.AreEqual(546.3, (double)T4.As(TemperatureUnit.Kelvin), 0.0000001); Assert.AreEqual(0, (double)T5.As(TemperatureUnit.Kelvin), 0.00001); Assert.AreEqual(510.7444444444444, (double)T6.As(TemperatureUnit.Kelvin)); }