Esempio n. 1
0
        public void ConversionRoundTrip()
        {
            Energy joule = Energy.FromJoules(1);

            AssertEx.EqualTolerance(1, Energy.FromBritishThermalUnits(joule.BritishThermalUnits).Joules, BritishThermalUnitsTolerance);
            AssertEx.EqualTolerance(1, Energy.FromCalories(joule.Calories).Joules, CaloriesTolerance);
            AssertEx.EqualTolerance(1, Energy.FromDecathermsEc(joule.DecathermsEc).Joules, DecathermsEcTolerance);
            AssertEx.EqualTolerance(1, Energy.FromDecathermsImperial(joule.DecathermsImperial).Joules, DecathermsImperialTolerance);
            AssertEx.EqualTolerance(1, Energy.FromDecathermsUs(joule.DecathermsUs).Joules, DecathermsUsTolerance);
            AssertEx.EqualTolerance(1, Energy.FromElectronVolts(joule.ElectronVolts).Joules, ElectronVoltsTolerance);
            AssertEx.EqualTolerance(1, Energy.FromErgs(joule.Ergs).Joules, ErgsTolerance);
            AssertEx.EqualTolerance(1, Energy.FromFootPounds(joule.FootPounds).Joules, FootPoundsTolerance);
            AssertEx.EqualTolerance(1, Energy.FromGigabritishThermalUnits(joule.GigabritishThermalUnits).Joules, GigabritishThermalUnitsTolerance);
            AssertEx.EqualTolerance(1, Energy.FromGigawattHours(joule.GigawattHours).Joules, GigawattHoursTolerance);
            AssertEx.EqualTolerance(1, Energy.FromJoules(joule.Joules).Joules, JoulesTolerance);
            AssertEx.EqualTolerance(1, Energy.FromKilobritishThermalUnits(joule.KilobritishThermalUnits).Joules, KilobritishThermalUnitsTolerance);
            AssertEx.EqualTolerance(1, Energy.FromKilocalories(joule.Kilocalories).Joules, KilocaloriesTolerance);
            AssertEx.EqualTolerance(1, Energy.FromKilojoules(joule.Kilojoules).Joules, KilojoulesTolerance);
            AssertEx.EqualTolerance(1, Energy.FromKilowattHours(joule.KilowattHours).Joules, KilowattHoursTolerance);
            AssertEx.EqualTolerance(1, Energy.FromMegabritishThermalUnits(joule.MegabritishThermalUnits).Joules, MegabritishThermalUnitsTolerance);
            AssertEx.EqualTolerance(1, Energy.FromMegajoules(joule.Megajoules).Joules, MegajoulesTolerance);
            AssertEx.EqualTolerance(1, Energy.FromMegawattHours(joule.MegawattHours).Joules, MegawattHoursTolerance);
            AssertEx.EqualTolerance(1, Energy.FromThermsEc(joule.ThermsEc).Joules, ThermsEcTolerance);
            AssertEx.EqualTolerance(1, Energy.FromThermsImperial(joule.ThermsImperial).Joules, ThermsImperialTolerance);
            AssertEx.EqualTolerance(1, Energy.FromThermsUs(joule.ThermsUs).Joules, ThermsUsTolerance);
            AssertEx.EqualTolerance(1, Energy.FromWattHours(joule.WattHours).Joules, WattHoursTolerance);
        }
Esempio n. 2
0
        public void ConversionRoundTrip()
        {
            Energy joule = Energy.FromJoules(1);

            Assert.AreEqual(1, Energy.FromBritishThermalUnits(joule.BritishThermalUnits).Joules, BritishThermalUnitsTolerance);
            Assert.AreEqual(1, Energy.FromCalories(joule.Calories).Joules, CaloriesTolerance);
            Assert.AreEqual(1, Energy.FromElectronVolts(joule.ElectronVolts).Joules, ElectronVoltsTolerance);
            Assert.AreEqual(1, Energy.FromErgs(joule.Ergs).Joules, ErgsTolerance);
            Assert.AreEqual(1, Energy.FromFootPounds(joule.FootPounds).Joules, FootPoundsTolerance);
            Assert.AreEqual(1, Energy.FromGigawattHours(joule.GigawattHours).Joules, GigawattHoursTolerance);
            Assert.AreEqual(1, Energy.FromJoules(joule.Joules).Joules, JoulesTolerance);
            Assert.AreEqual(1, Energy.FromKilocalories(joule.Kilocalories).Joules, KilocaloriesTolerance);
            Assert.AreEqual(1, Energy.FromKilojoules(joule.Kilojoules).Joules, KilojoulesTolerance);
            Assert.AreEqual(1, Energy.FromKilowattHours(joule.KilowattHours).Joules, KilowattHoursTolerance);
            Assert.AreEqual(1, Energy.FromMegajoules(joule.Megajoules).Joules, MegajoulesTolerance);
            Assert.AreEqual(1, Energy.FromMegawattHours(joule.MegawattHours).Joules, MegawattHoursTolerance);
            Assert.AreEqual(1, Energy.FromWattHours(joule.WattHours).Joules, WattHoursTolerance);
        }
 /// <inheritdoc cref="Energy.FromBritishThermalUnits(UnitsNet.QuantityValue)" />
 public static Energy BritishThermalUnits <T>(this T value) =>
 Energy.FromBritishThermalUnits(Convert.ToDouble(value));
 public void NumberToBritishThermalUnitsTest() =>
 Assert.Equal(Energy.FromBritishThermalUnits(2), 2.BritishThermalUnits());
Esempio n. 5
0
 /// <inheritdoc cref="Energy.FromBritishThermalUnits(double?)"/>
 public static Energy?BritishThermalUnits(this decimal?value) => Energy.FromBritishThermalUnits(value == null ? (double?)null : Convert.ToDouble(value.Value));
Esempio n. 6
0
 /// <inheritdoc cref="Energy.FromBritishThermalUnits(double?)"/>
 public static Energy?BritishThermalUnits(this float?value) => Energy.FromBritishThermalUnits(value);
Esempio n. 7
0
 /// <inheritdoc cref="Energy.FromBritishThermalUnits(double)"/>
 public static Energy BritishThermalUnits(this double value) => Energy.FromBritishThermalUnits(value);
 public static Energy?BritishThermalUnits <T>(this T?value) where T : struct => Energy.FromBritishThermalUnits(value == null ? (double?)null : Convert.ToDouble(value.Value));