Beispiel #1
0
        public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = Diffusivity.FromSquareMeterPerHours(1);

            Assert.True(v.Equals(Diffusivity.FromSquareMeterPerHours(1), SquareMeterPerHoursTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(Diffusivity.Zero, SquareMeterPerHoursTolerance, ComparisonType.Relative));
        }
Beispiel #2
0
        public void Equals_SameType_IsImplemented()
        {
            var a = Diffusivity.FromSquareMeterPerHours(1);
            var b = Diffusivity.FromSquareMeterPerHours(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
Beispiel #3
0
        public void CompareToIsImplemented()
        {
            Diffusivity squaremeterperhour = Diffusivity.FromSquareMeterPerHours(1);

            Assert.Equal(0, squaremeterperhour.CompareTo(squaremeterperhour));
            Assert.True(squaremeterperhour.CompareTo(Diffusivity.Zero) > 0);
            Assert.True(Diffusivity.Zero.CompareTo(squaremeterperhour) < 0);
        }
Beispiel #4
0
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = Diffusivity.FromSquareMeterPerHours(1);
            object b = Diffusivity.FromSquareMeterPerHours(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
Beispiel #5
0
        public void ToUnit()
        {
            var squaremeterperhour = Diffusivity.FromSquareMeterPerHours(1);

            var squaremeterperhourQuantity = squaremeterperhour.ToUnit(DiffusivityUnit.SquareMeterPerHour);

            AssertEx.EqualTolerance(SquareMeterPerHoursInOneSquareMeterPerHour, (double)squaremeterperhourQuantity.Value, SquareMeterPerHoursTolerance);
            Assert.Equal(DiffusivityUnit.SquareMeterPerHour, squaremeterperhourQuantity.Unit);
        }
Beispiel #6
0
        public void ArithmeticOperators()
        {
            Diffusivity v = Diffusivity.FromSquareMeterPerHours(1);

            AssertEx.EqualTolerance(-1, -v.SquareMeterPerHours, SquareMeterPerHoursTolerance);
            AssertEx.EqualTolerance(2, (Diffusivity.FromSquareMeterPerHours(3) - v).SquareMeterPerHours, SquareMeterPerHoursTolerance);
            AssertEx.EqualTolerance(2, (v + v).SquareMeterPerHours, SquareMeterPerHoursTolerance);
            AssertEx.EqualTolerance(10, (v * 10).SquareMeterPerHours, SquareMeterPerHoursTolerance);
            AssertEx.EqualTolerance(10, (10 * v).SquareMeterPerHours, SquareMeterPerHoursTolerance);
            AssertEx.EqualTolerance(2, (Diffusivity.FromSquareMeterPerHours(10) / 5).SquareMeterPerHours, SquareMeterPerHoursTolerance);
            AssertEx.EqualTolerance(2, Diffusivity.FromSquareMeterPerHours(10) / Diffusivity.FromSquareMeterPerHours(5), SquareMeterPerHoursTolerance);
        }
Beispiel #7
0
        public void ComparisonOperators()
        {
            Diffusivity oneSquareMeterPerHour  = Diffusivity.FromSquareMeterPerHours(1);
            Diffusivity twoSquareMeterPerHours = Diffusivity.FromSquareMeterPerHours(2);

            Assert.True(oneSquareMeterPerHour < twoSquareMeterPerHours);
            Assert.True(oneSquareMeterPerHour <= twoSquareMeterPerHours);
            Assert.True(twoSquareMeterPerHours > oneSquareMeterPerHour);
            Assert.True(twoSquareMeterPerHours >= oneSquareMeterPerHour);

            Assert.False(oneSquareMeterPerHour > twoSquareMeterPerHours);
            Assert.False(oneSquareMeterPerHour >= twoSquareMeterPerHours);
            Assert.False(twoSquareMeterPerHours < oneSquareMeterPerHour);
            Assert.False(twoSquareMeterPerHours <= oneSquareMeterPerHour);
        }
Beispiel #8
0
        public void EqualityOperators()
        {
            var a = Diffusivity.FromSquareMeterPerHours(1);
            var b = Diffusivity.FromSquareMeterPerHours(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
        }
Beispiel #9
0
        public void Convert_ToInt32_EqualsValueAsSameType()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity));
        }
Beispiel #10
0
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
Beispiel #11
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
Beispiel #12
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
Beispiel #13
0
        public void GetHashCode_Equals()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Equal(new { Diffusivity.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Beispiel #14
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Equal(Diffusivity.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Beispiel #15
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(DiffusivityUnit)));
        }
Beispiel #16
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Beispiel #17
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Beispiel #18
0
        public void ConversionRoundTrip()
        {
            Diffusivity squaremeterperhour = Diffusivity.FromSquareMeterPerHours(1);

            AssertEx.EqualTolerance(1, Diffusivity.FromSquareMeterPerHours(squaremeterperhour.SquareMeterPerHours).SquareMeterPerHours, SquareMeterPerHoursTolerance);
        }
Beispiel #19
0
        public void CompareToThrowsOnNull()
        {
            Diffusivity squaremeterperhour = Diffusivity.FromSquareMeterPerHours(1);

            Assert.Throws <ArgumentNullException>(() => squaremeterperhour.CompareTo(null));
        }
Beispiel #20
0
        public void CompareToThrowsOnTypeMismatch()
        {
            Diffusivity squaremeterperhour = Diffusivity.FromSquareMeterPerHours(1);

            Assert.Throws <ArgumentException>(() => squaremeterperhour.CompareTo(new object()));
        }
Beispiel #21
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Beispiel #22
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = Diffusivity.FromSquareMeterPerHours(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(Diffusivity.FromSquareMeterPerHours(1), -1, ComparisonType.Relative));
        }
Beispiel #23
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(Diffusivity)));
        }
Beispiel #24
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            Diffusivity squaremeterperhour = Diffusivity.FromSquareMeterPerHours(1);

            Assert.False(squaremeterperhour.Equals(new object()));
        }
Beispiel #25
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Equal(QuantityType.Diffusivity, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Beispiel #26
0
        public void EqualsReturnsFalseOnNull()
        {
            Diffusivity squaremeterperhour = Diffusivity.FromSquareMeterPerHours(1);

            Assert.False(squaremeterperhour.Equals(null));
        }
Beispiel #27
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Beispiel #28
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
Beispiel #29
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(value);

            Assert.Equal(Diffusivity.FromSquareMeterPerHours(-value), -quantity);
        }
Beispiel #30
0
        public void As()
        {
            var squaremeterperhour = Diffusivity.FromSquareMeterPerHours(1);

            AssertEx.EqualTolerance(SquareMeterPerHoursInOneSquareMeterPerHour, squaremeterperhour.As(DiffusivityUnit.SquareMeterPerHour), SquareMeterPerHoursTolerance);
        }