Ejemplo n.º 1
0
 public void StaticFromDoubleToKelvinBoilingPointTest() => Assert.AreEqual(expected: Constants.BoilingPointH2OInKelvin, Delisle.ToKelvin(Constants.BoilingPointH2OInDelisle).Value);
Ejemplo n.º 2
0
            public void DemoTest()
            {
                // Unit creation
                var delisle = new Delisle(Constants.MeltingPointH2OInDelisle);

                Assert.AreEqual(Constants.MeltingPointH2OInDelisle, delisle.Value);

                delisle = new Delisle("50.8 °D");
                Assert.AreEqual(new Delisle(50.8), delisle);

                delisle = new Delisle("273.15 K");
                Assert.AreEqual(new Kelvin(Constants.MeltingPointH2OInKelvin), delisle);


                var fahrenheit = new Fahrenheit(Constants.MeltingPointH2OInFahrenheit);
                var delisle2   = new Delisle(fahrenheit);

                Assert.AreEqual(fahrenheit, delisle2);


                // Arithmetic
                var delisle3 = delisle + delisle2;

                Assert.AreEqual(2 * Constants.MeltingPointH2OInDelisle, delisle3.Value);
                var delisle4 = delisle + fahrenheit;

                Assert.AreEqual(2 * Constants.MeltingPointH2OInDelisle, delisle4.Value);
                delisle3 = delisle2 - delisle;
                Assert.AreEqual(2 * Constants.MeltingPointH2OInDelisle, delisle3.Value);
                delisle4 = delisle2 - fahrenheit;
                Assert.AreEqual(2 * Constants.MeltingPointH2OInDelisle, delisle4.Value);

                delisle3.Value = 20;
                delisle4.Value = 30;

                delisle3 += delisle4;
                Assert.AreEqual(50, delisle3.Value);
                delisle3 -= delisle4;
                Assert.AreEqual(80, delisle3.Value);

                // OOP Conversion
                delisle = new Delisle(fahrenheit.ToDelisle());
                Assert.AreEqual(delisle, fahrenheit);
                delisle = Delisle.ToDelisle(fahrenheit);
                Assert.AreEqual(fahrenheit, delisle);

                double someTemperatureInDelisle = Converter.Fah2Del(Constants.BoilingPointH2OInFahrenheit);
                double newValueInKelvin         = Delisle.ToKelvin(someTemperatureInDelisle).Value;

                Assert.AreEqual(someTemperatureInDelisle, Converter.Kel2Del(newValueInKelvin), OperationOverDoublePrecision.HighPrecision);

                // Comparison
                delisle.Value  = 20;
                delisle2.Value = 20;

                Assert.AreEqual(delisle, delisle2);

                delisle    = new Delisle(Constants.AbsoluteZeroInDelisle);
                fahrenheit = new Fahrenheit(Constants.AbsoluteZeroInFahrenheit);

                Assert.AreEqual(delisle, fahrenheit);
            }
Ejemplo n.º 3
0
 public void StaticFromDoubleToKelvinAbsoluteZeroTest() => Assert.AreEqual(expected: Constants.AbsoluteZeroInKelvin, Delisle.ToKelvin(Constants.AbsoluteZeroInDelisle).Value);