/// <inheritdoc cref="BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double?)"/>
 public static BrakeSpecificFuelConsumption?KilogramsPerJoule(this decimal?value) => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value == null ? (double?)null : Convert.ToDouble(value.Value));
예제 #2
0
 /// <inheritdoc cref="BrakeSpecificFuelConsumption.FromKilogramsPerJoule(UnitsNet.QuantityValue)" />
 public static BrakeSpecificFuelConsumption KilogramsPerJoule <T>(this T value) =>
 BrakeSpecificFuelConsumption.FromKilogramsPerJoule(Convert.ToDouble(value));
예제 #3
0
        public void DoubleDividedBySpecificEnergyEqualsBrakeSpecificFuelConsumption()
        {
            BrakeSpecificFuelConsumption bsfc = 2.0 / SpecificEnergy.FromJoulesPerKilogram(4.0);

            Assert.Equal(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(0.5), bsfc);
        }
예제 #4
0
        public void CompareToThrowsOnNull()
        {
            BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            Assert.Throws <ArgumentNullException>(() => kilogramperjoule.CompareTo(null));
        }
예제 #5
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            Assert.False(kilogramperjoule.Equals(new object()));
        }
예제 #6
0
        public void GetHashCode_Equals()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal(new { BrakeSpecificFuelConsumption.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
예제 #7
0
        public void ArithmeticOperators()
        {
            BrakeSpecificFuelConsumption v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            AssertEx.EqualTolerance(-1, -v.KilogramsPerJoule, KilogramsPerJouleTolerance);
            AssertEx.EqualTolerance(2, (BrakeSpecificFuelConsumption.FromKilogramsPerJoule(3) - v).KilogramsPerJoule, KilogramsPerJouleTolerance);
            AssertEx.EqualTolerance(2, (v + v).KilogramsPerJoule, KilogramsPerJouleTolerance);
            AssertEx.EqualTolerance(10, (v * 10).KilogramsPerJoule, KilogramsPerJouleTolerance);
            AssertEx.EqualTolerance(10, (10 * v).KilogramsPerJoule, KilogramsPerJouleTolerance);
            AssertEx.EqualTolerance(2, (BrakeSpecificFuelConsumption.FromKilogramsPerJoule(10) / 5).KilogramsPerJoule, KilogramsPerJouleTolerance);
            AssertEx.EqualTolerance(2, BrakeSpecificFuelConsumption.FromKilogramsPerJoule(10) / BrakeSpecificFuelConsumption.FromKilogramsPerJoule(5), KilogramsPerJouleTolerance);
        }
예제 #8
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1), -1, ComparisonType.Relative));
        }
예제 #9
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
 public void NumberToKilogramsPerJouleTest() =>
 Assert.Equal(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2), 2.KilogramsPerJoule());
예제 #11
0
        public void FromKilogramsPerJoule_WithNanValue_CreateQuantityAndAffectNaNValue()
        {
            var nanQuantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.NaN);

            Assert.True(double.IsNaN(nanQuantity.Value));
        }
예제 #12
0
 public static BrakeSpecificFuelConsumption?KilogramsPerJoule <T>(this T?value) where T : struct => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value == null ? (double?)null : Convert.ToDouble(value.Value));
        public void ToBaseUnit_ReturnsQuantityWithBaseUnit()
        {
            var quantityInBaseUnit = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1).ToBaseUnit();

            Assert.Equal(BrakeSpecificFuelConsumption.BaseUnit, quantityInBaseUnit.Unit);
        }
 /// <inheritdoc cref="BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double?)"/>
 public static BrakeSpecificFuelConsumption?KilogramsPerJoule(this double?value) => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value);
예제 #15
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal(BrakeSpecificFuelConsumption.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
예제 #16
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
예제 #17
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
예제 #18
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
예제 #19
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value);

            Assert.Equal(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(-value), -quantity);
        }
예제 #20
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
예제 #21
0
        public void CompareToThrowsOnTypeMismatch()
        {
            BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            Assert.Throws <ArgumentException>(() => kilogramperjoule.CompareTo(new object()));
        }
예제 #22
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
예제 #23
0
        public void EqualsIsImplemented()
        {
            BrakeSpecificFuelConsumption v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            Assert.True(v.Equals(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1), BrakeSpecificFuelConsumption.FromKilogramsPerJoule(KilogramsPerJouleTolerance)));
            Assert.False(v.Equals(BrakeSpecificFuelConsumption.Zero, BrakeSpecificFuelConsumption.FromKilogramsPerJoule(KilogramsPerJouleTolerance)));
        }
예제 #24
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
예제 #25
0
        public void EqualsReturnsFalseOnNull()
        {
            BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            Assert.False(kilogramperjoule.Equals(null));
        }
예제 #26
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(BrakeSpecificFuelConsumptionUnit)));
        }
 /// <summary>Get <see cref="BrakeSpecificFuelConsumption"/> from <see cref="double"/> divided by <see cref="SpecificEnergy"/>.</summary>
 public static BrakeSpecificFuelConsumption operator /(double value, SpecificEnergy specificEnergy)
 {
     return(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value / specificEnergy.JoulesPerKilogram));
 }
예제 #28
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal(QuantityType.BrakeSpecificFuelConsumption, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
예제 #29
0
        public void SpecificEnergyTimesBrakeSpecificFuelConsumptionEqualsEnergy()
        {
            double value = SpecificEnergy.FromJoulesPerKilogram(10.0) * BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0);

            Assert.Equal(200d, value);
        }
 /// <inheritdoc cref="BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double)"/>
 public static BrakeSpecificFuelConsumption KilogramsPerJoule(this float value) => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value);