Exemple #1
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricCurrentGradientUnit)));
        }
Exemple #2
0
 public void ToString_NullArgs_ThrowsArgumentNullException()
 {
     var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0);
     Assert.Throws<ArgumentNullException>(() => quantity.ToString(null, "g", null));
 }
Exemple #3
0
 public void Convert_ToByte_EqualsValueAsSameType()
 {
     var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0);
    Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity));
 }
Exemple #4
0
 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));
 }
Exemple #5
0
 public void EqualsReturnsFalseOnTypeMismatch()
 {
     ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1);
     Assert.False(amperepersecond.Equals(new object()));
 }
Exemple #6
0
 public void ToBaseUnit_ReturnsQuantityWithBaseUnit()
 {
     var quantityInBaseUnit = ElectricCurrentGradient.FromAmperesPerSecond(1).ToBaseUnit();
     Assert.Equal(ElectricCurrentGradient.BaseUnit, quantityInBaseUnit.Unit);
 }
Exemple #7
0
 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);
        }
Exemple #10
0
        public void GetHashCode_Equals()
        {
            var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0);

            Assert.Equal(new { ElectricCurrentGradient.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Exemple #11
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value);

            Assert.Equal(ElectricCurrentGradient.FromAmperesPerSecond(-value), -quantity);
        }
Exemple #12
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Exemple #13
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0);

            Assert.Equal(ElectricCurrentGradient.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Exemple #14
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0);

            Assert.Equal(QuantityType.ElectricCurrentGradient, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Exemple #15
0
 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);
 }
Exemple #17
0
        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);
        }
Exemple #19
0
 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);
Exemple #21
0
 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);
Exemple #23
0
 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));
Exemple #25
0
 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));
Exemple #27
0
 public void ToString_NullProvider_EqualsCurrentUICulture()
 {
     var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0);
     Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
 }
Exemple #28
0
 public void FromAmperesPerSecond_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws<ArgumentException>(() => ElectricCurrentGradient.FromAmperesPerSecond(double.PositiveInfinity));
     Assert.Throws<ArgumentException>(() => ElectricCurrentGradient.FromAmperesPerSecond(double.NegativeInfinity));
 }
Exemple #29
0
 public void Convert_ToChar_ThrowsInvalidCastException()
 {
     var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0);
     Assert.Throws<InvalidCastException>(() => Convert.ToChar(quantity));
 }
Exemple #30
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }