public void ToUnit() { var cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); var cubicmeterpermeterQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.CubicMeterPerMeter); AssertEx.EqualTolerance(CubicMetersPerMeterInOneCubicMeterPerMeter, (double)cubicmeterpermeterQuantity.Value, CubicMetersPerMeterTolerance); Assert.Equal(VolumePerLengthUnit.CubicMeterPerMeter, cubicmeterpermeterQuantity.Unit); var cubicyardperfootQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.CubicYardPerFoot); AssertEx.EqualTolerance(CubicYardsPerFootInOneCubicMeterPerMeter, (double)cubicyardperfootQuantity.Value, CubicYardsPerFootTolerance); Assert.Equal(VolumePerLengthUnit.CubicYardPerFoot, cubicyardperfootQuantity.Unit); var cubicyardperussurveyfootQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.CubicYardPerUsSurveyFoot); AssertEx.EqualTolerance(CubicYardsPerUsSurveyFootInOneCubicMeterPerMeter, (double)cubicyardperussurveyfootQuantity.Value, CubicYardsPerUsSurveyFootTolerance); Assert.Equal(VolumePerLengthUnit.CubicYardPerUsSurveyFoot, cubicyardperussurveyfootQuantity.Unit); var literpermeterQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.LiterPerMeter); AssertEx.EqualTolerance(LitersPerMeterInOneCubicMeterPerMeter, (double)literpermeterQuantity.Value, LitersPerMeterTolerance); Assert.Equal(VolumePerLengthUnit.LiterPerMeter, literpermeterQuantity.Unit); var oilbarrelperfootQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.OilBarrelPerFoot); AssertEx.EqualTolerance(OilBarrelsPerFootInOneCubicMeterPerMeter, (double)oilbarrelperfootQuantity.Value, OilBarrelsPerFootTolerance); Assert.Equal(VolumePerLengthUnit.OilBarrelPerFoot, oilbarrelperfootQuantity.Unit); }
public void EqualsRelativeToleranceIsImplemented() { var v = VolumePerLength.FromCubicMetersPerMeter(1); Assert.True(v.Equals(VolumePerLength.FromCubicMetersPerMeter(1), CubicMetersPerMeterTolerance, ComparisonType.Relative)); Assert.False(v.Equals(VolumePerLength.Zero, CubicMetersPerMeterTolerance, ComparisonType.Relative)); }
public void CompareToIsImplemented() { VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); Assert.Equal(0, cubicmeterpermeter.CompareTo(cubicmeterpermeter)); Assert.True(cubicmeterpermeter.CompareTo(VolumePerLength.Zero) > 0); Assert.True(VolumePerLength.Zero.CompareTo(cubicmeterpermeter) < 0); }
public void Equals_SameType_IsImplemented() { var a = VolumePerLength.FromCubicMetersPerMeter(1); var b = VolumePerLength.FromCubicMetersPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); }
public void FromCubicMetersPerMeter_WithInfinityValue_CreateQuantityAndAffectInfinityValue() { var positiveInfinityQuantity = VolumePerLength.FromCubicMetersPerMeter(double.PositiveInfinity); var negativeInfinityQuantity = VolumePerLength.FromCubicMetersPerMeter(double.NegativeInfinity); Assert.True(double.IsPositiveInfinity(positiveInfinityQuantity.Value)); Assert.True(double.IsNegativeInfinity(negativeInfinityQuantity.Value)); }
public void CubicMeterPerMeterToVolumePerLengthUnits() { VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); AssertEx.EqualTolerance(CubicMetersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.CubicMetersPerMeter, CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(LitersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.LitersPerMeter, LitersPerMeterTolerance); AssertEx.EqualTolerance(OilBarrelsPerFootInOneCubicMeterPerMeter, cubicmeterpermeter.OilBarrelsPerFoot, OilBarrelsPerFootTolerance); }
public void ConversionRoundTrip() { VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); AssertEx.EqualTolerance(1, VolumePerLength.FromCubicMetersPerMeter(cubicmeterpermeter.CubicMetersPerMeter).CubicMetersPerMeter, CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(1, VolumePerLength.FromLitersPerMeter(cubicmeterpermeter.LitersPerMeter).CubicMetersPerMeter, LitersPerMeterTolerance); AssertEx.EqualTolerance(1, VolumePerLength.FromOilBarrelsPerFoot(cubicmeterpermeter.OilBarrelsPerFoot).CubicMetersPerMeter, OilBarrelsPerFootTolerance); }
public void As() { var cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); AssertEx.EqualTolerance(CubicMetersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.As(VolumePerLengthUnit.CubicMeterPerMeter), CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(LitersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.As(VolumePerLengthUnit.LiterPerMeter), LitersPerMeterTolerance); AssertEx.EqualTolerance(OilBarrelsPerFootInOneCubicMeterPerMeter, cubicmeterpermeter.As(VolumePerLengthUnit.OilBarrelPerFoot), OilBarrelsPerFootTolerance); }
public void Equals_QuantityAsObject_IsImplemented() { object a = VolumePerLength.FromCubicMetersPerMeter(1); object b = VolumePerLength.FromCubicMetersPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); Assert.False(a.Equals((object)null)); }
public void To_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { var cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.SI)); Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.CGS)); Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.BI)); Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.EE)); Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.USC)); Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.FPS)); Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.Astronomical)); }
public void ArithmeticOperators() { VolumePerLength v = VolumePerLength.FromCubicMetersPerMeter(1); AssertEx.EqualTolerance(-1, -v.CubicMetersPerMeter, CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(2, (VolumePerLength.FromCubicMetersPerMeter(3) - v).CubicMetersPerMeter, CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(2, (v + v).CubicMetersPerMeter, CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(10, (v * 10).CubicMetersPerMeter, CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(10, (10 * v).CubicMetersPerMeter, CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(2, (VolumePerLength.FromCubicMetersPerMeter(10) / 5).CubicMetersPerMeter, CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(2, VolumePerLength.FromCubicMetersPerMeter(10) / VolumePerLength.FromCubicMetersPerMeter(5), CubicMetersPerMeterTolerance); }
public void ComparisonOperators() { VolumePerLength oneCubicMeterPerMeter = VolumePerLength.FromCubicMetersPerMeter(1); VolumePerLength twoCubicMetersPerMeter = VolumePerLength.FromCubicMetersPerMeter(2); Assert.True(oneCubicMeterPerMeter < twoCubicMetersPerMeter); Assert.True(oneCubicMeterPerMeter <= twoCubicMetersPerMeter); Assert.True(twoCubicMetersPerMeter > oneCubicMeterPerMeter); Assert.True(twoCubicMetersPerMeter >= oneCubicMeterPerMeter); Assert.False(oneCubicMeterPerMeter > twoCubicMetersPerMeter); Assert.False(oneCubicMeterPerMeter >= twoCubicMetersPerMeter); Assert.False(twoCubicMetersPerMeter < oneCubicMeterPerMeter); Assert.False(twoCubicMetersPerMeter <= oneCubicMeterPerMeter); }
public void EqualityOperators() { var a = VolumePerLength.FromCubicMetersPerMeter(1); var b = VolumePerLength.FromCubicMetersPerMeter(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 CompareToThrowsOnNull() { VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); Assert.Throws <ArgumentNullException>(() => cubicmeterpermeter.CompareTo(null)); }
public void CompareToThrowsOnTypeMismatch() { VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); Assert.Throws <ArgumentException>(() => cubicmeterpermeter.CompareTo(new object())); }
public void Convert_ToInt16_EqualsValueAsSameType() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); }
public void FromCubicMetersPerMeter_WithNanValue_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => VolumePerLength.FromCubicMetersPerMeter(double.NaN)); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = VolumePerLength.FromCubicMetersPerMeter(value); Assert.Equal(VolumePerLength.FromCubicMetersPerMeter(-value), -quantity); }
public void GetHashCode_Equals() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); Assert.Equal(new { VolumePerLength.Info.Name, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
public void EqualsReturnsFalseOnTypeMismatch() { VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); Assert.False(cubicmeterpermeter.Equals(new object())); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumePerLengthUnit))); }
public void Convert_ChangeType_SelfType_EqualsSelf() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(VolumePerLength))); }
public void FromCubicMetersPerMeter_WithInfinityValue_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => VolumePerLength.FromCubicMetersPerMeter(double.PositiveInfinity)); Assert.Throws <ArgumentException>(() => VolumePerLength.FromCubicMetersPerMeter(double.NegativeInfinity)); }
public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); Assert.Equal(VolumePerLength.Info, Convert.ChangeType(quantity, typeof(QuantityInfo))); }
public void Convert_ToString_EqualsToString() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void EqualsReturnsFalseOnNull() { VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); Assert.False(cubicmeterpermeter.Equals(null)); }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); Assert.Equal(VolumePerLength.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }