Пример #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);
        }
Пример #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);
        }
Пример #3
0
 /// <inheritdoc cref="Energy.FromErgs(UnitsNet.QuantityValue)" />
 public static Energy Ergs <T>(this T value) =>
 Energy.FromErgs(Convert.ToDouble(value));
 public void NumberToErgsTest() =>
 Assert.Equal(Energy.FromErgs(2), 2.Ergs());
Пример #5
0
 /// <inheritdoc cref="Energy.FromErgs(double?)"/>
 public static Energy?Ergs(this decimal?value) => Energy.FromErgs(value == null ? (double?)null : Convert.ToDouble(value.Value));
Пример #6
0
 /// <inheritdoc cref="Energy.FromErgs(double)"/>
 public static Energy Ergs(this decimal value) => Energy.FromErgs(Convert.ToDouble(value));
Пример #7
0
 /// <inheritdoc cref="Energy.FromErgs(double?)"/>
 public static Energy?Ergs(this float?value) => Energy.FromErgs(value);
Пример #8
0
 /// <inheritdoc cref="Energy.FromErgs(double?)"/>
 public static Energy?Ergs(this double?value) => Energy.FromErgs(value);
Пример #9
0
 /// <inheritdoc cref="Energy.FromErgs(double?)"/>
 public static Energy?Ergs(this long?value) => Energy.FromErgs(value);
Пример #10
0
 /// <inheritdoc cref="Energy.FromErgs(double)"/>
 public static Energy Ergs(this int value) => Energy.FromErgs(value);
 public static Energy?Ergs <T>(this T?value) where T : struct => Energy.FromErgs(value == null ? (double?)null : Convert.ToDouble(value.Value));