public void EqualsIsImplemented() { ElectricCurrentDensity v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.True(v.Equals(ElectricCurrentDensity.FromAmperesPerSquareMeter(1), ElectricCurrentDensity.FromAmperesPerSquareMeter(AmperesPerSquareMeterTolerance))); Assert.False(v.Equals(ElectricCurrentDensity.Zero, ElectricCurrentDensity.FromAmperesPerSquareMeter(AmperesPerSquareMeterTolerance))); }
public void Equals_RelativeTolerance_IsImplemented() { var v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.True(v.Equals(ElectricCurrentDensity.FromAmperesPerSquareMeter(1), AmperesPerSquareMeterTolerance, ComparisonType.Relative)); Assert.False(v.Equals(ElectricCurrentDensity.Zero, AmperesPerSquareMeterTolerance, ComparisonType.Relative)); }
public void Equals_SameType_IsImplemented() { var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); }
public void ConversionRoundTrip() { ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareFoot(amperepersquaremeter.AmperesPerSquareFoot).AmperesPerSquareMeter, AmperesPerSquareFootTolerance); AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareInch(amperepersquaremeter.AmperesPerSquareInch).AmperesPerSquareMeter, AmperesPerSquareInchTolerance); AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareMeter(amperepersquaremeter.AmperesPerSquareMeter).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); }
public void CompareToIsImplemented() { ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.Equal(0, amperepersquaremeter.CompareTo(amperepersquaremeter)); Assert.True(amperepersquaremeter.CompareTo(ElectricCurrentDensity.Zero) > 0); Assert.True(ElectricCurrentDensity.Zero.CompareTo(amperepersquaremeter) < 0); }
public void As() { var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); AssertEx.EqualTolerance(AmperesPerSquareFootInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareFoot), AmperesPerSquareFootTolerance); AssertEx.EqualTolerance(AmperesPerSquareInchInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareInch), AmperesPerSquareInchTolerance); AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareMeter), AmperesPerSquareMeterTolerance); }
public void FromAmperesPerSquareMeter_WithInfinityValue_CreateQuantityAndAffectInfinityValue() { var positiveInfinityQuantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(double.PositiveInfinity); var negativeInfinityQuantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(double.NegativeInfinity); Assert.True(double.IsPositiveInfinity(positiveInfinityQuantity.Value)); Assert.True(double.IsNegativeInfinity(negativeInfinityQuantity.Value)); }
public void Equals_QuantityAsObject_IsImplemented() { object a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); object b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); Assert.False(a.Equals((object)null)); }
public void ToUnit() { var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); var amperepersquaremeterQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareMeter); AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, (double)amperepersquaremeterQuantity.Value, AmperesPerSquareMeterTolerance); Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareMeter, amperepersquaremeterQuantity.Unit); }
public void ArithmeticOperators() { ElectricCurrentDensity v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); AssertEx.EqualTolerance(-1, -v.AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (ElectricCurrentDensity.FromAmperesPerSquareMeter(3) - v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (v + v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (v * 10).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (10 * v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (ElectricCurrentDensity.FromAmperesPerSquareMeter(10) / 5).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); AssertEx.EqualTolerance(2, ElectricCurrentDensity.FromAmperesPerSquareMeter(10) / ElectricCurrentDensity.FromAmperesPerSquareMeter(5), AmperesPerSquareMeterTolerance); }
public void To_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.SI)); Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.CGS)); Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.BI)); Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.EE)); Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.USC)); Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.FPS)); Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.Astronomical)); }
public void EqualityOperators() { ElectricCurrentDensity a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); ElectricCurrentDensity b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); // ReSharper disable EqualExpressionComparison Assert.True(a == a); Assert.True(a != b); Assert.False(a == b); Assert.False(a != a); // ReSharper restore EqualExpressionComparison }
public void ComparisonOperators() { ElectricCurrentDensity oneAmperePerSquareMeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); ElectricCurrentDensity twoAmperesPerSquareMeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); Assert.True(oneAmperePerSquareMeter < twoAmperesPerSquareMeter); Assert.True(oneAmperePerSquareMeter <= twoAmperesPerSquareMeter); Assert.True(twoAmperesPerSquareMeter > oneAmperePerSquareMeter); Assert.True(twoAmperesPerSquareMeter >= oneAmperePerSquareMeter); Assert.False(oneAmperePerSquareMeter > twoAmperesPerSquareMeter); Assert.False(oneAmperePerSquareMeter >= twoAmperesPerSquareMeter); Assert.False(twoAmperesPerSquareMeter < oneAmperePerSquareMeter); Assert.False(twoAmperesPerSquareMeter <= oneAmperePerSquareMeter); }
public void ToUnit() { var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); var amperepersquarefootQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareFoot); AssertEx.EqualTolerance(AmperesPerSquareFootInOneAmperePerSquareMeter, (decimal)amperepersquarefootQuantity.Value, AmperesPerSquareFootTolerance); Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareFoot, amperepersquarefootQuantity.Unit); var amperepersquareinchQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareInch); AssertEx.EqualTolerance(AmperesPerSquareInchInOneAmperePerSquareMeter, (decimal)amperepersquareinchQuantity.Value, AmperesPerSquareInchTolerance); Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareInch, amperepersquareinchQuantity.Unit); var amperepersquaremeterQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareMeter); AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, (decimal)amperepersquaremeterQuantity.Value, AmperesPerSquareMeterTolerance); Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareMeter, amperepersquaremeterQuantity.Unit); }
public void EqualityOperators() { var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(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 CompareToThrowsOnNull() { ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.Throws <ArgumentNullException>(() => amperepersquaremeter.CompareTo(null)); }
public void CompareToThrowsOnTypeMismatch() { ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.Throws <ArgumentException>(() => amperepersquaremeter.CompareTo(new object())); }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); Assert.Equal(ElectricCurrentDensity.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void EqualsReturnsFalseOnNull() { ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.False(amperepersquaremeter.Equals(null)); }
/// <inheritdoc cref="ElectricCurrentDensity.FromAmperesPerSquareMeter(double?)"/> public static ElectricCurrentDensity?AmperesPerSquareMeter(this float?value) => ElectricCurrentDensity.FromAmperesPerSquareMeter(value);
public void NegationOperator_ReturnsQuantity_WithNegatedValue(decimal value) { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); Assert.Equal(ElectricCurrentDensity.FromAmperesPerSquareMeter(-value), -quantity); }
public void GetHashCode_Equals() { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); Assert.Equal(new { ElectricCurrentDensity.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
/// <inheritdoc cref="ElectricCurrentDensity.FromAmperesPerSquareMeter(double)"/> public static ElectricCurrentDensity AmperesPerSquareMeter(this decimal value) => ElectricCurrentDensity.FromAmperesPerSquareMeter(Convert.ToDouble(value));
public void EqualsReturnsFalseOnTypeMismatch() { ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.False(amperepersquaremeter.Equals(new object())); }
/// <inheritdoc cref="ElectricCurrentDensity.FromAmperesPerSquareMeter(double?)"/> public static ElectricCurrentDensity?AmperesPerSquareMeter(this decimal?value) => ElectricCurrentDensity.FromAmperesPerSquareMeter(value == null ? (double?)null : Convert.ToDouble(value.Value));
public void AmperePerSquareMeterToElectricCurrentDensityUnits() { ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); }
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); Assert.Equal(QuantityType.ElectricCurrentDensity, Convert.ChangeType(quantity, typeof(QuantityType))); }
public void NumberToAmperesPerSquareMeterTest() => Assert.Equal(ElectricCurrentDensity.FromAmperesPerSquareMeter(2), 2.AmperesPerSquareMeter());
/// <inheritdoc cref="ElectricCurrentDensity.FromAmperesPerSquareMeter(double)"/> public static ElectricCurrentDensity AmperesPerSquareMeter(this double value) => ElectricCurrentDensity.FromAmperesPerSquareMeter(value);