/// <inheritdoc cref="ElectricCurrent.FromAmperes(double)"/>
 public static ElectricCurrent Amperes(this double value) => ElectricCurrent.FromAmperes(value);
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
        public void Convert_ToInt64_EqualsValueAsSameType()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity));
        }
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            ElectricCurrent ampere = ElectricCurrent.FromAmperes(1);

            Assert.False(ampere.Equals(new object()));
        }
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
        public void ToBaseUnit_ReturnsQuantityWithBaseUnit()
        {
            var quantityInBaseUnit = ElectricCurrent.FromAmperes(1).ToBaseUnit();

            Assert.Equal(ElectricCurrent.BaseUnit, quantityInBaseUnit.Unit);
        }
        public void CompareToThrowsOnNull()
        {
            ElectricCurrent ampere = ElectricCurrent.FromAmperes(1);

            Assert.Throws <ArgumentNullException>(() => ampere.CompareTo(null));
        }
Beispiel #8
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(ElectricCurrent)));
        }
Beispiel #9
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricCurrentUnit)));
        }
Beispiel #10
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Beispiel #11
0
        public void Convert_ToUInt32_EqualsValueAsSameType()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity));
        }
 /// <inheritdoc cref="ElectricCurrent.FromAmperes(double?)"/>
 public static ElectricCurrent?Amperes(this decimal?value) => ElectricCurrent.FromAmperes(value == null ? (double?)null : Convert.ToDouble(value.Value));
 /// <inheritdoc cref="ElectricCurrent.FromAmperes(double)"/>
 public static ElectricCurrent Amperes(this decimal value) => ElectricCurrent.FromAmperes(Convert.ToDouble(value));
 /// <inheritdoc cref="ElectricCurrent.FromAmperes(double?)"/>
 public static ElectricCurrent?Amperes(this float?value) => ElectricCurrent.FromAmperes(value);
Beispiel #15
0
 public void FromAmperes_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => ElectricCurrent.FromAmperes(double.NaN));
 }
Beispiel #16
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Equal(QuantityType.ElectricCurrent, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Beispiel #17
0
        public void ElectricResistanceTimesElectricCurrentEqualsElectricPotential(float resistance, float current, float expected)
        {
            ElectricPotential potential = ElectricResistance.FromOhms(resistance) * ElectricCurrent.FromAmperes(current);

            Assert.Equal(expected, potential.Volts);
        }
Beispiel #18
0
        public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Equal(ElectricCurrent.Info, Convert.ChangeType(quantity, typeof(QuantityInfo)));
        }
        public void CompareToThrowsOnTypeMismatch()
        {
            ElectricCurrent ampere = ElectricCurrent.FromAmperes(1);

            Assert.Throws <ArgumentException>(() => ampere.CompareTo(new object()));
        }
Beispiel #20
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Equal(ElectricCurrent.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = ElectricCurrent.FromAmperes(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(ElectricCurrent.FromAmperes(1), -1, ComparisonType.Relative));
        }
Beispiel #22
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
        public void EqualsReturnsFalseOnNull()
        {
            ElectricCurrent ampere = ElectricCurrent.FromAmperes(1);

            Assert.False(ampere.Equals(null));
        }
Beispiel #24
0
        public void GetHashCode_Equals()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Equal(new { ElectricCurrent.Info.Name, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
Beispiel #26
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = ElectricCurrent.FromAmperes(value);

            Assert.Equal(ElectricCurrent.FromAmperes(-value), -quantity);
        }
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
Beispiel #28
0
 public void FromAmperes_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => ElectricCurrent.FromAmperes(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => ElectricCurrent.FromAmperes(double.NegativeInfinity));
 }
        public void Convert_ToSByte_EqualsValueAsSameType()
        {
            var quantity = ElectricCurrent.FromAmperes(1.0);

            Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity));
        }
Beispiel #30
0
 /// <inheritdoc cref="ElectricCurrent.FromAmperes(UnitsNet.QuantityValue)" />
 public static ElectricCurrent Amperes <T>(this T value) => ElectricCurrent.FromAmperes(Convert.ToDouble(value));