Ejemplo n.º 1
0
 public void FromAmperesPerMeter_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => Magnetization.FromAmperesPerMeter(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => Magnetization.FromAmperesPerMeter(double.NegativeInfinity));
 }
Ejemplo n.º 2
0
        public void As()
        {
            var amperepermeter = Magnetization.FromAmperesPerMeter(1);

            AssertEx.EqualTolerance(AmperesPerMeterInOneAmperePerMeter, amperepermeter.As(MagnetizationUnit.AmperePerMeter), AmperesPerMeterTolerance);
        }
Ejemplo n.º 3
0
        public void CompareToThrowsOnTypeMismatch()
        {
            Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1);

            Assert.Throws <ArgumentException>(() => amperepermeter.CompareTo(new object()));
        }
 /// <inheritdoc cref="Magnetization.FromAmperesPerMeter(double)"/>
 public static Magnetization AmperesPerMeter(this decimal value) => Magnetization.FromAmperesPerMeter(Convert.ToDouble(value));
Ejemplo n.º 5
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1);

            Assert.False(amperepermeter.Equals(new object()));
        }
Ejemplo n.º 6
0
        public void GetHashCode_Equals()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Equal(new { Magnetization.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
 /// <inheritdoc cref="Magnetization.FromAmperesPerMeter(double)"/>
 public static Magnetization AmperesPerMeter(this double value) => Magnetization.FromAmperesPerMeter(value);
Ejemplo n.º 8
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
Ejemplo n.º 9
0
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
Ejemplo n.º 10
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
Ejemplo n.º 11
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
Ejemplo n.º 12
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = Magnetization.FromAmperesPerMeter(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(Magnetization.FromAmperesPerMeter(1), -1, ComparisonType.Relative));
        }
Ejemplo n.º 13
0
        public void ToBaseUnit_ReturnsQuantityWithBaseUnit()
        {
            var quantityInBaseUnit = Magnetization.FromAmperesPerMeter(1).ToBaseUnit();

            Assert.Equal(Magnetization.BaseUnit, quantityInBaseUnit.Unit);
        }
Ejemplo n.º 14
0
 public void FromAmperesPerMeter_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => Magnetization.FromAmperesPerMeter(double.NaN));
 }
Ejemplo n.º 15
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Equal(Magnetization.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Ejemplo n.º 16
0
        public void Convert_ToInt16_EqualsValueAsSameType()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity));
        }
Ejemplo n.º 17
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Ejemplo n.º 18
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Ejemplo n.º 19
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = Magnetization.FromAmperesPerMeter(value);

            Assert.Equal(Magnetization.FromAmperesPerMeter(-value), -quantity);
        }
Ejemplo n.º 20
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
 /// <inheritdoc cref="Magnetization.FromAmperesPerMeter(double?)"/>
 public static Magnetization?AmperesPerMeter(this float?value) => Magnetization.FromAmperesPerMeter(value);
Ejemplo n.º 22
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
 /// <inheritdoc cref="Magnetization.FromAmperesPerMeter(double?)"/>
 public static Magnetization?AmperesPerMeter(this decimal?value) => Magnetization.FromAmperesPerMeter(value == null ? (double?)null : Convert.ToDouble(value.Value));
Ejemplo n.º 24
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(Magnetization)));
        }
Ejemplo n.º 25
0
        public void EqualsReturnsFalseOnNull()
        {
            Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1);

            Assert.False(amperepermeter.Equals(null));
        }
Ejemplo n.º 26
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MagnetizationUnit)));
        }
Ejemplo n.º 27
0
        public void ConversionRoundTrip()
        {
            Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1);

            AssertEx.EqualTolerance(1, Magnetization.FromAmperesPerMeter(amperepermeter.AmperesPerMeter).AmperesPerMeter, AmperesPerMeterTolerance);
        }
Ejemplo n.º 28
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = Magnetization.FromAmperesPerMeter(1.0);

            Assert.Equal(QuantityType.Magnetization, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Ejemplo n.º 29
0
        public void CompareToThrowsOnNull()
        {
            Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1);

            Assert.Throws <ArgumentNullException>(() => amperepermeter.CompareTo(null));
        }
Ejemplo n.º 30
0
        public void ToUnit_WithNullUnitSystem_ThrowsNullException()
        {
            var amperepermeter = Magnetization.FromAmperesPerMeter(1);

            Assert.Throws <ArgumentNullException>(() => amperepermeter.ToUnit(null));
        }