diff --git a/UnitsNet.Tests/QuantityTest.cs b/UnitsNet.Tests/QuantityTest.cs index 94b3e49926..b074f9df99 100644 --- a/UnitsNet.Tests/QuantityTest.cs +++ b/UnitsNet.Tests/QuantityTest.cs @@ -38,7 +38,7 @@ public void TryFrom_GivenNullUnit_ReturnsFalse() Enum? nullUnit = null; Assert.False(Quantity.TryFrom(1, nullUnit, out IQuantity? _)); } - + [Fact] public void TryFrom_GivenUnknownUnitType_ReturnsFalse() { @@ -53,14 +53,6 @@ public void From_GivenValueAndUnit_ReturnsQuantity() Assert.Equal(Pressure.FromMegabars(3), Quantity.From(3, PressureUnit.Megabar)); } - [Fact] - public void FromQuantityInfo_ReturnsQuantityWithBaseUnit() - { - IQuantity quantity = Quantity.FromQuantityInfo(Length.Info, 1); - Assert.Equal(1, quantity.Value); - Assert.Equal(Length.BaseUnit, quantity.Unit); - } - [Fact] public void ByName_GivenLength_ReturnsQuantityInfoForLength() { @@ -143,7 +135,7 @@ public void Parse_WithDefaultCulture_ReturnsQuantity(double value, string format Type targetType = expectedQuantity.QuantityInfo.QuantityType; IQuantity parsedQuantity = Quantity.Parse(targetType, valueAsString); - + Assert.Equal(expectedQuantity, parsedQuantity); } @@ -228,7 +220,7 @@ public void Types_ReturnsKnownQuantityTypes() Assert.Superset(knownQuantities.ToHashSet(), types.ToHashSet()); } - + [Theory] [InlineData(1, 0, 0, 0, 0, 0, 0)] [InlineData(0, 1, 0, 0, 0, 0, 0)] diff --git a/UnitsNet/CustomCode/Quantity.cs b/UnitsNet/CustomCode/Quantity.cs index abc4e309e8..b4098e8cd6 100644 --- a/UnitsNet/CustomCode/Quantity.cs +++ b/UnitsNet/CustomCode/Quantity.cs @@ -17,7 +17,7 @@ public static partial class Quantity /// All quantity information objects, such as and , that are present in the configuration. /// public static IReadOnlyList Infos => Quantities.Infos; - + /// /// All QuantityInfo instances mapped by quantity name that are present in the configuration. /// @@ -35,7 +35,7 @@ public static bool TryGetUnitInfo(UnitKey unitEnum, [NotNullWhen(true)] out Unit { return Quantities.TryGetUnitInfo(unitEnum, out unitInfo); } - + /// /// Dynamically constructs a quantity from a numeric value and a unit enum value. /// @@ -66,25 +66,6 @@ public static IQuantity From(double value, string quantityName, string unitName) return Quantities.GetUnitByName(quantityName, unitName).From(value); } - /// - /// Dynamically constructs a quantity of the given with the value in the quantity's base - /// units. - /// - /// The of the quantity to create. - /// The value to construct the quantity with. - /// The created quantity. - /// - /// This is the equivalent to: - /// quantityInfo.From(value, quantityInfo.BaseUnitInfo.Value) - /// or - /// quantityInfo.BaseUnitInfo.From(value) - /// - [Obsolete("Consider using: quantityInfo.BaseUnitInfo.From(value)")] - public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, double value) - { - return quantityInfo.BaseUnitInfo.From(value); - } - /// /// Dynamically construct a quantity from a numeric value and a unit abbreviation using . ///