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 DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit()
        {
            var quantity = new SpecificHeatEnergy();

            Assert.Equal(0, quantity.Value);
            Assert.Equal(SpecificHeatEnergyUnit.JoulePerGramCelciusDegree, quantity.Unit);
        }
Example #3
0
        public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
        {
            var quantity00 = SpecificHeatEnergy.From(1, SpecificHeatEnergyUnit.JoulePerGramCelciusDegree);

            AssertEx.EqualTolerance(1, quantity00.JoulePerGramCelciusDegrees, JoulePerGramCelciusDegreesTolerance);
            Assert.Equal(SpecificHeatEnergyUnit.JoulePerGramCelciusDegree, quantity00.Unit);
        }
Example #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
0
        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
        }
Example #12
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

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

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

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

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

            Assert.Throws <ArgumentException>(() => joulepergramcelciusdegree.CompareTo(new object()));
        }
Example #17
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Example #18
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
Example #19
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(value);

            Assert.Equal(SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(-value), -quantity);
        }
Example #20
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
Example #21
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
Example #22
0
        public void As()
        {
            var joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1);

            AssertEx.EqualTolerance(JoulePerGramCelciusDegreesInOneJoulePerGramCelciusDegree, joulepergramcelciusdegree.As(SpecificHeatEnergyUnit.JoulePerGramCelciusDegree), JoulePerGramCelciusDegreesTolerance);
        }
Example #23
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1);

            Assert.False(joulepergramcelciusdegree.Equals(new object()));
        }
Example #24
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1);

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

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Example #26
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1.0);

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

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

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Example #29
0
        public void EqualsReturnsFalseOnNull()
        {
            SpecificHeatEnergy joulepergramcelciusdegree = SpecificHeatEnergy.FromJoulePerGramCelciusDegrees(1);

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

            Assert.Throws <ArgumentNullException>(() => joulepergramcelciusdegree.CompareTo(null));
        }