public void Equals_RelativeTolerance_IsImplemented() { var v = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); Assert.True(v.Equals(SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1), JoulePerGramCelciusDegreesTolerance, ComparisonType.Relative)); Assert.False(v.Equals(SpecificHeatEnergy.Zero, JoulePerGramCelciusDegreesTolerance, ComparisonType.Relative)); }
public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { var quantity = new SpecificHeatEnergy(); Assert.Equal(0, quantity.Value); Assert.Equal(SpecificHeatEnergyUnit.JoulePerGramCelciusDegree, quantity.Unit); }
public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { var quantity00 = SpecificHeatEnergy.From(1, SpecificHeatEnergyUnit.JoulePerGramCelciusDegree); AssertEx.EqualTolerance(1, quantity00.JoulePerGramCelciusDegrees, JoulePerGramCelciusDegreesTolerance); Assert.Equal(SpecificHeatEnergyUnit.JoulePerGramCelciusDegree, quantity00.Unit); }
public void CompareToIsImplemented() { SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); Assert.Equal(0, joulepergramcelciusdegree.CompareTo(joulepergramcelciusdegree)); Assert.True(joulepergramcelciusdegree.CompareTo(SpecificHeatEnergy.Zero) > 0); Assert.True(SpecificHeatEnergy.Zero.CompareTo(joulepergramcelciusdegree) < 0); }
public void Equals_SameType_IsImplemented() { var a = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); var b = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); }
public void Equals_QuantityAsObject_IsImplemented() { object a = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); object b = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); Assert.False(a.Equals((object)null)); }
public void ToUnit() { var joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); var joulepergramcelciusdegreeQuantity = joulepergramcelciusdegree.ToUnit(SpecificHeatEnergyUnit.JoulePerGramCelciusDegree); AssertEx.EqualTolerance(JoulePerGramCelciusDegreesInOneJoulePerGramCelciusDegree, (double)joulepergramcelciusdegreeQuantity.Value, JoulePerGramCelciusDegreesTolerance); Assert.Equal(SpecificHeatEnergyUnit.JoulePerGramCelciusDegree, joulepergramcelciusdegreeQuantity.Unit); }
public void ArithmeticOperators() { SpecificHeatEnergy v = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); AssertEx.EqualTolerance(-1, -v.JoulePerGramCelciusDegrees, JoulePerGramCelciusDegreesTolerance); AssertEx.EqualTolerance(2, (SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(3) - v).JoulePerGramCelciusDegrees, JoulePerGramCelciusDegreesTolerance); AssertEx.EqualTolerance(2, (v + v).JoulePerGramCelciusDegrees, JoulePerGramCelciusDegreesTolerance); AssertEx.EqualTolerance(10, (v * 10).JoulePerGramCelciusDegrees, JoulePerGramCelciusDegreesTolerance); AssertEx.EqualTolerance(10, (10 * v).JoulePerGramCelciusDegrees, JoulePerGramCelciusDegreesTolerance); AssertEx.EqualTolerance(2, (SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(10) / 5).JoulePerGramCelciusDegrees, JoulePerGramCelciusDegreesTolerance); AssertEx.EqualTolerance(2, SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(10) / SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(5), JoulePerGramCelciusDegreesTolerance); }
public void ComparisonOperators() { SpecificHeatEnergy oneJoulePerGramCelciusDegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); SpecificHeatEnergy twoJoulePerGramCelciusDegrees = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(2); Assert.True(oneJoulePerGramCelciusDegree < twoJoulePerGramCelciusDegrees); Assert.True(oneJoulePerGramCelciusDegree <= twoJoulePerGramCelciusDegrees); Assert.True(twoJoulePerGramCelciusDegrees > oneJoulePerGramCelciusDegree); Assert.True(twoJoulePerGramCelciusDegrees >= oneJoulePerGramCelciusDegree); Assert.False(oneJoulePerGramCelciusDegree > twoJoulePerGramCelciusDegrees); Assert.False(oneJoulePerGramCelciusDegree >= twoJoulePerGramCelciusDegrees); Assert.False(twoJoulePerGramCelciusDegrees < oneJoulePerGramCelciusDegree); Assert.False(twoJoulePerGramCelciusDegrees <= oneJoulePerGramCelciusDegree); }
public void EqualityOperators() { var a = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); var b = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(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 SpecificHeatEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() { var quantity = new SpecificHeatEnergy(1, SpecificHeatEnergyUnit.JoulePerGramCelciusDegree); QuantityInfo <SpecificHeatEnergyUnit> quantityInfo = quantity.QuantityInfo; Assert.Equal(SpecificHeatEnergy.Zero, quantityInfo.Zero); Assert.Equal("SpecificHeatEnergy", quantityInfo.Name); Assert.Equal(QuantityType.SpecificHeatEnergy, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues <SpecificHeatEnergyUnit>().Except(new[] { SpecificHeatEnergyUnit.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 Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0); Assert.Equal(SpecificHeatEnergy.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void ConversionRoundTrip() { SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); AssertEx.EqualTolerance(1, SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(joulepergramcelciusdegree.JoulePerGramCelciusDegrees).JoulePerGramCelciusDegrees, JoulePerGramCelciusDegreesTolerance); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificHeatEnergyUnit))); }
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0); Assert.Equal(QuantityType.SpecificHeatEnergy, Convert.ChangeType(quantity, typeof(QuantityType))); }
public void CompareToThrowsOnTypeMismatch() { SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); Assert.Throws <ArgumentException>(() => joulepergramcelciusdegree.CompareTo(new object())); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void Convert_ToDateTime_ThrowsInvalidCastException() { var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0); Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity)); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(value); Assert.Equal(SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(-value), -quantity); }
public void ToString_NullArgs_ThrowsArgumentNullException() { var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0); Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null)); }
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
public void As() { var joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); AssertEx.EqualTolerance(JoulePerGramCelciusDegreesInOneJoulePerGramCelciusDegree, joulepergramcelciusdegree.As(SpecificHeatEnergyUnit.JoulePerGramCelciusDegree), JoulePerGramCelciusDegreesTolerance); }
public void EqualsReturnsFalseOnTypeMismatch() { SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); Assert.False(joulepergramcelciusdegree.Equals(new object())); }
public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { var v = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1), -1, ComparisonType.Relative)); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
public void GetHashCode_Equals() { var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0); Assert.Equal(new { SpecificHeatEnergy.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void Convert_ToString_EqualsToString() { var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void EqualsReturnsFalseOnNull() { SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); Assert.False(joulepergramcelciusdegree.Equals(null)); }
public void CompareToThrowsOnNull() { SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1); Assert.Throws <ArgumentNullException>(() => joulepergramcelciusdegree.CompareTo(null)); }