コード例 #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
 /// <inheritdoc cref="Energy.FromDecathermsUs(UnitsNet.QuantityValue)" />
 public static Energy DecathermsUs <T>(this T value) =>
 Energy.FromDecathermsUs(Convert.ToDouble(value));
コード例 #3
0
 /// <inheritdoc cref="Energy.FromDecathermsUs(double?)"/>
 public static Energy?DecathermsUs(this decimal?value) => Energy.FromDecathermsUs(value == null ? (double?)null : Convert.ToDouble(value.Value));
コード例 #4
0
 public void NumberToDecathermsUsTest() =>
 Assert.Equal(Energy.FromDecathermsUs(2), 2.DecathermsUs());
コード例 #5
0
 /// <inheritdoc cref="Energy.FromDecathermsUs(double)"/>
 public static Energy DecathermsUs(this decimal value) => Energy.FromDecathermsUs(Convert.ToDouble(value));
コード例 #6
0
 /// <inheritdoc cref="Energy.FromDecathermsUs(double?)"/>
 public static Energy?DecathermsUs(this float?value) => Energy.FromDecathermsUs(value);
コード例 #7
0
 /// <inheritdoc cref="Energy.FromDecathermsUs(double?)"/>
 public static Energy?DecathermsUs(this double?value) => Energy.FromDecathermsUs(value);
コード例 #8
0
 /// <inheritdoc cref="Energy.FromDecathermsUs(double)"/>
 public static Energy DecathermsUs(this long value) => Energy.FromDecathermsUs(value);
コード例 #9
0
 public static Energy?DecathermsUs <T>(this T?value) where T : struct => Energy.FromDecathermsUs(value == null ? (double?)null : Convert.ToDouble(value.Value));