public void Equals_RelativeTolerance_IsImplemented() { var v = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.True(v.Equals(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1), CoulombsPerSquareMeterTolerance, ComparisonType.Relative)); Assert.False(v.Equals(ElectricSurfaceChargeDensity.Zero, CoulombsPerSquareMeterTolerance, ComparisonType.Relative)); }
public void ConversionRoundTrip() { ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.FromCoulombsPerSquareCentimeter(coulombpersquaremeter.CoulombsPerSquareCentimeter).CoulombsPerSquareMeter, CoulombsPerSquareCentimeterTolerance); AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.FromCoulombsPerSquareInch(coulombpersquaremeter.CoulombsPerSquareInch).CoulombsPerSquareMeter, CoulombsPerSquareInchTolerance); AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(coulombpersquaremeter.CoulombsPerSquareMeter).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); }
public void Equals_SameType_IsImplemented() { var a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); var b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); }
public void As() { var coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); AssertEx.EqualTolerance(CoulombsPerSquareCentimeterInOneCoulombPerSquareMeter, coulombpersquaremeter.As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter), CoulombsPerSquareCentimeterTolerance); AssertEx.EqualTolerance(CoulombsPerSquareInchInOneCoulombPerSquareMeter, coulombpersquaremeter.As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch), CoulombsPerSquareInchTolerance); AssertEx.EqualTolerance(CoulombsPerSquareMeterInOneCoulombPerSquareMeter, coulombpersquaremeter.As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter), CoulombsPerSquareMeterTolerance); }
public void FromCoulombsPerSquareMeter_WithInfinityValue_CreateQuantityAndAffectInfinityValue() { var positiveInfinityQuantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.PositiveInfinity); var negativeInfinityQuantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.NegativeInfinity); Assert.True(double.IsPositiveInfinity(positiveInfinityQuantity.Value)); Assert.True(double.IsNegativeInfinity(negativeInfinityQuantity.Value)); }
public void CompareToIsImplemented() { ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.Equal(0, coulombpersquaremeter.CompareTo(coulombpersquaremeter)); Assert.True(coulombpersquaremeter.CompareTo(ElectricSurfaceChargeDensity.Zero) > 0); Assert.True(ElectricSurfaceChargeDensity.Zero.CompareTo(coulombpersquaremeter) < 0); }
public void Equals_QuantityAsObject_IsImplemented() { object a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); object b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); Assert.False(a.Equals((object)null)); }
public void ArithmeticOperators() { ElectricSurfaceChargeDensity v = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); AssertEx.EqualTolerance(-1, -v.CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(3) - v).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (v + v).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (v * 10).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (10 * v).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(10) / 5).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); AssertEx.EqualTolerance(2, ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(10) / ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(5), CoulombsPerSquareMeterTolerance); }
public void To_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { var coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.Throws <ArgumentException>(() => coulombpersquaremeter.ToUnit(UnitSystem.SI)); Assert.Throws <ArgumentException>(() => coulombpersquaremeter.ToUnit(UnitSystem.CGS)); Assert.Throws <ArgumentException>(() => coulombpersquaremeter.ToUnit(UnitSystem.BI)); Assert.Throws <ArgumentException>(() => coulombpersquaremeter.ToUnit(UnitSystem.EE)); Assert.Throws <ArgumentException>(() => coulombpersquaremeter.ToUnit(UnitSystem.USC)); Assert.Throws <ArgumentException>(() => coulombpersquaremeter.ToUnit(UnitSystem.FPS)); Assert.Throws <ArgumentException>(() => coulombpersquaremeter.ToUnit(UnitSystem.Astronomical)); }
public void ComparisonOperators() { ElectricSurfaceChargeDensity oneCoulombPerSquareMeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); ElectricSurfaceChargeDensity twoCoulombsPerSquareMeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); Assert.True(oneCoulombPerSquareMeter < twoCoulombsPerSquareMeter); Assert.True(oneCoulombPerSquareMeter <= twoCoulombsPerSquareMeter); Assert.True(twoCoulombsPerSquareMeter > oneCoulombPerSquareMeter); Assert.True(twoCoulombsPerSquareMeter >= oneCoulombPerSquareMeter); Assert.False(oneCoulombPerSquareMeter > twoCoulombsPerSquareMeter); Assert.False(oneCoulombPerSquareMeter >= twoCoulombsPerSquareMeter); Assert.False(twoCoulombsPerSquareMeter < oneCoulombPerSquareMeter); Assert.False(twoCoulombsPerSquareMeter <= oneCoulombPerSquareMeter); }
public void EqualityOperators() { var a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); var b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(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 ToUnit() { var coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); var coulombpersquarecentimeterQuantity = coulombpersquaremeter.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); AssertEx.EqualTolerance(CoulombsPerSquareCentimeterInOneCoulombPerSquareMeter, (decimal)coulombpersquarecentimeterQuantity.Value, CoulombsPerSquareCentimeterTolerance); Assert.Equal(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, coulombpersquarecentimeterQuantity.Unit); var coulombpersquareinchQuantity = coulombpersquaremeter.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); AssertEx.EqualTolerance(CoulombsPerSquareInchInOneCoulombPerSquareMeter, (decimal)coulombpersquareinchQuantity.Value, CoulombsPerSquareInchTolerance); Assert.Equal(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, coulombpersquareinchQuantity.Unit); var coulombpersquaremeterQuantity = coulombpersquaremeter.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); AssertEx.EqualTolerance(CoulombsPerSquareMeterInOneCoulombPerSquareMeter, (decimal)coulombpersquaremeterQuantity.Value, CoulombsPerSquareMeterTolerance); Assert.Equal(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, coulombpersquaremeterQuantity.Unit); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void Convert_ToString_EqualsToString() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void Convert_ToDateTime_ThrowsInvalidCastException() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity)); }
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
public void CompareToThrowsOnTypeMismatch() { ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.Throws <ArgumentException>(() => coulombpersquaremeter.CompareTo(new object())); }
public void GetHashCode_Equals() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); Assert.Equal(new { ElectricSurfaceChargeDensity.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); Assert.Equal(ElectricSurfaceChargeDensity.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { var v = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1), -1, ComparisonType.Relative)); }
/// <inheritdoc cref="ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(UnitsNet.QuantityValue)" /> public static ElectricSurfaceChargeDensity CoulombsPerSquareMeter <T>(this T value) => ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(Convert.ToDouble(value));
public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1).ToBaseUnit(); Assert.Equal(ElectricSurfaceChargeDensity.BaseUnit, quantityInBaseUnit.Unit); }
public void CompareToThrowsOnNull() { ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.Throws <ArgumentNullException>(() => coulombpersquaremeter.CompareTo(null)); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricSurfaceChargeDensityUnit))); }
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); Assert.Equal(QuantityType.ElectricSurfaceChargeDensity, Convert.ChangeType(quantity, typeof(QuantityType))); }
public void EqualsReturnsFalseOnTypeMismatch() { ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.False(coulombpersquaremeter.Equals(new object())); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void EqualsReturnsFalseOnNull() { ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.False(coulombpersquaremeter.Equals(null)); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(decimal value) { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); Assert.Equal(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(-value), -quantity); }
public void ToString_NullArgs_ThrowsArgumentNullException() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null)); }