public void ComparisonOperators() { AreaDensity oneKilogramPerSquareMeter = AreaDensity.FromKilogramsPerSquareMeter(1); AreaDensity twoKilogramsPerSquareMeter = AreaDensity.FromKilogramsPerSquareMeter(2); Assert.True(oneKilogramPerSquareMeter < twoKilogramsPerSquareMeter); Assert.True(oneKilogramPerSquareMeter <= twoKilogramsPerSquareMeter); Assert.True(twoKilogramsPerSquareMeter > oneKilogramPerSquareMeter); Assert.True(twoKilogramsPerSquareMeter >= oneKilogramPerSquareMeter); Assert.False(oneKilogramPerSquareMeter > twoKilogramsPerSquareMeter); Assert.False(oneKilogramPerSquareMeter >= twoKilogramsPerSquareMeter); Assert.False(twoKilogramsPerSquareMeter < oneKilogramPerSquareMeter); Assert.False(twoKilogramsPerSquareMeter <= oneKilogramPerSquareMeter); }
public void EqualityOperators() { var a = AreaDensity.FromKilogramsPerSquareMeter(1); var b = AreaDensity.FromKilogramsPerSquareMeter(2); // ReSharper disable EqualExpressionComparison Assert.True(a == a); Assert.False(a != a); Assert.True(a != b); Assert.False(a == b); Assert.False(a == null); Assert.False(null == a); // ReSharper restore EqualExpressionComparison }
public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = AreaDensity.FromKilogramsPerSquareMeter(1).ToBaseUnit(); Assert.Equal(AreaDensity.BaseUnit, quantityInBaseUnit.Unit); }
/// <inheritdoc cref="AreaDensity.FromKilogramsPerSquareMeter(double?)"/> public static AreaDensity?KilogramsPerSquareMeter(this decimal?value) => AreaDensity.FromKilogramsPerSquareMeter(value == null ? (double?)null : Convert.ToDouble(value.Value));
/// <inheritdoc cref="AreaDensity.FromKilogramsPerSquareMeter(double)"/> public static AreaDensity KilogramsPerSquareMeter(this double value) => AreaDensity.FromKilogramsPerSquareMeter(value);
public void As() { var kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.KilogramPerSquareMeter), KilogramsPerSquareMeterTolerance); }
public void EqualsReturnsFalseOnNull() { AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); Assert.False(kilogrampersquaremeter.Equals(null)); }
public void CompareToThrowsOnNull() { AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); Assert.Throws <ArgumentNullException>(() => kilogrampersquaremeter.CompareTo(null)); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); Assert.Equal(AreaDensity.FromKilogramsPerSquareMeter(-value), -quantity); }
public void Convert_ToInt16_EqualsValueAsSameType() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); }
public void Convert_ToDecimal_EqualsValueAsSameType() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); }
public void Convert_ToDateTime_ThrowsInvalidCastException() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity)); }
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
public void ToString_NullArgs_ThrowsArgumentNullException() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null)); }
public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { var v = AreaDensity.FromKilogramsPerSquareMeter(1); Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(AreaDensity.FromKilogramsPerSquareMeter(1), -1, ComparisonType.Relative)); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void GetHashCode_Equals() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Equal(new { AreaDensity.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
public void CompareToThrowsOnTypeMismatch() { AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); Assert.Throws <ArgumentException>(() => kilogrampersquaremeter.CompareTo(new object())); }
public void Convert_ToString_EqualsToString() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void EqualsReturnsFalseOnTypeMismatch() { AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); Assert.False(kilogrampersquaremeter.Equals(new object())); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void KilogramPerSquareMeterToAreaDensityUnits() { AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); }
public void Convert_ChangeType_SelfType_EqualsSelf() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(AreaDensity))); }
public void ConversionRoundTrip() { AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); AssertEx.EqualTolerance(1, AreaDensity.FromKilogramsPerSquareMeter(kilogrampersquaremeter.KilogramsPerSquareMeter).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AreaDensityUnit))); }
/// <inheritdoc cref="AreaDensity.FromKilogramsPerSquareMeter(double?)"/> public static AreaDensity?KilogramsPerSquareMeter(this float?value) => AreaDensity.FromKilogramsPerSquareMeter(value);
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Equal(QuantityType.AreaDensity, Convert.ChangeType(quantity, typeof(QuantityType))); }
/// <inheritdoc cref="AreaDensity.FromKilogramsPerSquareMeter(UnitsNet.QuantityValue)" /> public static AreaDensity KilogramsPerSquareMeter <T>(this T value) => AreaDensity.FromKilogramsPerSquareMeter(Convert.ToDouble(value));
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); Assert.Equal(AreaDensity.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }