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)); }
public void GrayToAbsorbedDoseUnits() { AbsorbedDose gray = AbsorbedDose.FromGrays(1); AssertEx.EqualTolerance(GraysInOneGray, gray.Grays, GraysTolerance); AssertEx.EqualTolerance(SievertsInOneGray, gray.Sieverts, SievertsTolerance); }
public void As() { var gray = AbsorbedDose.FromGrays(1); AssertEx.EqualTolerance(GraysInOneGray, gray.As(AbsorbedDoseUnit.Gray), GraysTolerance); AssertEx.EqualTolerance(SievertsInOneGray, gray.As(AbsorbedDoseUnit.Sievert), SievertsTolerance); }
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); }
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)); }
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); }
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)); }
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); }
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); }
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); }
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 }
public void Convert_ToDateTime_ThrowsInvalidCastException() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity)); }
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
public void GetHashCode_Equals() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Equal(new { AbsorbedDose.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Equal(AbsorbedDose.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
public void CompareToThrowsOnNull() { AbsorbedDose gray = AbsorbedDose.FromGrays(1); Assert.Throws <ArgumentNullException>(() => gray.CompareTo(null)); }
public void Convert_ToDecimal_EqualsValueAsSameType() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); }
public void Convert_ToInt32_EqualsValueAsSameType() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void Convert_ToString_EqualsToString() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AbsorbedDoseUnit))); }
public void Convert_ChangeType_SelfType_EqualsSelf() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(AbsorbedDose))); }
public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { var v = AbsorbedDose.FromGrays(1); Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(AbsorbedDose.FromGrays(1), -1, ComparisonType.Relative)); }
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Equal(QuantityType.AbsorbedDose, Convert.ChangeType(quantity, typeof(QuantityType))); }
public void EqualsReturnsFalseOnTypeMismatch() { AbsorbedDose gray = AbsorbedDose.FromGrays(1); Assert.False(gray.Equals(new object())); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void EqualsReturnsFalseOnNull() { AbsorbedDose gray = AbsorbedDose.FromGrays(1); Assert.False(gray.Equals(null)); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = AbsorbedDose.FromGrays(value); Assert.Equal(AbsorbedDose.FromGrays(-value), -quantity); }
public void ToString_NullArgs_ThrowsArgumentNullException() { var quantity = AbsorbedDose.FromGrays(1.0); Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null)); }