コード例 #1
0
        public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = SpaceVelocity.FromLiterPerSecondCubicMeters(1);

            Assert.True(v.Equals(SpaceVelocity.FromLiterPerSecondCubicMeters(1), LiterPerSecondCubicMetersTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(SpaceVelocity.Zero, LiterPerSecondCubicMetersTolerance, ComparisonType.Relative));
        }
コード例 #2
0
        public void Equals_SameType_IsImplemented()
        {
            var a = SpaceVelocity.FromLiterPerSecondCubicMeters(1);
            var b = SpaceVelocity.FromLiterPerSecondCubicMeters(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
コード例 #3
0
        public void CompareToIsImplemented()
        {
            SpaceVelocity literpersecondcubicmeter = SpaceVelocity.FromLiterPerSecondCubicMeters(1);

            Assert.Equal(0, literpersecondcubicmeter.CompareTo(literpersecondcubicmeter));
            Assert.True(literpersecondcubicmeter.CompareTo(SpaceVelocity.Zero) > 0);
            Assert.True(SpaceVelocity.Zero.CompareTo(literpersecondcubicmeter) < 0);
        }
コード例 #4
0
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = SpaceVelocity.FromLiterPerSecondCubicMeters(1);
            object b = SpaceVelocity.FromLiterPerSecondCubicMeters(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
コード例 #5
0
        public void ToUnit()
        {
            var literpersecondcubicmeter = SpaceVelocity.FromLiterPerSecondCubicMeters(1);

            var literpersecondcubicmeterQuantity = literpersecondcubicmeter.ToUnit(SpaceVelocityUnit.LiterPerSecondCubicMeter);

            AssertEx.EqualTolerance(LiterPerSecondCubicMetersInOneLiterPerSecondCubicMeter, (double)literpersecondcubicmeterQuantity.Value, LiterPerSecondCubicMetersTolerance);
            Assert.Equal(SpaceVelocityUnit.LiterPerSecondCubicMeter, literpersecondcubicmeterQuantity.Unit);
        }
コード例 #6
0
        public void ArithmeticOperators()
        {
            SpaceVelocity v = SpaceVelocity.FromLiterPerSecondCubicMeters(1);

            AssertEx.EqualTolerance(-1, -v.LiterPerSecondCubicMeters, LiterPerSecondCubicMetersTolerance);
            AssertEx.EqualTolerance(2, (SpaceVelocity.FromLiterPerSecondCubicMeters(3) - v).LiterPerSecondCubicMeters, LiterPerSecondCubicMetersTolerance);
            AssertEx.EqualTolerance(2, (v + v).LiterPerSecondCubicMeters, LiterPerSecondCubicMetersTolerance);
            AssertEx.EqualTolerance(10, (v * 10).LiterPerSecondCubicMeters, LiterPerSecondCubicMetersTolerance);
            AssertEx.EqualTolerance(10, (10 * v).LiterPerSecondCubicMeters, LiterPerSecondCubicMetersTolerance);
            AssertEx.EqualTolerance(2, (SpaceVelocity.FromLiterPerSecondCubicMeters(10) / 5).LiterPerSecondCubicMeters, LiterPerSecondCubicMetersTolerance);
            AssertEx.EqualTolerance(2, SpaceVelocity.FromLiterPerSecondCubicMeters(10) / SpaceVelocity.FromLiterPerSecondCubicMeters(5), LiterPerSecondCubicMetersTolerance);
        }
コード例 #7
0
        public void ComparisonOperators()
        {
            SpaceVelocity oneLiterPerSecondCubicMeter  = SpaceVelocity.FromLiterPerSecondCubicMeters(1);
            SpaceVelocity twoLiterPerSecondCubicMeters = SpaceVelocity.FromLiterPerSecondCubicMeters(2);

            Assert.True(oneLiterPerSecondCubicMeter < twoLiterPerSecondCubicMeters);
            Assert.True(oneLiterPerSecondCubicMeter <= twoLiterPerSecondCubicMeters);
            Assert.True(twoLiterPerSecondCubicMeters > oneLiterPerSecondCubicMeter);
            Assert.True(twoLiterPerSecondCubicMeters >= oneLiterPerSecondCubicMeter);

            Assert.False(oneLiterPerSecondCubicMeter > twoLiterPerSecondCubicMeters);
            Assert.False(oneLiterPerSecondCubicMeter >= twoLiterPerSecondCubicMeters);
            Assert.False(twoLiterPerSecondCubicMeters < oneLiterPerSecondCubicMeter);
            Assert.False(twoLiterPerSecondCubicMeters <= oneLiterPerSecondCubicMeter);
        }
コード例 #8
0
        public void EqualityOperators()
        {
            var a = SpaceVelocity.FromLiterPerSecondCubicMeters(1);
            var b = SpaceVelocity.FromLiterPerSecondCubicMeters(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
        }
コード例 #9
0
        public void Convert_ToInt16_EqualsValueAsSameType()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity));
        }
コード例 #10
0
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
コード例 #11
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
コード例 #12
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
コード例 #13
0
        public void GetHashCode_Equals()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Equal(new { SpaceVelocity.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
コード例 #14
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Equal(SpaceVelocity.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
コード例 #15
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpaceVelocityUnit)));
        }
コード例 #16
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
コード例 #17
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
コード例 #18
0
        public void ConversionRoundTrip()
        {
            SpaceVelocity literpersecondcubicmeter = SpaceVelocity.FromLiterPerSecondCubicMeters(1);

            AssertEx.EqualTolerance(1, SpaceVelocity.FromLiterPerSecondCubicMeters(literpersecondcubicmeter.LiterPerSecondCubicMeters).LiterPerSecondCubicMeters, LiterPerSecondCubicMetersTolerance);
        }
コード例 #19
0
        public void CompareToThrowsOnNull()
        {
            SpaceVelocity literpersecondcubicmeter = SpaceVelocity.FromLiterPerSecondCubicMeters(1);

            Assert.Throws <ArgumentNullException>(() => literpersecondcubicmeter.CompareTo(null));
        }
コード例 #20
0
        public void CompareToThrowsOnTypeMismatch()
        {
            SpaceVelocity literpersecondcubicmeter = SpaceVelocity.FromLiterPerSecondCubicMeters(1);

            Assert.Throws <ArgumentException>(() => literpersecondcubicmeter.CompareTo(new object()));
        }
コード例 #21
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
コード例 #22
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = SpaceVelocity.FromLiterPerSecondCubicMeters(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(SpaceVelocity.FromLiterPerSecondCubicMeters(1), -1, ComparisonType.Relative));
        }
コード例 #23
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(SpaceVelocity)));
        }
コード例 #24
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            SpaceVelocity literpersecondcubicmeter = SpaceVelocity.FromLiterPerSecondCubicMeters(1);

            Assert.False(literpersecondcubicmeter.Equals(new object()));
        }
コード例 #25
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Equal(QuantityType.SpaceVelocity, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
コード例 #26
0
        public void EqualsReturnsFalseOnNull()
        {
            SpaceVelocity literpersecondcubicmeter = SpaceVelocity.FromLiterPerSecondCubicMeters(1);

            Assert.False(literpersecondcubicmeter.Equals(null));
        }
コード例 #27
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
コード例 #28
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
コード例 #29
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = SpaceVelocity.FromLiterPerSecondCubicMeters(value);

            Assert.Equal(SpaceVelocity.FromLiterPerSecondCubicMeters(-value), -quantity);
        }
コード例 #30
0
        public void As()
        {
            var literpersecondcubicmeter = SpaceVelocity.FromLiterPerSecondCubicMeters(1);

            AssertEx.EqualTolerance(LiterPerSecondCubicMetersInOneLiterPerSecondCubicMeter, literpersecondcubicmeter.As(SpaceVelocityUnit.LiterPerSecondCubicMeter), LiterPerSecondCubicMetersTolerance);
        }