Example #1
0
        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));
        }
Example #2
0
        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);
        }
Example #3
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));
        }
Example #4
0
        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);
        }
Example #5
0
        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));
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        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
        }
Example #9
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
Example #10
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
Example #11
0
        public void EqualsReturnsFalseOnNull()
        {
            SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1);

            Assert.False(joulepergramcelciusdegree.Equals(null));
        }
Example #12
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1);

            Assert.False(joulepergramcelciusdegree.Equals(new object()));
        }
Example #13
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificHeatEnergyUnit)));
        }
Example #14
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Example #15
0
 public void FromJoulePerGramCelciusDegrees_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(double.NaN));
 }
Example #16
0
        public void CompareToThrowsOnNull()
        {
            SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1);

            Assert.Throws <ArgumentNullException>(() => joulepergramcelciusdegree.CompareTo(null));
        }
Example #17
0
        public void CompareToThrowsOnTypeMismatch()
        {
            SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1);

            Assert.Throws <ArgumentException>(() => joulepergramcelciusdegree.CompareTo(new object()));
        }
Example #18
0
        public void As()
        {
            var joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1);

            AssertEx.EqualTolerance(JoulePerGramCelciusDegreesInOneJoulePerGramCelciusDegree, joulepergramcelciusdegree.As(SpecificHeatEnergyUnit.JoulePerGramCelciusDegree), JoulePerGramCelciusDegreesTolerance);
        }
Example #19
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
Example #20
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Equal(SpecificHeatEnergy.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Example #21
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Example #22
0
        public void GetHashCode_Equals()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Equal(new { SpecificHeatEnergy.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Example #23
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Example #24
0
 public void FromJoulePerGramCelciusDegrees_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(double.NegativeInfinity));
 }
Example #25
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Equal(QuantityType.SpecificHeatEnergy, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Example #26
0
        public void ConversionRoundTrip()
        {
            SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1);

            AssertEx.EqualTolerance(1, SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(joulepergramcelciusdegree.JoulePerGramCelciusDegrees).JoulePerGramCelciusDegrees, JoulePerGramCelciusDegreesTolerance);
        }
Example #27
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Example #28
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1), -1, ComparisonType.Relative));
        }
Example #29
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(value);

            Assert.Equal(SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(-value), -quantity);
        }
Example #30
0
        public void JoulePerGramCelciusDegreeToSpecificHeatEnergyUnits()
        {
            SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1);

            AssertEx.EqualTolerance(JoulePerGramCelciusDegreesInOneJoulePerGramCelciusDegree, joulepergramcelciusdegree.JoulePerGramCelciusDegrees, JoulePerGramCelciusDegreesTolerance);
        }