コード例 #1
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = ElectricField.FromVoltsPerMeter(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
コード例 #2
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = ElectricField.FromVoltsPerMeter(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
コード例 #3
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = ElectricField.FromVoltsPerMeter(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
コード例 #4
0
        public void CompareToThrowsOnNull()
        {
            ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);

            Assert.Throws <ArgumentNullException>(() => voltpermeter.CompareTo(null));
        }
コード例 #5
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);

            Assert.False(voltpermeter.Equals(new object()));
        }
コード例 #6
0
        public void ToUnit_WithNullUnitSystem_ThrowsNullException()
        {
            var voltpermeter = ElectricField.FromVoltsPerMeter(1);

            Assert.Throws <ArgumentNullException>(() => voltpermeter.ToUnit(null));
        }
コード例 #7
0
        public void ConversionRoundTrip()
        {
            ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);

            AssertEx.EqualTolerance(1, ElectricField.FromVoltsPerMeter(voltpermeter.VoltsPerMeter).VoltsPerMeter, VoltsPerMeterTolerance);
        }
コード例 #8
0
        public void GetHashCode_Equals()
        {
            var quantity = ElectricField.FromVoltsPerMeter(1.0);

            Assert.Equal(new { ElectricField.Info.Name, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
コード例 #9
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = ElectricField.FromVoltsPerMeter(value);

            Assert.Equal(ElectricField.FromVoltsPerMeter(-value), -quantity);
        }
コード例 #10
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = ElectricField.FromVoltsPerMeter(1.0);

            Assert.Equal(ElectricField.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
コード例 #11
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = ElectricField.FromVoltsPerMeter(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
コード例 #12
0
        public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo()
        {
            var quantity = ElectricField.FromVoltsPerMeter(1.0);

            Assert.Equal(ElectricField.Info, Convert.ChangeType(quantity, typeof(QuantityInfo)));
        }
コード例 #13
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = ElectricField.FromVoltsPerMeter(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricFieldUnit)));
        }
コード例 #14
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = ElectricField.FromVoltsPerMeter(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(ElectricField)));
        }
コード例 #15
0
 public void FromVoltsPerMeter_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => ElectricField.FromVoltsPerMeter(double.NaN));
 }
コード例 #16
0
 public void NumberToVoltsPerMeterTest() =>
 Assert.Equal(ElectricField.FromVoltsPerMeter(2), 2.VoltsPerMeter());
コード例 #17
0
        public void As()
        {
            var voltpermeter = ElectricField.FromVoltsPerMeter(1);

            AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, voltpermeter.As(ElectricFieldUnit.VoltPerMeter), VoltsPerMeterTolerance);
        }
コード例 #18
0
 /// <inheritdoc cref="ElectricField.FromVoltsPerMeter(double)"/>
 public static ElectricField VoltsPerMeter(this double value) => ElectricField.FromVoltsPerMeter(value);
コード例 #19
0
        public void ToBaseUnit_ReturnsQuantityWithBaseUnit()
        {
            var quantityInBaseUnit = ElectricField.FromVoltsPerMeter(1).ToBaseUnit();

            Assert.Equal(ElectricField.BaseUnit, quantityInBaseUnit.Unit);
        }
コード例 #20
0
 /// <inheritdoc cref="ElectricField.FromVoltsPerMeter(double?)"/>
 public static ElectricField?VoltsPerMeter(this float?value) => ElectricField.FromVoltsPerMeter(value);
コード例 #21
0
        public void CompareToThrowsOnTypeMismatch()
        {
            ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);

            Assert.Throws <ArgumentException>(() => voltpermeter.CompareTo(new object()));
        }
コード例 #22
0
 /// <inheritdoc cref="ElectricField.FromVoltsPerMeter(double)"/>
 public static ElectricField VoltsPerMeter(this decimal value) => ElectricField.FromVoltsPerMeter(Convert.ToDouble(value));
コード例 #23
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = ElectricField.FromVoltsPerMeter(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(ElectricField.FromVoltsPerMeter(1), -1, ComparisonType.Relative));
        }
コード例 #24
0
 /// <inheritdoc cref="ElectricField.FromVoltsPerMeter(double?)"/>
 public static ElectricField?VoltsPerMeter(this decimal?value) => ElectricField.FromVoltsPerMeter(value == null ? (double?)null : Convert.ToDouble(value.Value));
コード例 #25
0
        public void EqualsReturnsFalseOnNull()
        {
            ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);

            Assert.False(voltpermeter.Equals(null));
        }
コード例 #26
0
        public void VoltPerMeterToElectricFieldUnits()
        {
            ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1);

            AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, voltpermeter.VoltsPerMeter, VoltsPerMeterTolerance);
        }
コード例 #27
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = ElectricField.FromVoltsPerMeter(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
コード例 #28
0
 public void FromVoltsPerMeter_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => ElectricField.FromVoltsPerMeter(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => ElectricField.FromVoltsPerMeter(double.NegativeInfinity));
 }
コード例 #29
0
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = ElectricField.FromVoltsPerMeter(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
コード例 #30
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = ElectricField.FromVoltsPerMeter(1.0);

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