public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricCurrentGradientUnit))); }
public void ToString_NullArgs_ThrowsArgumentNullException() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); Assert.Throws<ArgumentNullException>(() => quantity.ToString(null, "g", null)); }
public void Convert_ToByte_EqualsValueAsSameType() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); }
public void Equals_RelativeTolerance_IsImplemented() { var v = ElectricCurrentGradient.FromAmperesPerSecond(1); Assert.True(v.Equals(ElectricCurrentGradient.FromAmperesPerSecond(1), AmperesPerSecondTolerance, ComparisonType.Relative)); Assert.False(v.Equals(ElectricCurrentGradient.Zero, AmperesPerSecondTolerance, ComparisonType.Relative)); }
public void EqualsReturnsFalseOnTypeMismatch() { ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); Assert.False(amperepersecond.Equals(new object())); }
public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricCurrentGradient.FromAmperesPerSecond(1).ToBaseUnit(); Assert.Equal(ElectricCurrentGradient.BaseUnit, quantityInBaseUnit.Unit); }
public void CompareToThrowsOnTypeMismatch() { ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); Assert.Throws<ArgumentException>(() => amperepersecond.CompareTo(new object())); }
public static ElectricCurrentGradient AmperesPerSecond <T>(this T value) => ElectricCurrentGradient.FromAmperesPerSecond(Convert.ToDecimal(value));
public void ConversionRoundTrip() { ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); AssertEx.EqualTolerance(1, ElectricCurrentGradient.FromAmperesPerSecond(amperepersecond.AmperesPerSecond).AmperesPerSecond, AmperesPerSecondTolerance); }
public void GetHashCode_Equals() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); Assert.Equal(new { ElectricCurrentGradient.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); Assert.Equal(ElectricCurrentGradient.FromAmperesPerSecond(-value), -quantity); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); Assert.Equal(ElectricCurrentGradient.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); Assert.Equal(QuantityType.ElectricCurrentGradient, Convert.ChangeType(quantity, typeof(QuantityType))); }
public void FromAmperesPerSecond_WithNanValue_ThrowsArgumentException() { Assert.Throws<ArgumentException>(() => ElectricCurrentGradient.FromAmperesPerSecond(double.NaN)); }
public void FromValueAndUnit() { AssertEx.EqualTolerance(1, ElectricCurrentGradient.From(1, ElectricCurrentGradientUnit.AmperePerSecond).AmperesPerSecond, AmperesPerSecondTolerance); }
public void ToUnit_WithNullUnitSystem_ThrowsNullException() { var amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); Assert.Throws<ArgumentNullException>(() => amperepersecond.ToUnit(null)); }
public void As() { var amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); AssertEx.EqualTolerance(AmperesPerSecondInOneAmperePerSecond, amperepersecond.As(ElectricCurrentGradientUnit.AmperePerSecond), AmperesPerSecondTolerance); }
public void ArithmeticOperators() { ElectricCurrentGradient v = ElectricCurrentGradient.FromAmperesPerSecond(1); AssertEx.EqualTolerance(-1, -v.AmperesPerSecond, AmperesPerSecondTolerance); AssertEx.EqualTolerance(2, (ElectricCurrentGradient.FromAmperesPerSecond(3)-v).AmperesPerSecond, AmperesPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).AmperesPerSecond, AmperesPerSecondTolerance); AssertEx.EqualTolerance(10, (v*10).AmperesPerSecond, AmperesPerSecondTolerance); AssertEx.EqualTolerance(10, (10*v).AmperesPerSecond, AmperesPerSecondTolerance); AssertEx.EqualTolerance(2, (ElectricCurrentGradient.FromAmperesPerSecond(10)/5).AmperesPerSecond, AmperesPerSecondTolerance); AssertEx.EqualTolerance(2, ElectricCurrentGradient.FromAmperesPerSecond(10)/ElectricCurrentGradient.FromAmperesPerSecond(5), AmperesPerSecondTolerance); }
/// <inheritdoc cref="ElectricCurrentGradient.FromAmperesPerSecond(double)"/> public static ElectricCurrentGradient AmperesPerSecond(this double value) => ElectricCurrentGradient.FromAmperesPerSecond(value);
public void CompareToThrowsOnNull() { ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); Assert.Throws<ArgumentNullException>(() => amperepersecond.CompareTo(null)); }
/// <inheritdoc cref="ElectricCurrentGradient.FromAmperesPerSecond(double?)"/> public static ElectricCurrentGradient?AmperesPerSecond(this float?value) => ElectricCurrentGradient.FromAmperesPerSecond(value);
public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { var v = ElectricCurrentGradient.FromAmperesPerSecond(1); Assert.Throws<ArgumentOutOfRangeException>(() => v.Equals(ElectricCurrentGradient.FromAmperesPerSecond(1), -1, ComparisonType.Relative)); }
/// <inheritdoc cref="ElectricCurrentGradient.FromAmperesPerSecond(double)"/> public static ElectricCurrentGradient AmperesPerSecond(this decimal value) => ElectricCurrentGradient.FromAmperesPerSecond(Convert.ToDouble(value));
public void EqualsReturnsFalseOnNull() { ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); Assert.False(amperepersecond.Equals(null)); }
/// <inheritdoc cref="ElectricCurrentGradient.FromAmperesPerSecond(double?)"/> public static ElectricCurrentGradient?AmperesPerSecond(this decimal?value) => ElectricCurrentGradient.FromAmperesPerSecond(value == null ? (double?)null : Convert.ToDouble(value.Value));
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
public void FromAmperesPerSecond_WithInfinityValue_ThrowsArgumentException() { Assert.Throws<ArgumentException>(() => ElectricCurrentGradient.FromAmperesPerSecond(double.PositiveInfinity)); Assert.Throws<ArgumentException>(() => ElectricCurrentGradient.FromAmperesPerSecond(double.NegativeInfinity)); }
public void Convert_ToChar_ThrowsInvalidCastException() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); Assert.Throws<InvalidCastException>(() => Convert.ToChar(quantity)); }
public void Convert_ToString_EqualsToString() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }