/// <inheritdoc cref="BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double?)"/> public static BrakeSpecificFuelConsumption?KilogramsPerJoule(this decimal?value) => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value == null ? (double?)null : Convert.ToDouble(value.Value));
/// <inheritdoc cref="BrakeSpecificFuelConsumption.FromKilogramsPerJoule(UnitsNet.QuantityValue)" /> public static BrakeSpecificFuelConsumption KilogramsPerJoule <T>(this T value) => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(Convert.ToDouble(value));
public void DoubleDividedBySpecificEnergyEqualsBrakeSpecificFuelConsumption() { BrakeSpecificFuelConsumption bsfc = 2.0 / SpecificEnergy.FromJoulesPerKilogram(4.0); Assert.Equal(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(0.5), bsfc); }
public void CompareToThrowsOnNull() { BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); Assert.Throws <ArgumentNullException>(() => kilogramperjoule.CompareTo(null)); }
public void EqualsReturnsFalseOnTypeMismatch() { BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); Assert.False(kilogramperjoule.Equals(new object())); }
public void GetHashCode_Equals() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); Assert.Equal(new { BrakeSpecificFuelConsumption.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
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); }
public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { var v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1), -1, ComparisonType.Relative)); }
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());
public void FromKilogramsPerJoule_WithNanValue_CreateQuantityAndAffectNaNValue() { var nanQuantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.NaN); Assert.True(double.IsNaN(nanQuantity.Value)); }
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);
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); Assert.Equal(BrakeSpecificFuelConsumption.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void Convert_ToDateTime_ThrowsInvalidCastException() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity)); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); Assert.Equal(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(-value), -quantity); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
public void CompareToThrowsOnTypeMismatch() { BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); Assert.Throws <ArgumentException>(() => kilogramperjoule.CompareTo(new object())); }
public void Convert_ToString_EqualsToString() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
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))); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void EqualsReturnsFalseOnNull() { BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); Assert.False(kilogramperjoule.Equals(null)); }
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)); }
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); Assert.Equal(QuantityType.BrakeSpecificFuelConsumption, Convert.ChangeType(quantity, typeof(QuantityType))); }
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);