public void GrayToIrradiationDoseUnits() { IrradiationDose gray = IrradiationDose.FromGray(1); AssertEx.EqualTolerance(GrayInOneGray, gray.Gray, GrayTolerance); AssertEx.EqualTolerance(MilligrayInOneGray, gray.Milligray, MilligrayTolerance); }
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); }
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)); }
public void As() { var gray = IrradiationDose.FromGray(1); AssertEx.EqualTolerance(GrayInOneGray, gray.As(IrradiationDoseUnit.Gray), GrayTolerance); AssertEx.EqualTolerance(MilligrayInOneGray, gray.As(IrradiationDoseUnit.Milligray), MilligrayTolerance); }
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); }
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)); }
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); }
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); }
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); }
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 }
public void FromGray_WithNanValue_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => IrradiationDose.FromGray(double.NaN)); }
public void FromGray_WithInfinityValue_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => IrradiationDose.FromGray(double.PositiveInfinity)); Assert.Throws <ArgumentException>(() => IrradiationDose.FromGray(double.NegativeInfinity)); }
public void EqualsReturnsFalseOnNull() { IrradiationDose gray = IrradiationDose.FromGray(1); Assert.False(gray.Equals(null)); }
public void EqualsReturnsFalseOnTypeMismatch() { IrradiationDose gray = IrradiationDose.FromGray(1); Assert.False(gray.Equals(new object())); }
public void CompareToThrowsOnNull() { IrradiationDose gray = IrradiationDose.FromGray(1); Assert.Throws <ArgumentNullException>(() => gray.CompareTo(null)); }
public void CompareToThrowsOnTypeMismatch() { IrradiationDose gray = IrradiationDose.FromGray(1); Assert.Throws <ArgumentException>(() => gray.CompareTo(new object())); }