/// <inheritdoc cref="Capacitance.FromFarads(double?)"/>
 public static Capacitance?Farads(this decimal?value) => Capacitance.FromFarads(value == null ? (double?)null : Convert.ToDouble(value.Value));
Пример #2
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Equal(QuantityType.Capacitance, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Пример #3
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Пример #4
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Пример #5
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(Capacitance)));
        }
Пример #6
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
Пример #7
0
        public void Convert_ToInt32_EqualsValueAsSameType()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity));
        }
Пример #8
0
        public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Equal(Capacitance.Info, Convert.ChangeType(quantity, typeof(QuantityInfo)));
        }
Пример #9
0
        public void FromFarads_WithNanValue_CreateQuantityAndAffectNaNValue()
        {
            var nanQuantity = Capacitance.FromFarads(double.NaN);

            Assert.True(double.IsNaN(nanQuantity.Value));
        }
Пример #10
0
 public void FromFarads_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => Capacitance.FromFarads(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => Capacitance.FromFarads(double.NegativeInfinity));
 }
Пример #11
0
 public void FromFarads_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => Capacitance.FromFarads(double.NaN));
 }
Пример #12
0
        public void ConversionRoundTrip()
        {
            Capacitance farad = Capacitance.FromFarads(1);

            AssertEx.EqualTolerance(1, Capacitance.FromFarads(farad.Farads).Farads, FaradsTolerance);
        }
Пример #13
0
        public void As()
        {
            var farad = Capacitance.FromFarads(1);

            AssertEx.EqualTolerance(FaradsInOneFarad, farad.As(CapacitanceUnit.Farad), FaradsTolerance);
        }
Пример #14
0
        public void FaradToCapacitanceUnits()
        {
            Capacitance farad = Capacitance.FromFarads(1);

            AssertEx.EqualTolerance(FaradsInOneFarad, farad.Farads, FaradsTolerance);
        }
Пример #15
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
Пример #16
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = Capacitance.FromFarads(value);

            Assert.Equal(Capacitance.FromFarads(-value), -quantity);
        }
Пример #17
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
Пример #18
0
        public void ToBaseUnit_ReturnsQuantityWithBaseUnit()
        {
            var quantityInBaseUnit = Capacitance.FromFarads(1).ToBaseUnit();

            Assert.Equal(Capacitance.BaseUnit, quantityInBaseUnit.Unit);
        }
Пример #19
0
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
Пример #20
0
        public void CompareToThrowsOnTypeMismatch()
        {
            Capacitance farad = Capacitance.FromFarads(1);

            Assert.Throws <ArgumentException>(() => farad.CompareTo(new object()));
        }
Пример #21
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Пример #22
0
        public void CompareToThrowsOnNull()
        {
            Capacitance farad = Capacitance.FromFarads(1);

            Assert.Throws <ArgumentNullException>(() => farad.CompareTo(null));
        }
Пример #23
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Пример #24
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = Capacitance.FromFarads(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(Capacitance.FromFarads(1), -1, ComparisonType.Relative));
        }
Пример #25
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(CapacitanceUnit)));
        }
Пример #26
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            Capacitance farad = Capacitance.FromFarads(1);

            Assert.False(farad.Equals(new object()));
        }
Пример #27
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Equal(Capacitance.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Пример #28
0
        public void EqualsReturnsFalseOnNull()
        {
            Capacitance farad = Capacitance.FromFarads(1);

            Assert.False(farad.Equals(null));
        }
Пример #29
0
        public void GetHashCode_Equals()
        {
            var quantity = Capacitance.FromFarads(1.0);

            Assert.Equal(new { Capacitance.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
 /// <inheritdoc cref="Capacitance.FromFarads(double)"/>
 public static Capacitance Farads(this decimal value) => Capacitance.FromFarads(Convert.ToDouble(value));