public void Equals_RelativeTolerance_IsImplemented() { var v = ReciprocalArea.FromInverseSquareMeters(1); Assert.True(v.Equals(ReciprocalArea.FromInverseSquareMeters(1), InverseSquareMetersTolerance, ComparisonType.Relative)); Assert.False(v.Equals(ReciprocalArea.Zero, InverseSquareMetersTolerance, ComparisonType.Relative)); }
public void ToUnit() { var inversesquaremeter = ReciprocalArea.FromInverseSquareMeters(1); var inversesquarecentimeterQuantity = inversesquaremeter.ToUnit(ReciprocalAreaUnit.InverseSquareCentimeter); AssertEx.EqualTolerance(InverseSquareCentimetersInOneInverseSquareMeter, (double)inversesquarecentimeterQuantity.Value, InverseSquareCentimetersTolerance); Assert.Equal(ReciprocalAreaUnit.InverseSquareCentimeter, inversesquarecentimeterQuantity.Unit); var inversesquaredecimeterQuantity = inversesquaremeter.ToUnit(ReciprocalAreaUnit.InverseSquareDecimeter); AssertEx.EqualTolerance(InverseSquareDecimetersInOneInverseSquareMeter, (double)inversesquaredecimeterQuantity.Value, InverseSquareDecimetersTolerance); Assert.Equal(ReciprocalAreaUnit.InverseSquareDecimeter, inversesquaredecimeterQuantity.Unit); var inversesquarefootQuantity = inversesquaremeter.ToUnit(ReciprocalAreaUnit.InverseSquareFoot); AssertEx.EqualTolerance(InverseSquareFeetInOneInverseSquareMeter, (double)inversesquarefootQuantity.Value, InverseSquareFeetTolerance); Assert.Equal(ReciprocalAreaUnit.InverseSquareFoot, inversesquarefootQuantity.Unit); var inversesquareinchQuantity = inversesquaremeter.ToUnit(ReciprocalAreaUnit.InverseSquareInch); AssertEx.EqualTolerance(InverseSquareInchesInOneInverseSquareMeter, (double)inversesquareinchQuantity.Value, InverseSquareInchesTolerance); Assert.Equal(ReciprocalAreaUnit.InverseSquareInch, inversesquareinchQuantity.Unit); var inversesquarekilometerQuantity = inversesquaremeter.ToUnit(ReciprocalAreaUnit.InverseSquareKilometer); AssertEx.EqualTolerance(InverseSquareKilometersInOneInverseSquareMeter, (double)inversesquarekilometerQuantity.Value, InverseSquareKilometersTolerance); Assert.Equal(ReciprocalAreaUnit.InverseSquareKilometer, inversesquarekilometerQuantity.Unit); var inversesquaremeterQuantity = inversesquaremeter.ToUnit(ReciprocalAreaUnit.InverseSquareMeter); AssertEx.EqualTolerance(InverseSquareMetersInOneInverseSquareMeter, (double)inversesquaremeterQuantity.Value, InverseSquareMetersTolerance); Assert.Equal(ReciprocalAreaUnit.InverseSquareMeter, inversesquaremeterQuantity.Unit); var inversesquaremicrometerQuantity = inversesquaremeter.ToUnit(ReciprocalAreaUnit.InverseSquareMicrometer); AssertEx.EqualTolerance(InverseSquareMicrometersInOneInverseSquareMeter, (double)inversesquaremicrometerQuantity.Value, InverseSquareMicrometersTolerance); Assert.Equal(ReciprocalAreaUnit.InverseSquareMicrometer, inversesquaremicrometerQuantity.Unit); var inversesquaremileQuantity = inversesquaremeter.ToUnit(ReciprocalAreaUnit.InverseSquareMile); AssertEx.EqualTolerance(InverseSquareMilesInOneInverseSquareMeter, (double)inversesquaremileQuantity.Value, InverseSquareMilesTolerance); Assert.Equal(ReciprocalAreaUnit.InverseSquareMile, inversesquaremileQuantity.Unit); var inversesquaremillimeterQuantity = inversesquaremeter.ToUnit(ReciprocalAreaUnit.InverseSquareMillimeter); AssertEx.EqualTolerance(InverseSquareMillimetersInOneInverseSquareMeter, (double)inversesquaremillimeterQuantity.Value, InverseSquareMillimetersTolerance); Assert.Equal(ReciprocalAreaUnit.InverseSquareMillimeter, inversesquaremillimeterQuantity.Unit); var inversesquareyardQuantity = inversesquaremeter.ToUnit(ReciprocalAreaUnit.InverseSquareYard); AssertEx.EqualTolerance(InverseSquareYardsInOneInverseSquareMeter, (double)inversesquareyardQuantity.Value, InverseSquareYardsTolerance); Assert.Equal(ReciprocalAreaUnit.InverseSquareYard, inversesquareyardQuantity.Unit); var inverseussurveysquarefootQuantity = inversesquaremeter.ToUnit(ReciprocalAreaUnit.InverseUsSurveySquareFoot); AssertEx.EqualTolerance(InverseUsSurveySquareFeetInOneInverseSquareMeter, (double)inverseussurveysquarefootQuantity.Value, InverseUsSurveySquareFeetTolerance); Assert.Equal(ReciprocalAreaUnit.InverseUsSurveySquareFoot, inverseussurveysquarefootQuantity.Unit); }
public void CompareToIsImplemented() { ReciprocalArea inversesquaremeter = ReciprocalArea.FromInverseSquareMeters(1); Assert.Equal(0, inversesquaremeter.CompareTo(inversesquaremeter)); Assert.True(inversesquaremeter.CompareTo(ReciprocalArea.Zero) > 0); Assert.True(ReciprocalArea.Zero.CompareTo(inversesquaremeter) < 0); }
public void Equals_SameType_IsImplemented() { var a = ReciprocalArea.FromInverseSquareMeters(1); var b = ReciprocalArea.FromInverseSquareMeters(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); }
public void Equals_QuantityAsObject_IsImplemented() { object a = ReciprocalArea.FromInverseSquareMeters(1); object b = ReciprocalArea.FromInverseSquareMeters(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); Assert.False(a.Equals((object)null)); }
public void ArithmeticOperators() { ReciprocalArea v = ReciprocalArea.FromInverseSquareMeters(1); AssertEx.EqualTolerance(-1, -v.InverseSquareMeters, InverseSquareMetersTolerance); AssertEx.EqualTolerance(2, (ReciprocalArea.FromInverseSquareMeters(3) - v).InverseSquareMeters, InverseSquareMetersTolerance); AssertEx.EqualTolerance(2, (v + v).InverseSquareMeters, InverseSquareMetersTolerance); AssertEx.EqualTolerance(10, (v * 10).InverseSquareMeters, InverseSquareMetersTolerance); AssertEx.EqualTolerance(10, (10 * v).InverseSquareMeters, InverseSquareMetersTolerance); AssertEx.EqualTolerance(2, (ReciprocalArea.FromInverseSquareMeters(10) / 5).InverseSquareMeters, InverseSquareMetersTolerance); AssertEx.EqualTolerance(2, ReciprocalArea.FromInverseSquareMeters(10) / ReciprocalArea.FromInverseSquareMeters(5), InverseSquareMetersTolerance); }
public void ComparisonOperators() { ReciprocalArea oneInverseSquareMeter = ReciprocalArea.FromInverseSquareMeters(1); ReciprocalArea twoInverseSquareMeters = ReciprocalArea.FromInverseSquareMeters(2); Assert.True(oneInverseSquareMeter < twoInverseSquareMeters); Assert.True(oneInverseSquareMeter <= twoInverseSquareMeters); Assert.True(twoInverseSquareMeters > oneInverseSquareMeter); Assert.True(twoInverseSquareMeters >= oneInverseSquareMeter); Assert.False(oneInverseSquareMeter > twoInverseSquareMeters); Assert.False(oneInverseSquareMeter >= twoInverseSquareMeters); Assert.False(twoInverseSquareMeters < oneInverseSquareMeter); Assert.False(twoInverseSquareMeters <= oneInverseSquareMeter); }
public void ConversionRoundTrip() { ReciprocalArea inversesquaremeter = ReciprocalArea.FromInverseSquareMeters(1); AssertEx.EqualTolerance(1, ReciprocalArea.FromInverseSquareCentimeters(inversesquaremeter.InverseSquareCentimeters).InverseSquareMeters, InverseSquareCentimetersTolerance); AssertEx.EqualTolerance(1, ReciprocalArea.FromInverseSquareDecimeters(inversesquaremeter.InverseSquareDecimeters).InverseSquareMeters, InverseSquareDecimetersTolerance); AssertEx.EqualTolerance(1, ReciprocalArea.FromInverseSquareFeet(inversesquaremeter.InverseSquareFeet).InverseSquareMeters, InverseSquareFeetTolerance); AssertEx.EqualTolerance(1, ReciprocalArea.FromInverseSquareInches(inversesquaremeter.InverseSquareInches).InverseSquareMeters, InverseSquareInchesTolerance); AssertEx.EqualTolerance(1, ReciprocalArea.FromInverseSquareKilometers(inversesquaremeter.InverseSquareKilometers).InverseSquareMeters, InverseSquareKilometersTolerance); AssertEx.EqualTolerance(1, ReciprocalArea.FromInverseSquareMeters(inversesquaremeter.InverseSquareMeters).InverseSquareMeters, InverseSquareMetersTolerance); AssertEx.EqualTolerance(1, ReciprocalArea.FromInverseSquareMicrometers(inversesquaremeter.InverseSquareMicrometers).InverseSquareMeters, InverseSquareMicrometersTolerance); AssertEx.EqualTolerance(1, ReciprocalArea.FromInverseSquareMiles(inversesquaremeter.InverseSquareMiles).InverseSquareMeters, InverseSquareMilesTolerance); AssertEx.EqualTolerance(1, ReciprocalArea.FromInverseSquareMillimeters(inversesquaremeter.InverseSquareMillimeters).InverseSquareMeters, InverseSquareMillimetersTolerance); AssertEx.EqualTolerance(1, ReciprocalArea.FromInverseSquareYards(inversesquaremeter.InverseSquareYards).InverseSquareMeters, InverseSquareYardsTolerance); AssertEx.EqualTolerance(1, ReciprocalArea.FromInverseUsSurveySquareFeet(inversesquaremeter.InverseUsSurveySquareFeet).InverseSquareMeters, InverseUsSurveySquareFeetTolerance); }
public void InverseSquareMeterToReciprocalAreaUnits() { ReciprocalArea inversesquaremeter = ReciprocalArea.FromInverseSquareMeters(1); AssertEx.EqualTolerance(InverseSquareCentimetersInOneInverseSquareMeter, inversesquaremeter.InverseSquareCentimeters, InverseSquareCentimetersTolerance); AssertEx.EqualTolerance(InverseSquareDecimetersInOneInverseSquareMeter, inversesquaremeter.InverseSquareDecimeters, InverseSquareDecimetersTolerance); AssertEx.EqualTolerance(InverseSquareFeetInOneInverseSquareMeter, inversesquaremeter.InverseSquareFeet, InverseSquareFeetTolerance); AssertEx.EqualTolerance(InverseSquareInchesInOneInverseSquareMeter, inversesquaremeter.InverseSquareInches, InverseSquareInchesTolerance); AssertEx.EqualTolerance(InverseSquareKilometersInOneInverseSquareMeter, inversesquaremeter.InverseSquareKilometers, InverseSquareKilometersTolerance); AssertEx.EqualTolerance(InverseSquareMetersInOneInverseSquareMeter, inversesquaremeter.InverseSquareMeters, InverseSquareMetersTolerance); AssertEx.EqualTolerance(InverseSquareMicrometersInOneInverseSquareMeter, inversesquaremeter.InverseSquareMicrometers, InverseSquareMicrometersTolerance); AssertEx.EqualTolerance(InverseSquareMilesInOneInverseSquareMeter, inversesquaremeter.InverseSquareMiles, InverseSquareMilesTolerance); AssertEx.EqualTolerance(InverseSquareMillimetersInOneInverseSquareMeter, inversesquaremeter.InverseSquareMillimeters, InverseSquareMillimetersTolerance); AssertEx.EqualTolerance(InverseSquareYardsInOneInverseSquareMeter, inversesquaremeter.InverseSquareYards, InverseSquareYardsTolerance); AssertEx.EqualTolerance(InverseUsSurveySquareFeetInOneInverseSquareMeter, inversesquaremeter.InverseUsSurveySquareFeet, InverseUsSurveySquareFeetTolerance); }
public void As() { var inversesquaremeter = ReciprocalArea.FromInverseSquareMeters(1); AssertEx.EqualTolerance(InverseSquareCentimetersInOneInverseSquareMeter, inversesquaremeter.As(ReciprocalAreaUnit.InverseSquareCentimeter), InverseSquareCentimetersTolerance); AssertEx.EqualTolerance(InverseSquareDecimetersInOneInverseSquareMeter, inversesquaremeter.As(ReciprocalAreaUnit.InverseSquareDecimeter), InverseSquareDecimetersTolerance); AssertEx.EqualTolerance(InverseSquareFeetInOneInverseSquareMeter, inversesquaremeter.As(ReciprocalAreaUnit.InverseSquareFoot), InverseSquareFeetTolerance); AssertEx.EqualTolerance(InverseSquareInchesInOneInverseSquareMeter, inversesquaremeter.As(ReciprocalAreaUnit.InverseSquareInch), InverseSquareInchesTolerance); AssertEx.EqualTolerance(InverseSquareKilometersInOneInverseSquareMeter, inversesquaremeter.As(ReciprocalAreaUnit.InverseSquareKilometer), InverseSquareKilometersTolerance); AssertEx.EqualTolerance(InverseSquareMetersInOneInverseSquareMeter, inversesquaremeter.As(ReciprocalAreaUnit.InverseSquareMeter), InverseSquareMetersTolerance); AssertEx.EqualTolerance(InverseSquareMicrometersInOneInverseSquareMeter, inversesquaremeter.As(ReciprocalAreaUnit.InverseSquareMicrometer), InverseSquareMicrometersTolerance); AssertEx.EqualTolerance(InverseSquareMilesInOneInverseSquareMeter, inversesquaremeter.As(ReciprocalAreaUnit.InverseSquareMile), InverseSquareMilesTolerance); AssertEx.EqualTolerance(InverseSquareMillimetersInOneInverseSquareMeter, inversesquaremeter.As(ReciprocalAreaUnit.InverseSquareMillimeter), InverseSquareMillimetersTolerance); AssertEx.EqualTolerance(InverseSquareYardsInOneInverseSquareMeter, inversesquaremeter.As(ReciprocalAreaUnit.InverseSquareYard), InverseSquareYardsTolerance); AssertEx.EqualTolerance(InverseUsSurveySquareFeetInOneInverseSquareMeter, inversesquaremeter.As(ReciprocalAreaUnit.InverseUsSurveySquareFoot), InverseUsSurveySquareFeetTolerance); }
public void EqualityOperators() { var a = ReciprocalArea.FromInverseSquareMeters(1); var b = ReciprocalArea.FromInverseSquareMeters(2); #pragma warning disable CS8073 // 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 #pragma warning restore CS8073 }
public void Convert_ToString_EqualsToString() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
public void Convert_ToInt16_EqualsValueAsSameType() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); }
public void Convert_ToDecimal_EqualsValueAsSameType() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); }
public void Convert_ToDateTime_ThrowsInvalidCastException() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity)); }
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
public void GetHashCode_Equals() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Equal(new { ReciprocalArea.Info.Name, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Equal(ReciprocalArea.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ReciprocalAreaUnit))); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void CompareToThrowsOnNull() { ReciprocalArea inversesquaremeter = ReciprocalArea.FromInverseSquareMeters(1); Assert.Throws <ArgumentNullException>(() => inversesquaremeter.CompareTo(null)); }
public void Convert_ChangeType_SelfType_EqualsSelf() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(ReciprocalArea))); }
public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { var v = ReciprocalArea.FromInverseSquareMeters(1); Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(ReciprocalArea.FromInverseSquareMeters(1), -1, ComparisonType.Relative)); }
public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Equal(ReciprocalArea.Info, Convert.ChangeType(quantity, typeof(QuantityInfo))); }
public void EqualsReturnsFalseOnTypeMismatch() { ReciprocalArea inversesquaremeter = ReciprocalArea.FromInverseSquareMeters(1); Assert.False(inversesquaremeter.Equals(new object())); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void EqualsReturnsFalseOnNull() { ReciprocalArea inversesquaremeter = ReciprocalArea.FromInverseSquareMeters(1); Assert.False(inversesquaremeter.Equals(null)); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = ReciprocalArea.FromInverseSquareMeters(value); Assert.Equal(ReciprocalArea.FromInverseSquareMeters(-value), -quantity); }
public void ToString_NullArgs_ThrowsArgumentNullException() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null)); }