Beispiel #1
0
        public void GrayToIrradiationDoseUnits()
        {
            IrradiationDose gray = IrradiationDose.FromGray(1);

            AssertEx.EqualTolerance(GrayInOneGray, gray.Gray, GrayTolerance);
            AssertEx.EqualTolerance(MilligrayInOneGray, gray.Milligray, MilligrayTolerance);
        }
Beispiel #2
0
        public void ConversionRoundTrip()
        {
            IrradiationDose gray = IrradiationDose.FromGray(1);

            AssertEx.EqualTolerance(1, IrradiationDose.FromGray(gray.Gray).Gray, GrayTolerance);
            AssertEx.EqualTolerance(1, IrradiationDose.FromMilligray(gray.Milligray).Gray, MilligrayTolerance);
        }
Beispiel #3
0
        public void EqualsRelativeToleranceIsImplemented()
        {
            var v = IrradiationDose.FromGray(1);

            Assert.True(v.Equals(IrradiationDose.FromGray(1), GrayTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(IrradiationDose.Zero, GrayTolerance, ComparisonType.Relative));
        }
Beispiel #4
0
        public void As()
        {
            var gray = IrradiationDose.FromGray(1);

            AssertEx.EqualTolerance(GrayInOneGray, gray.As(IrradiationDoseUnit.Gray), GrayTolerance);
            AssertEx.EqualTolerance(MilligrayInOneGray, gray.As(IrradiationDoseUnit.Milligray), MilligrayTolerance);
        }
Beispiel #5
0
        public void CompareToIsImplemented()
        {
            IrradiationDose gray = IrradiationDose.FromGray(1);

            Assert.Equal(0, gray.CompareTo(gray));
            Assert.True(gray.CompareTo(IrradiationDose.Zero) > 0);
            Assert.True(IrradiationDose.Zero.CompareTo(gray) < 0);
        }
Beispiel #6
0
        public void EqualsIsImplemented()
        {
            var a = IrradiationDose.FromGray(1);
            var b = IrradiationDose.FromGray(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals(null));
        }
Beispiel #7
0
        public void ArithmeticOperators()
        {
            IrradiationDose v = IrradiationDose.FromGray(1);

            AssertEx.EqualTolerance(-1, -v.Gray, GrayTolerance);
            AssertEx.EqualTolerance(2, (IrradiationDose.FromGray(3) - v).Gray, GrayTolerance);
            AssertEx.EqualTolerance(2, (v + v).Gray, GrayTolerance);
            AssertEx.EqualTolerance(10, (v * 10).Gray, GrayTolerance);
            AssertEx.EqualTolerance(10, (10 * v).Gray, GrayTolerance);
            AssertEx.EqualTolerance(2, (IrradiationDose.FromGray(10) / 5).Gray, GrayTolerance);
            AssertEx.EqualTolerance(2, IrradiationDose.FromGray(10) / IrradiationDose.FromGray(5), GrayTolerance);
        }
Beispiel #8
0
        public void ToUnit()
        {
            var gray = IrradiationDose.FromGray(1);

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

            AssertEx.EqualTolerance(GrayInOneGray, (double)grayQuantity.Value, GrayTolerance);
            Assert.Equal(IrradiationDoseUnit.Gray, grayQuantity.Unit);

            var milligrayQuantity = gray.ToUnit(IrradiationDoseUnit.Milligray);

            AssertEx.EqualTolerance(MilligrayInOneGray, (double)milligrayQuantity.Value, MilligrayTolerance);
            Assert.Equal(IrradiationDoseUnit.Milligray, milligrayQuantity.Unit);
        }
Beispiel #9
0
        public void ComparisonOperators()
        {
            IrradiationDose oneGray = IrradiationDose.FromGray(1);
            IrradiationDose twoGray = IrradiationDose.FromGray(2);

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

            Assert.False(oneGray > twoGray);
            Assert.False(oneGray >= twoGray);
            Assert.False(twoGray < oneGray);
            Assert.False(twoGray <= oneGray);
        }
Beispiel #10
0
        public void EqualityOperators()
        {
            var a = IrradiationDose.FromGray(1);
            var b = IrradiationDose.FromGray(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 #11
0
 public void FromGray_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => IrradiationDose.FromGray(double.NaN));
 }
Beispiel #12
0
 public void FromGray_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => IrradiationDose.FromGray(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => IrradiationDose.FromGray(double.NegativeInfinity));
 }
Beispiel #13
0
        public void EqualsReturnsFalseOnNull()
        {
            IrradiationDose gray = IrradiationDose.FromGray(1);

            Assert.False(gray.Equals(null));
        }
Beispiel #14
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            IrradiationDose gray = IrradiationDose.FromGray(1);

            Assert.False(gray.Equals(new object()));
        }
Beispiel #15
0
        public void CompareToThrowsOnNull()
        {
            IrradiationDose gray = IrradiationDose.FromGray(1);

            Assert.Throws <ArgumentNullException>(() => gray.CompareTo(null));
        }
Beispiel #16
0
        public void CompareToThrowsOnTypeMismatch()
        {
            IrradiationDose gray = IrradiationDose.FromGray(1);

            Assert.Throws <ArgumentException>(() => gray.CompareTo(new object()));
        }