Пример #1
0
        public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = AbsorbedDose.FromGrays(1);

            Assert.True(v.Equals(AbsorbedDose.FromGrays(1), GraysTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(AbsorbedDose.Zero, GraysTolerance, ComparisonType.Relative));
        }
Пример #2
0
        public void GrayToAbsorbedDoseUnits()
        {
            AbsorbedDose gray = AbsorbedDose.FromGrays(1);

            AssertEx.EqualTolerance(GraysInOneGray, gray.Grays, GraysTolerance);
            AssertEx.EqualTolerance(SievertsInOneGray, gray.Sieverts, SievertsTolerance);
        }
Пример #3
0
        public void As()
        {
            var gray = AbsorbedDose.FromGrays(1);

            AssertEx.EqualTolerance(GraysInOneGray, gray.As(AbsorbedDoseUnit.Gray), GraysTolerance);
            AssertEx.EqualTolerance(SievertsInOneGray, gray.As(AbsorbedDoseUnit.Sievert), SievertsTolerance);
        }
Пример #4
0
        public void ConversionRoundTrip()
        {
            AbsorbedDose gray = AbsorbedDose.FromGrays(1);

            AssertEx.EqualTolerance(1, AbsorbedDose.FromGrays(gray.Grays).Grays, GraysTolerance);
            AssertEx.EqualTolerance(1, AbsorbedDose.FromSieverts(gray.Sieverts).Grays, SievertsTolerance);
        }
Пример #5
0
        public void Equals_SameType_IsImplemented()
        {
            var a = AbsorbedDose.FromGrays(1);
            var b = AbsorbedDose.FromGrays(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
Пример #6
0
        public void CompareToIsImplemented()
        {
            AbsorbedDose gray = AbsorbedDose.FromGrays(1);

            Assert.Equal(0, gray.CompareTo(gray));
            Assert.True(gray.CompareTo(AbsorbedDose.Zero) > 0);
            Assert.True(AbsorbedDose.Zero.CompareTo(gray) < 0);
        }
Пример #7
0
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = AbsorbedDose.FromGrays(1);
            object b = AbsorbedDose.FromGrays(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
Пример #8
0
        public void ArithmeticOperators()
        {
            AbsorbedDose v = AbsorbedDose.FromGrays(1);

            AssertEx.EqualTolerance(-1, -v.Grays, GraysTolerance);
            AssertEx.EqualTolerance(2, (AbsorbedDose.FromGrays(3) - v).Grays, GraysTolerance);
            AssertEx.EqualTolerance(2, (v + v).Grays, GraysTolerance);
            AssertEx.EqualTolerance(10, (v * 10).Grays, GraysTolerance);
            AssertEx.EqualTolerance(10, (10 * v).Grays, GraysTolerance);
            AssertEx.EqualTolerance(2, (AbsorbedDose.FromGrays(10) / 5).Grays, GraysTolerance);
            AssertEx.EqualTolerance(2, AbsorbedDose.FromGrays(10) / AbsorbedDose.FromGrays(5), GraysTolerance);
        }
Пример #9
0
        public void ToUnit()
        {
            var gray = AbsorbedDose.FromGrays(1);

            var grayQuantity = gray.ToUnit(AbsorbedDoseUnit.Gray);

            AssertEx.EqualTolerance(GraysInOneGray, (double)grayQuantity.Value, GraysTolerance);
            Assert.Equal(AbsorbedDoseUnit.Gray, grayQuantity.Unit);

            var sievertQuantity = gray.ToUnit(AbsorbedDoseUnit.Sievert);

            AssertEx.EqualTolerance(SievertsInOneGray, (double)sievertQuantity.Value, SievertsTolerance);
            Assert.Equal(AbsorbedDoseUnit.Sievert, sievertQuantity.Unit);
        }
Пример #10
0
        public void ComparisonOperators()
        {
            AbsorbedDose oneGray  = AbsorbedDose.FromGrays(1);
            AbsorbedDose twoGrays = AbsorbedDose.FromGrays(2);

            Assert.True(oneGray < twoGrays);
            Assert.True(oneGray <= twoGrays);
            Assert.True(twoGrays > oneGray);
            Assert.True(twoGrays >= oneGray);

            Assert.False(oneGray > twoGrays);
            Assert.False(oneGray >= twoGrays);
            Assert.False(twoGrays < oneGray);
            Assert.False(twoGrays <= oneGray);
        }
Пример #11
0
        public void EqualityOperators()
        {
            var a = AbsorbedDose.FromGrays(1);
            var b = AbsorbedDose.FromGrays(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
        }
Пример #12
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
Пример #13
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
Пример #14
0
        public void GetHashCode_Equals()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Equal(new { AbsorbedDose.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Пример #15
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Equal(AbsorbedDose.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Пример #16
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Пример #17
0
        public void CompareToThrowsOnNull()
        {
            AbsorbedDose gray = AbsorbedDose.FromGrays(1);

            Assert.Throws <ArgumentNullException>(() => gray.CompareTo(null));
        }
Пример #18
0
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
Пример #19
0
        public void Convert_ToInt32_EqualsValueAsSameType()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity));
        }
Пример #20
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Пример #21
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Пример #22
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AbsorbedDoseUnit)));
        }
Пример #23
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(AbsorbedDose)));
        }
Пример #24
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = AbsorbedDose.FromGrays(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(AbsorbedDose.FromGrays(1), -1, ComparisonType.Relative));
        }
Пример #25
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Equal(QuantityType.AbsorbedDose, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Пример #26
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            AbsorbedDose gray = AbsorbedDose.FromGrays(1);

            Assert.False(gray.Equals(new object()));
        }
Пример #27
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Пример #28
0
        public void EqualsReturnsFalseOnNull()
        {
            AbsorbedDose gray = AbsorbedDose.FromGrays(1);

            Assert.False(gray.Equals(null));
        }
Пример #29
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = AbsorbedDose.FromGrays(value);

            Assert.Equal(AbsorbedDose.FromGrays(-value), -quantity);
        }
Пример #30
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = AbsorbedDose.FromGrays(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }