Ejemplo n.º 1
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
 /// <inheritdoc cref="LinearDensity.FromKilogramsPerMeter(double)"/>
 public static LinearDensity KilogramsPerMeter(this decimal value) => LinearDensity.FromKilogramsPerMeter(Convert.ToDouble(value));
 /// <inheritdoc cref="LinearDensity.FromPoundsPerFoot(double?)"/>
 public static LinearDensity?PoundsPerFoot(this int?value) => LinearDensity.FromPoundsPerFoot(value);
Ejemplo n.º 4
0
        public void DensityTimesAreaEqualsLinearDensity()
        {
            LinearDensity linearDensity = Density.FromGramsPerCubicCentimeter(10) * Area.FromSquareCentimeters(2);

            Assert.Equal(LinearDensity.FromGramsPerCentimeter(20), linearDensity);
        }
 public void NumberToPoundsPerFootTest() =>
 Assert.Equal(LinearDensity.FromPoundsPerFoot(2), 2.PoundsPerFoot());
Ejemplo n.º 6
0
 /// <inheritdoc cref="LinearDensity.FromPoundsPerFoot(UnitsNet.QuantityValue)" />
 public static LinearDensity?PoundsPerFoot(this decimal?value) => LinearDensity.FromPoundsPerFoot(value == null ? (double?)null : Convert.ToDouble(value.Value));
Ejemplo n.º 7
0
 /// <inheritdoc cref="LinearDensity.FromGramsPerMeter(UnitsNet.QuantityValue)" />
 public static LinearDensity GramsPerMeter(this float value) => LinearDensity.FromGramsPerMeter(value);
Ejemplo n.º 8
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(LinearDensity)));
        }
Ejemplo n.º 9
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LinearDensityUnit)));
        }
Ejemplo n.º 10
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Ejemplo n.º 11
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Ejemplo n.º 12
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Ejemplo n.º 13
0
        public void Convert_ToInt16_EqualsValueAsSameType()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity));
        }
Ejemplo n.º 14
0
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
Ejemplo n.º 15
0
        public void AreaTimesDensityEqualsLinearDensity()
        {
            LinearDensity linearDensity = Area.FromSquareCentimeters(2) * Density.FromGramsPerCubicCentimeter(10);

            Assert.Equal(LinearDensity.FromGramsPerCentimeter(20), linearDensity);
        }
Ejemplo n.º 16
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Equal(QuantityType.LinearDensity, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Ejemplo n.º 17
0
 /// <inheritdoc cref="LinearDensity.FromPoundsPerFoot(UnitsNet.QuantityValue)" />
 public static LinearDensity PoundsPerFoot(this decimal value) => LinearDensity.FromPoundsPerFoot(Convert.ToDouble(value));
Ejemplo n.º 18
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Equal(LinearDensity.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Ejemplo n.º 19
0
 /// <inheritdoc cref="LinearDensity.FromGramsPerMeter(UnitsNet.QuantityValue)" />
 public static LinearDensity?GramsPerMeter(this double?value) => LinearDensity.FromGramsPerMeter(value);
Ejemplo n.º 20
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Ejemplo n.º 21
0
 /// <inheritdoc cref="LinearDensity.FromKilogramsPerMeter(UnitsNet.QuantityValue)" />
 public static LinearDensity KilogramsPerMeter(this double value) => LinearDensity.FromKilogramsPerMeter(value);
Ejemplo n.º 22
0
        public void GetHashCode_Equals()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Equal(new { LinearDensity.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
 public void NumberToKilogramsPerMeterTest() =>
 Assert.Equal(LinearDensity.FromKilogramsPerMeter(2), 2.KilogramsPerMeter());
Ejemplo n.º 24
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(value);

            Assert.Equal(LinearDensity.FromKilogramsPerMeter(-value), -quantity);
        }
 /// <inheritdoc cref="LinearDensity.FromKilogramsPerMeter(double?)"/>
 public static LinearDensity?KilogramsPerMeter(this float?value) => LinearDensity.FromKilogramsPerMeter(value);
 public void NumberToGramsPerCentimeterTest() =>
 Assert.Equal(LinearDensity.FromGramsPerCentimeter(2), 2.GramsPerCentimeter());
 /// <inheritdoc cref="LinearDensity.FromKilogramsPerMeter(double?)"/>
 public static LinearDensity?KilogramsPerMeter(this decimal?value) => LinearDensity.FromKilogramsPerMeter(value == null ? (double?)null : Convert.ToDouble(value.Value));
 public void NumberToMilligramsPerMillimeterTest() =>
 Assert.Equal(LinearDensity.FromMilligramsPerMillimeter(2), 2.MilligramsPerMillimeter());
 /// <inheritdoc cref="LinearDensity.FromPoundsPerFoot(double)"/>
 public static LinearDensity PoundsPerFoot(this long value) => LinearDensity.FromPoundsPerFoot(value);
Ejemplo n.º 30
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = LinearDensity.FromKilogramsPerMeter(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }