public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { var quantity00 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.CentimeterToTheSixth); AssertEx.EqualTolerance(1, quantity00.CentimetersToTheSixth, CentimetersToTheSixthTolerance); Assert.Equal(WarpingMomentOfInertiaUnit.CentimeterToTheSixth, quantity00.Unit); var quantity01 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.DecimeterToTheSixth); AssertEx.EqualTolerance(1, quantity01.DecimetersToTheSixth, DecimetersToTheSixthTolerance); Assert.Equal(WarpingMomentOfInertiaUnit.DecimeterToTheSixth, quantity01.Unit); var quantity02 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.FootToTheSixth); AssertEx.EqualTolerance(1, quantity02.FeetToTheSixth, FeetToTheSixthTolerance); Assert.Equal(WarpingMomentOfInertiaUnit.FootToTheSixth, quantity02.Unit); var quantity03 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.InchToTheSixth); AssertEx.EqualTolerance(1, quantity03.InchesToTheSixth, InchesToTheSixthTolerance); Assert.Equal(WarpingMomentOfInertiaUnit.InchToTheSixth, quantity03.Unit); var quantity04 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.MeterToTheSixth); AssertEx.EqualTolerance(1, quantity04.MetersToTheSixth, MetersToTheSixthTolerance); Assert.Equal(WarpingMomentOfInertiaUnit.MeterToTheSixth, quantity04.Unit); var quantity05 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.MillimeterToTheSixth); AssertEx.EqualTolerance(1, quantity05.MillimetersToTheSixth, MillimetersToTheSixthTolerance); Assert.Equal(WarpingMomentOfInertiaUnit.MillimeterToTheSixth, quantity05.Unit); }
public void ToUnit(WarpingMomentOfInertiaUnit unit) { var inBaseUnits = WarpingMomentOfInertia.From(1.0, WarpingMomentOfInertia.BaseUnit); var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); }
public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(WarpingMomentOfInertiaUnit unit) { // See if there is a unit available that is not the base unit. var fromUnit = WarpingMomentOfInertia.Units.FirstOrDefault(u => u != WarpingMomentOfInertia.BaseUnit && u != WarpingMomentOfInertiaUnit.Undefined); // If there is only one unit for the quantity, we must use the base unit. if (fromUnit == WarpingMomentOfInertiaUnit.Undefined) fromUnit = WarpingMomentOfInertia.BaseUnit; var quantity = WarpingMomentOfInertia.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); Assert.Equal(converted.Unit, unit); }
public void ToUnit_WithSameUnits_AreEqual(WarpingMomentOfInertiaUnit unit) { var quantity = WarpingMomentOfInertia.From(3.0, unit); var toUnitWithSameUnit = quantity.ToUnit(unit); Assert.Equal(quantity, toUnitWithSameUnit); }