public void ToStandardMeasures_DecimalWithUnitConversion_ReturningConvertedStandardMeasures() { var measures = new[] { 1.0m, 2.0m, 3.0m, -2.0m }.Cast(ElectricCurrent.MilliAmpere); var expected = new ElectricCurrent(0.002m); var actual = measures.ElementAt(1); MeasureAssert.MeasuresAreEqual(expected, actual); }
public void VerifyAllEnums() { var acceleration = new Acceleration(1, AccelerationUnit.BaseUnit); var angle = new Angle(1, AngleUnit.BaseUnit); var angularAcceleration = new AngularAcceleration(1, AngularAccelerationUnit.BaseUnit); var area = new Area(1, AreaUnit.BaseUnit); var density = new MassDensity(1, MassDensityUnit.BaseUnit); var electricCurrent = new ElectricCurrent(1, ElectricCurrentUnit.BaseUnit); var electricResistance = new ElectricResistance(1, ElectricResistanceUnit.BaseUnit); var electricVoltage = new ElectricPotential(1, ElectricPotentialUnit.BaseUnit); var energy = new Energy(1, EnergyUnit.BaseUnit); var force = new Force(1, ForceUnit.BaseUnit); var frequency = new Frequency(1, FrequencyUnit.BaseUnit); var jerk = new Jerk(1, JerkUnit.BaseUnit); var length = new Length(1, LengthUnit.BaseUnit); var mass = new Mass(1, MassUnit.BaseUnit); var massFlowRate = new MassFlowRate(1, MassFlowRateUnit.BaseUnit); var momentum = new Momentum(1, MomentumUnit.BaseUnit); var numeric = new Numeric(1, NumericUnit.BaseUnit); var power = new Power(1, PowerUnit.BaseUnit); var pressure = new Pressure(1, PressureUnit.BaseUnit); var speed = new Speed(1, SpeedUnit.BaseUnit); var temperature = new Temperature(1, TemperatureUnit.BaseUnit); var time = new Time(1, TimeUnit.BaseUnit); var torque = new Torque(1, TorqueUnit.BaseUnit); var volume = new Volume(1, VolumeUnit.BaseUnit); var volumetricFlowRate = new VolumetricFlowRate(1, VolumetricFlowRateUnit.BaseUnit); }
public void OpAddition() { var current1 = new ElectricCurrent(3000, ElectricCurrentUnit.Ampere); var current2 = new ElectricCurrent(1, ElectricCurrentUnit.KiloAmpere); var expected = new ElectricCurrent(4000, ElectricCurrentUnit.Ampere); (current1 + current2).ShouldEqual(expected); (current2 + current1).ShouldEqual(expected); }
public void OpGreaterThanOrEqual() { var current1 = new ElectricCurrent(3000, ElectricCurrentUnit.Ampere); var current2 = new ElectricCurrent(3, ElectricCurrentUnit.KiloAmpere); var current3 = new ElectricCurrent(6, ElectricCurrentUnit.KiloAmpere); (current1 >= current3).ShouldBeFalse(); (current3 >= current1).ShouldBeTrue(); (current1 >= current2).ShouldBeTrue(); (current2 >= current1).ShouldBeTrue(); }
public void OpInverseEquals() { var current1 = new ElectricCurrent(3000, ElectricCurrentUnit.Ampere); var current2 = new ElectricCurrent(3, ElectricCurrentUnit.KiloAmpere); var current3 = new ElectricCurrent(6, ElectricCurrentUnit.KiloAmpere); (current1 != current2).ShouldBeFalse(); (current2 != current1).ShouldBeFalse(); (current1 != current3).ShouldBeTrue(); (current3 != current1).ShouldBeTrue(); }
public void OpDivision() { var current1 = new ElectricCurrent(2000, ElectricCurrentUnit.Ampere); var current2 = new ElectricCurrent(2, ElectricCurrentUnit.KiloAmpere); (current1 / current2).ShouldBeWithinEpsilonOf(1); (current2 / current1).ShouldBeWithinEpsilonOf(1); (current1 / 2).ShouldEqual(new ElectricCurrent(1000, ElectricCurrentUnit.Ampere)); (current2 / 2).ShouldEqual(new ElectricCurrent(1, ElectricCurrentUnit.KiloAmpere)); }
public void OpEquals() { var current1 = new ElectricCurrent(3000, ElectricCurrentUnit.Ampere); var current2 = new ElectricCurrent(3, ElectricCurrentUnit.KiloAmpere); var current3 = new ElectricCurrent(6, ElectricCurrentUnit.KiloAmpere); (current1 == current2).ShouldBeTrue(); (current2 == current1).ShouldBeTrue(); (current1 == current3).ShouldBeFalse(); (current3 == current1).ShouldBeFalse(); current1.Equals(current2) .ShouldBeTrue(); current1.Equals((object)current2) .ShouldBeTrue(); current2.Equals(current1) .ShouldBeTrue(); current2.Equals((object)current1) .ShouldBeTrue(); }
public void Convert_ToInt32_EqualsValueAsSameType() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); }
public void Convert_ToString_EqualsToString() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
/// <inheritdoc cref="ElectricCurrent.FromPicoamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent Picoamperes(this decimal value) => ElectricCurrent.FromPicoamperes(Convert.ToDouble(value));
/// <inheritdoc cref="ElectricCurrent.FromPicoamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent Picoamperes(this double value) => ElectricCurrent.FromPicoamperes(value);
/// <inheritdoc cref="ElectricCurrent.FromNanoamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent?Nanoamperes(this double?value) => ElectricCurrent.FromNanoamperes(value);
/// <inheritdoc cref="ElectricCurrent.FromMilliamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent Milliamperes(this double value) => ElectricCurrent.FromMilliamperes(value);
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Equal(ElectricCurrent.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Equal(ElectricCurrent.Info, Convert.ChangeType(quantity, typeof(QuantityInfo))); }
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Equal(QuantityType.ElectricCurrent, Convert.ChangeType(quantity, typeof(QuantityType))); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricCurrentUnit))); }
public void Convert_ChangeType_SelfType_EqualsSelf() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(ElectricCurrent))); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
/// <inheritdoc cref="ElectricCurrent.FromMicroamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent?Microamperes(this long?value) => ElectricCurrent.FromMicroamperes(value);
/// <inheritdoc cref="ElectricCurrent.FromMicroamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent Microamperes(this float value) => ElectricCurrent.FromMicroamperes(value);
public void GetHashCode_Equals() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Equal(new { ElectricCurrent.Info.Name, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
/// <inheritdoc cref="ElectricCurrent.FromMilliamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent?Milliamperes(this float?value) => ElectricCurrent.FromMilliamperes(value);
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = ElectricCurrent.FromAmperes(value); Assert.Equal(ElectricCurrent.FromAmperes(-value), -quantity); }
/// <inheritdoc cref="ElectricCurrent.FromNanoamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent Nanoamperes(this float value) => ElectricCurrent.FromNanoamperes(value);
/// <inheritdoc cref="ElectricCurrent.FromCentiamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent Centiamperes(this float value) => ElectricCurrent.FromCentiamperes(value);
/// <inheritdoc cref="ElectricCurrent.FromPicoamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent?Picoamperes(this float?value) => ElectricCurrent.FromPicoamperes(value);
/// <inheritdoc cref="ElectricCurrent.FromKiloamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent?Kiloamperes(this int?value) => ElectricCurrent.FromKiloamperes(value);
/// <inheritdoc cref="ElectricCurrent.FromPicoamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent?Picoamperes(this decimal?value) => ElectricCurrent.FromPicoamperes(value == null ? (double?)null : Convert.ToDouble(value.Value));
public void OpSubtraction() { var current1 = new ElectricCurrent(7000, ElectricCurrentUnit.Ampere); var current2 = new ElectricCurrent(1, ElectricCurrentUnit.KiloAmpere); (current1 - current2).ShouldEqual(new ElectricCurrent(6000, ElectricCurrentUnit.Ampere)); (current2 - current1).ShouldEqual(new ElectricCurrent(-6, ElectricCurrentUnit.KiloAmpere)); }
public void OpMultiplicationScaler() { var current = new ElectricCurrent(1, ElectricCurrentUnit.Ampere); var expected = new ElectricCurrent(2, ElectricCurrentUnit.Ampere); (current * 2).ShouldEqual(expected); (2 * current).ShouldEqual(expected); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
public void Convert_ToDateTime_ThrowsInvalidCastException() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity)); }
/// <inheritdoc cref="ElectricCurrent.FromMegaamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent?Megaamperes(this double?value) => ElectricCurrent.FromMegaamperes(value);
/// <inheritdoc cref="ElectricCurrent.FromKiloamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent Kiloamperes(this long value) => ElectricCurrent.FromKiloamperes(value);
public void Convert_ToDecimal_EqualsValueAsSameType() { var quantity = ElectricCurrent.FromAmperes(1.0); Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); }
public void OpLessThan() { var current1 = new ElectricCurrent(3000, ElectricCurrentUnit.Ampere); var current2 = new ElectricCurrent(3, ElectricCurrentUnit.KiloAmpere); var current3 = new ElectricCurrent(6, ElectricCurrentUnit.KiloAmpere); (current1 < current3).ShouldBeTrue(); (current3 < current1).ShouldBeFalse(); (current1 < current2).ShouldBeFalse(); (current2 < current1).ShouldBeFalse(); }
/// <inheritdoc cref="ElectricCurrent.FromMegaamperes(UnitsNet.QuantityValue)" /> public static ElectricCurrent Megaamperes(this long value) => ElectricCurrent.FromMegaamperes(value);