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

            AssertEx.EqualTolerance(GrayInOneGray, gray.Gray, GrayTolerance);
            AssertEx.EqualTolerance(MilligrayInOneGray, gray.Milligray, MilligrayTolerance);
        }
Example #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);
        }
Example #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));
        }
Example #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);
        }
Example #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);
        }
Example #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));
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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
        }
Example #11
0
 public void FromGray_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => IrradiationDose.FromGray(double.NaN));
 }
Example #12
0
 public void FromGray_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => IrradiationDose.FromGray(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => IrradiationDose.FromGray(double.NegativeInfinity));
 }
Example #13
0
        public void EqualsReturnsFalseOnNull()
        {
            IrradiationDose gray = IrradiationDose.FromGray(1);

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

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

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

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