public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { var quantity00 = HeatCapacity.From(1, HeatCapacityUnit.BTUPerFahrenheitDegree); AssertEx.EqualTolerance(1, quantity00.BTUPerFahrenheitDegrees, BTUPerFahrenheitDegreesTolerance); Assert.Equal(HeatCapacityUnit.BTUPerFahrenheitDegree, quantity00.Unit); }
public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { var quantity = new HeatCapacity(); Assert.Equal(0, quantity.Value); Assert.Equal(HeatCapacityUnit.BTUPerFahrenheitDegree, quantity.Unit); }
public void Equals_RelativeTolerance_IsImplemented() { var v = HeatCapacity.FromBTUPerFahrenheitDegrees(1); Assert.True(v.Equals(HeatCapacity.FromBTUPerFahrenheitDegrees(1), BTUPerFahrenheitDegreesTolerance, ComparisonType.Relative)); Assert.False(v.Equals(HeatCapacity.Zero, BTUPerFahrenheitDegreesTolerance, ComparisonType.Relative)); }
public void Equals_SameType_IsImplemented() { var a = HeatCapacity.FromBTUPerFahrenheitDegrees(1); var b = HeatCapacity.FromBTUPerFahrenheitDegrees(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); }
public void CompareToIsImplemented() { HeatCapacity btuperfahrenheitdegree = HeatCapacity.FromBTUPerFahrenheitDegrees(1); Assert.Equal(0, btuperfahrenheitdegree.CompareTo(btuperfahrenheitdegree)); Assert.True(btuperfahrenheitdegree.CompareTo(HeatCapacity.Zero) > 0); Assert.True(HeatCapacity.Zero.CompareTo(btuperfahrenheitdegree) < 0); }
public void ToUnit() { var btuperfahrenheitdegree = HeatCapacity.FromBTUPerFahrenheitDegrees(1); var btuperfahrenheitdegreeQuantity = btuperfahrenheitdegree.ToUnit(HeatCapacityUnit.BTUPerFahrenheitDegree); AssertEx.EqualTolerance(BTUPerFahrenheitDegreesInOneBTUPerFahrenheitDegree, (double)btuperfahrenheitdegreeQuantity.Value, BTUPerFahrenheitDegreesTolerance); Assert.Equal(HeatCapacityUnit.BTUPerFahrenheitDegree, btuperfahrenheitdegreeQuantity.Unit); }
public void Equals_QuantityAsObject_IsImplemented() { object a = HeatCapacity.FromBTUPerFahrenheitDegrees(1); object b = HeatCapacity.FromBTUPerFahrenheitDegrees(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); Assert.False(a.Equals((object)null)); }
public void ArithmeticOperators() { HeatCapacity v = HeatCapacity.FromBTUPerFahrenheitDegrees(1); AssertEx.EqualTolerance(-1, -v.BTUPerFahrenheitDegrees, BTUPerFahrenheitDegreesTolerance); AssertEx.EqualTolerance(2, (HeatCapacity.FromBTUPerFahrenheitDegrees(3) - v).BTUPerFahrenheitDegrees, BTUPerFahrenheitDegreesTolerance); AssertEx.EqualTolerance(2, (v + v).BTUPerFahrenheitDegrees, BTUPerFahrenheitDegreesTolerance); AssertEx.EqualTolerance(10, (v * 10).BTUPerFahrenheitDegrees, BTUPerFahrenheitDegreesTolerance); AssertEx.EqualTolerance(10, (10 * v).BTUPerFahrenheitDegrees, BTUPerFahrenheitDegreesTolerance); AssertEx.EqualTolerance(2, (HeatCapacity.FromBTUPerFahrenheitDegrees(10) / 5).BTUPerFahrenheitDegrees, BTUPerFahrenheitDegreesTolerance); AssertEx.EqualTolerance(2, HeatCapacity.FromBTUPerFahrenheitDegrees(10) / HeatCapacity.FromBTUPerFahrenheitDegrees(5), BTUPerFahrenheitDegreesTolerance); }
public void ComparisonOperators() { HeatCapacity oneBTUPerFahrenheitDegree = HeatCapacity.FromBTUPerFahrenheitDegrees(1); HeatCapacity twoBTUPerFahrenheitDegrees = HeatCapacity.FromBTUPerFahrenheitDegrees(2); Assert.True(oneBTUPerFahrenheitDegree < twoBTUPerFahrenheitDegrees); Assert.True(oneBTUPerFahrenheitDegree <= twoBTUPerFahrenheitDegrees); Assert.True(twoBTUPerFahrenheitDegrees > oneBTUPerFahrenheitDegree); Assert.True(twoBTUPerFahrenheitDegrees >= oneBTUPerFahrenheitDegree); Assert.False(oneBTUPerFahrenheitDegree > twoBTUPerFahrenheitDegrees); Assert.False(oneBTUPerFahrenheitDegree >= twoBTUPerFahrenheitDegrees); Assert.False(twoBTUPerFahrenheitDegrees < oneBTUPerFahrenheitDegree); Assert.False(twoBTUPerFahrenheitDegrees <= oneBTUPerFahrenheitDegree); }
public void EqualityOperators() { var a = HeatCapacity.FromBTUPerFahrenheitDegrees(1); var b = HeatCapacity.FromBTUPerFahrenheitDegrees(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 HeatCapacity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() { var quantity = new HeatCapacity(1, HeatCapacityUnit.BTUPerFahrenheitDegree); QuantityInfo <HeatCapacityUnit> quantityInfo = quantity.QuantityInfo; Assert.Equal(HeatCapacity.Zero, quantityInfo.Zero); Assert.Equal("HeatCapacity", quantityInfo.Name); Assert.Equal(QuantityType.HeatCapacity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues <HeatCapacityUnit>().Except(new[] { HeatCapacityUnit.Undefined }).ToArray(); var unitNames = units.Select(x => x.ToString()); // Obsolete members #pragma warning disable 618 Assert.Equal(units, quantityInfo.Units); Assert.Equal(unitNames, quantityInfo.UnitNames); #pragma warning restore 618 }
public void GetHashCode_Equals() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Equal(new { HeatCapacity.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Equal(QuantityType.HeatCapacity, Convert.ChangeType(quantity, typeof(QuantityType))); }
public void Convert_ChangeType_SelfType_EqualsSelf() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(HeatCapacity))); }
public void Convert_ToString_EqualsToString() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void Convert_ToInt16_EqualsValueAsSameType() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { var v = HeatCapacity.FromBTUPerFahrenheitDegrees(1); Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(HeatCapacity.FromBTUPerFahrenheitDegrees(1), -1, ComparisonType.Relative)); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void EqualsReturnsFalseOnTypeMismatch() { HeatCapacity btuperfahrenheitdegree = HeatCapacity.FromBTUPerFahrenheitDegrees(1); Assert.False(btuperfahrenheitdegree.Equals(new object())); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(HeatCapacityUnit))); }
public void EqualsReturnsFalseOnNull() { HeatCapacity btuperfahrenheitdegree = HeatCapacity.FromBTUPerFahrenheitDegrees(1); Assert.False(btuperfahrenheitdegree.Equals(null)); }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Equal(HeatCapacity.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void ToString_NullArgs_ThrowsArgumentNullException() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null)); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(value); Assert.Equal(HeatCapacity.FromBTUPerFahrenheitDegrees(-value), -quantity); }
public void Convert_ToDateTime_ThrowsInvalidCastException() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity)); }
public static HeatCapacity BTUPerFahrenheitDegrees <T>(this T value) => HeatCapacity.FromBTUPerFahrenheitDegrees(Convert.ToDouble(value));
public void Convert_ToDecimal_EqualsValueAsSameType() { var quantity = HeatCapacity.FromBTUPerFahrenheitDegrees(1.0); Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); }