Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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
        }
Esempio n. 9
0
        public void Convert_ToInt32_EqualsValueAsSameType()
        {
            var quantity = Diffusivity.FromSquareMeterPerHours(1.0);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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