diff --git a/Common/UnitDefinitions/AreaDensity.json b/Common/UnitDefinitions/AreaDensity.json index 4e66410de6..f8aac24b4b 100644 --- a/Common/UnitDefinitions/AreaDensity.json +++ b/Common/UnitDefinitions/AreaDensity.json @@ -56,6 +56,38 @@ "Abbreviations": [ "mg/m²" ] } ] + }, + { + "SingularName": "PoundPerSquareFoot", + "PluralName": "PoundPerSquareFoot", + "BaseUnits": { + "L": "Foot", + "M": "Pound" + }, + "FromUnitToBaseFunc": "{x} * 0.45359237 / 0.092903", + "FromBaseToUnitFunc": "{x} / (0.45359237 / 0.092903)", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "lbs/ft²", "lbs/SF" ] + } + ] + }, + { + "SingularName": "PoundPerThousandSquareFeet", + "PluralName": "PoundPerThousandSquareFeet", + "BaseUnits": { + "L": "Foot", + "M": "Pound" + }, + "FromUnitToBaseFunc": "{x} * (0.45359237 / 0.092903) / 1000", + "FromBaseToUnitFunc": "{x} / (0.45359237 / 0.092903) * 1000", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "lbs/MSF" ] + } + ] } ] } diff --git a/Common/UnitEnumValues.g.json b/Common/UnitEnumValues.g.json index 3ebdc3d87d..a7d6f6ff94 100644 --- a/Common/UnitEnumValues.g.json +++ b/Common/UnitEnumValues.g.json @@ -86,7 +86,9 @@ "AreaDensity": { "KilogramPerSquareMeter": 1, "GramPerSquareMeter": 6, - "MilligramPerSquareMeter": 10 + "MilligramPerSquareMeter": 10, + "PoundPerThousandSquareFeet": 3, + "PoundPerSquareFoot": 8 }, "AreaMomentOfInertia": { "CentimeterToTheFourth": 1, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs index 5ba01d91a1..4a57d1e4d9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs @@ -93,6 +93,16 @@ public AreaDensity(double value, AreaDensityUnit unit) /// public double MilligramsPerSquareMeter => As(AreaDensityUnit.MilligramPerSquareMeter); + /// + /// Gets a value of this quantity converted into + /// + public double PoundPerSquareFoot => As(AreaDensityUnit.PoundPerSquareFoot); + + /// + /// Gets a value of this quantity converted into + /// + public double PoundPerThousandSquareFeet => As(AreaDensityUnit.PoundPerThousandSquareFeet); + #endregion #region Static Factory Methods @@ -112,6 +122,16 @@ public AreaDensity(double value, AreaDensityUnit unit) /// public static AreaDensity FromMilligramsPerSquareMeter(double milligramspersquaremeter) => new AreaDensity(milligramspersquaremeter, AreaDensityUnit.MilligramPerSquareMeter); + /// + /// Creates a from . + /// + public static AreaDensity FromPoundPerSquareFoot(double poundpersquarefoot) => new AreaDensity(poundpersquarefoot, AreaDensityUnit.PoundPerSquareFoot); + + /// + /// Creates a from . + /// + public static AreaDensity FromPoundPerThousandSquareFeet(double poundperthousandsquarefeet) => new AreaDensity(poundperthousandsquarefeet, AreaDensityUnit.PoundPerThousandSquareFeet); + /// /// Dynamically convert from value and unit enum to . /// @@ -155,6 +175,8 @@ private double GetValueInBaseUnit() AreaDensityUnit.GramPerSquareMeter => _value / 1000, AreaDensityUnit.KilogramPerSquareMeter => _value, AreaDensityUnit.MilligramPerSquareMeter => _value / 1000000, + AreaDensityUnit.PoundPerSquareFoot => _value * 4.8824, + AreaDensityUnit.PoundPerThousandSquareFeet => _value * 4.8824 / 1000, _ => throw new NotImplementedException($"Can't convert {Unit} to base units.") }; } @@ -171,6 +193,8 @@ private double GetValueAs(AreaDensityUnit unit) AreaDensityUnit.GramPerSquareMeter => baseUnitValue * 1000, AreaDensityUnit.KilogramPerSquareMeter => baseUnitValue, AreaDensityUnit.MilligramPerSquareMeter => baseUnitValue * 1000000, + AreaDensityUnit.PoundPerSquareFoot => baseUnitValue / 4.8824, + AreaDensityUnit.PoundPerThousandSquareFeet => baseUnitValue / 4.8824 * 1000, _ => throw new NotImplementedException($"Can't convert {Unit} to {unit}.") }; } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/AreaDensityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/AreaDensityUnit.g.cs index bacdc7e8f4..06c176003f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/AreaDensityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/AreaDensityUnit.g.cs @@ -33,6 +33,8 @@ public enum AreaDensityUnit GramPerSquareMeter = 6, KilogramPerSquareMeter = 1, MilligramPerSquareMeter = 10, + PoundPerSquareFoot = 8, + PoundPerThousandSquareFeet = 3, } #pragma warning restore 1591 diff --git a/UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs index 5c8fb6a388..158f3dfb23 100644 --- a/UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs @@ -36,5 +36,13 @@ public void NumberToKilogramsPerSquareMeterTest() => public void NumberToMilligramsPerSquareMeterTest() => Assert.Equal(AreaDensity.FromMilligramsPerSquareMeter(2), 2.MilligramsPerSquareMeter); + [Fact] + public void NumberToPoundPerSquareFootTest() => + Assert.Equal(AreaDensity.FromPoundPerSquareFoot(2), 2.PoundPerSquareFoot); + + [Fact] + public void NumberToPoundPerThousandSquareFeetTest() => + Assert.Equal(AreaDensity.FromPoundPerThousandSquareFeet(2), 2.PoundPerThousandSquareFeet); + } } diff --git a/UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToAreaDensityExtensions.g.cs b/UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToAreaDensityExtensions.g.cs index 76d03f1fc8..2f868788ef 100644 --- a/UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToAreaDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToAreaDensityExtensions.g.cs @@ -66,6 +66,22 @@ public AreaDensity MilligramsPerSquareMeter => AreaDensity.FromMilligramsPerSquareMeter(value.ToDouble(null)); #endif + /// + public AreaDensity PoundPerSquareFoot +#if NET7_0_OR_GREATER + => AreaDensity.FromPoundPerSquareFoot(double.CreateChecked(value)); +#else + => AreaDensity.FromPoundPerSquareFoot(value.ToDouble(null)); +#endif + + /// + public AreaDensity PoundPerThousandSquareFeet +#if NET7_0_OR_GREATER + => AreaDensity.FromPoundPerThousandSquareFeet(double.CreateChecked(value)); +#else + => AreaDensity.FromPoundPerThousandSquareFeet(value.ToDouble(null)); +#endif + } } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs index fa46181b00..ef2c0860b9 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs @@ -36,5 +36,13 @@ public void NumberToKilogramsPerSquareMeterTest() => public void NumberToMilligramsPerSquareMeterTest() => Assert.Equal(AreaDensity.FromMilligramsPerSquareMeter(2), 2.MilligramsPerSquareMeter()); + [Fact] + public void NumberToPoundPerSquareFootTest() => + Assert.Equal(AreaDensity.FromPoundPerSquareFoot(2), 2.PoundPerSquareFoot()); + + [Fact] + public void NumberToPoundPerThousandSquareFeetTest() => + Assert.Equal(AreaDensity.FromPoundPerThousandSquareFeet(2), 2.PoundPerThousandSquareFeet()); + } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs index 0ce7edeee7..14051bd61b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs @@ -65,5 +65,27 @@ public static AreaDensity MilligramsPerSquareMeter(this T value) => AreaDensity.FromMilligramsPerSquareMeter(value.ToDouble(null)); #endif + /// + public static AreaDensity PoundPerSquareFoot(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber + => AreaDensity.FromPoundPerSquareFoot(double.CreateChecked(value)); +#else + , IConvertible + => AreaDensity.FromPoundPerSquareFoot(value.ToDouble(null)); +#endif + + /// + public static AreaDensity PoundPerThousandSquareFeet(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber + => AreaDensity.FromPoundPerThousandSquareFeet(double.CreateChecked(value)); +#else + , IConvertible + => AreaDensity.FromPoundPerThousandSquareFeet(value.ToDouble(null)); +#endif + } } diff --git a/UnitsNet.Tests/CustomCode/AreaDensityTests.cs b/UnitsNet.Tests/CustomCode/AreaDensityTests.cs index f9a113d705..964d45f0cb 100644 --- a/UnitsNet.Tests/CustomCode/AreaDensityTests.cs +++ b/UnitsNet.Tests/CustomCode/AreaDensityTests.cs @@ -34,6 +34,10 @@ public class AreaDensityTests : AreaDensityTestsBase protected override double MilligramsPerSquareMeterInOneKilogramPerSquareMeter => 1000000; + protected override double PoundPerSquareFootInOneKilogramPerSquareMeter => 1 / 4.8824; + + protected override double PoundPerThousandSquareFeetInOneKilogramPerSquareMeter => 1000 / 4.8824; + [Fact] public void AreaDensityTimesAreaEqualsMass() { diff --git a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs index 9dfabd182a..cbac582132 100644 --- a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs +++ b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs @@ -40,7 +40,7 @@ void Assertion(int expectedValue, Enum expectedUnit, IQuantity quantity) Assertion(3, AmplitudeRatioUnit.DecibelVolt, Quantity.From(3, AmplitudeRatioUnit.DecibelVolt)); Assertion(3, AngleUnit.Revolution, Quantity.From(3, AngleUnit.Revolution)); Assertion(3, AreaUnit.UsSurveySquareFoot, Quantity.From(3, AreaUnit.UsSurveySquareFoot)); - Assertion(3, AreaDensityUnit.MilligramPerSquareMeter, Quantity.From(3, AreaDensityUnit.MilligramPerSquareMeter)); + Assertion(3, AreaDensityUnit.PoundPerThousandSquareFeet, Quantity.From(3, AreaDensityUnit.PoundPerThousandSquareFeet)); Assertion(3, AreaMomentOfInertiaUnit.MillimeterToTheFourth, Quantity.From(3, AreaMomentOfInertiaUnit.MillimeterToTheFourth)); Assertion(3, BitRateUnit.TeraoctetPerSecond, Quantity.From(3, BitRateUnit.TeraoctetPerSecond)); Assertion(3, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, Quantity.From(3, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour)); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 9389bf8362..2cfbdf08d1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -43,11 +43,15 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase protected abstract double GramsPerSquareMeterInOneKilogramPerSquareMeter { get; } protected abstract double KilogramsPerSquareMeterInOneKilogramPerSquareMeter { get; } protected abstract double MilligramsPerSquareMeterInOneKilogramPerSquareMeter { get; } + protected abstract double PoundPerSquareFootInOneKilogramPerSquareMeter { get; } + protected abstract double PoundPerThousandSquareFeetInOneKilogramPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global protected virtual double GramsPerSquareMeterTolerance { get { return 1e-5; } } protected virtual double KilogramsPerSquareMeterTolerance { get { return 1e-5; } } protected virtual double MilligramsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double PoundPerSquareFootTolerance { get { return 1e-5; } } + protected virtual double PoundPerThousandSquareFeetTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AreaDensityUnit unit) @@ -57,6 +61,8 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase AreaDensityUnit.GramPerSquareMeter => (GramsPerSquareMeterInOneKilogramPerSquareMeter, GramsPerSquareMeterTolerance), AreaDensityUnit.KilogramPerSquareMeter => (KilogramsPerSquareMeterInOneKilogramPerSquareMeter, KilogramsPerSquareMeterTolerance), AreaDensityUnit.MilligramPerSquareMeter => (MilligramsPerSquareMeterInOneKilogramPerSquareMeter, MilligramsPerSquareMeterTolerance), + AreaDensityUnit.PoundPerSquareFoot => (PoundPerSquareFootInOneKilogramPerSquareMeter, PoundPerSquareFootTolerance), + AreaDensityUnit.PoundPerThousandSquareFeet => (PoundPerThousandSquareFeetInOneKilogramPerSquareMeter, PoundPerThousandSquareFeetTolerance), _ => throw new NotSupportedException() }; } @@ -66,6 +72,8 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase new object[] { AreaDensityUnit.GramPerSquareMeter }, new object[] { AreaDensityUnit.KilogramPerSquareMeter }, new object[] { AreaDensityUnit.MilligramPerSquareMeter }, + new object[] { AreaDensityUnit.PoundPerSquareFoot }, + new object[] { AreaDensityUnit.PoundPerThousandSquareFeet }, }; [Fact] @@ -140,6 +148,8 @@ public void KilogramPerSquareMeterToAreaDensityUnits() AssertEx.EqualTolerance(GramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.GramsPerSquareMeter, GramsPerSquareMeterTolerance); AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); AssertEx.EqualTolerance(MilligramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.MilligramsPerSquareMeter, MilligramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(PoundPerSquareFootInOneKilogramPerSquareMeter, kilogrampersquaremeter.PoundPerSquareFoot, PoundPerSquareFootTolerance); + AssertEx.EqualTolerance(PoundPerThousandSquareFeetInOneKilogramPerSquareMeter, kilogrampersquaremeter.PoundPerThousandSquareFeet, PoundPerThousandSquareFeetTolerance); } [Fact] @@ -178,6 +188,8 @@ public void As() AssertEx.EqualTolerance(GramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.GramPerSquareMeter), GramsPerSquareMeterTolerance); AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.KilogramPerSquareMeter), KilogramsPerSquareMeterTolerance); AssertEx.EqualTolerance(MilligramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.MilligramPerSquareMeter), MilligramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(PoundPerSquareFootInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.PoundPerSquareFoot), PoundPerSquareFootTolerance); + AssertEx.EqualTolerance(PoundPerThousandSquareFeetInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.PoundPerThousandSquareFeet), PoundPerThousandSquareFeetTolerance); } [Fact] @@ -248,6 +260,9 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() [InlineData("en-US", "4.2 gsm", AreaDensityUnit.GramPerSquareMeter, 4.2)] [InlineData("en-US", "4.2 kg/m²", AreaDensityUnit.KilogramPerSquareMeter, 4.2)] [InlineData("en-US", "4.2 mg/m²", AreaDensityUnit.MilligramPerSquareMeter, 4.2)] + [InlineData("en-US", "4.2 lbs/ft²", AreaDensityUnit.PoundPerSquareFoot, 4.2)] + [InlineData("en-US", "4.2 lbs/SF", AreaDensityUnit.PoundPerSquareFoot, 4.2)] + [InlineData("en-US", "4.2 lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet, 4.2)] public void Parse(string culture, string quantityString, AreaDensityUnit expectedUnit, double expectedValue) { using var _ = new CultureScope(culture); @@ -261,6 +276,9 @@ public void Parse(string culture, string quantityString, AreaDensityUnit expecte [InlineData("en-US", "4.2 gsm", AreaDensityUnit.GramPerSquareMeter, 4.2)] [InlineData("en-US", "4.2 kg/m²", AreaDensityUnit.KilogramPerSquareMeter, 4.2)] [InlineData("en-US", "4.2 mg/m²", AreaDensityUnit.MilligramPerSquareMeter, 4.2)] + [InlineData("en-US", "4.2 lbs/ft²", AreaDensityUnit.PoundPerSquareFoot, 4.2)] + [InlineData("en-US", "4.2 lbs/SF", AreaDensityUnit.PoundPerSquareFoot, 4.2)] + [InlineData("en-US", "4.2 lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet, 4.2)] public void TryParse(string culture, string quantityString, AreaDensityUnit expectedUnit, double expectedValue) { using var _ = new CultureScope(culture); @@ -274,6 +292,9 @@ public void TryParse(string culture, string quantityString, AreaDensityUnit expe [InlineData("gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void ParseUnit_WithUsEnglishCurrentCulture(string abbreviation, AreaDensityUnit expectedUnit) { // Fallback culture "en-US" is always localized @@ -287,6 +308,9 @@ public void ParseUnit_WithUsEnglishCurrentCulture(string abbreviation, AreaDensi [InlineData("gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void ParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(string abbreviation, AreaDensityUnit expectedUnit) { // Currently, no abbreviations are localized for Icelandic, so it should fall back to "en-US" when parsing. @@ -300,6 +324,9 @@ public void ParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(string [InlineData("en-US", "gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("en-US", "kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("en-US", "mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("en-US", "lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void ParseUnit_WithCurrentCulture(string culture, string abbreviation, AreaDensityUnit expectedUnit) { using var _ = new CultureScope(culture); @@ -312,6 +339,9 @@ public void ParseUnit_WithCurrentCulture(string culture, string abbreviation, Ar [InlineData("en-US", "gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("en-US", "kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("en-US", "mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("en-US", "lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void ParseUnit_WithCulture(string culture, string abbreviation, AreaDensityUnit expectedUnit) { AreaDensityUnit parsedUnit = AreaDensity.ParseUnit(abbreviation, CultureInfo.GetCultureInfo(culture)); @@ -323,6 +353,9 @@ public void ParseUnit_WithCulture(string culture, string abbreviation, AreaDensi [InlineData("gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void TryParseUnit_WithUsEnglishCurrentCulture(string abbreviation, AreaDensityUnit expectedUnit) { // Fallback culture "en-US" is always localized @@ -336,6 +369,9 @@ public void TryParseUnit_WithUsEnglishCurrentCulture(string abbreviation, AreaDe [InlineData("gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void TryParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(string abbreviation, AreaDensityUnit expectedUnit) { // Currently, no abbreviations are localized for Icelandic, so it should fall back to "en-US" when parsing. @@ -349,6 +385,9 @@ public void TryParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(stri [InlineData("en-US", "gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("en-US", "kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("en-US", "mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("en-US", "lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void TryParseUnit_WithCurrentCulture(string culture, string abbreviation, AreaDensityUnit expectedUnit) { using var _ = new CultureScope(culture); @@ -361,6 +400,9 @@ public void TryParseUnit_WithCurrentCulture(string culture, string abbreviation, [InlineData("en-US", "gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("en-US", "kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("en-US", "mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("en-US", "lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void TryParseUnit_WithCulture(string culture, string abbreviation, AreaDensityUnit expectedUnit) { Assert.True(AreaDensity.TryParseUnit(abbreviation, CultureInfo.GetCultureInfo(culture), out AreaDensityUnit parsedUnit)); @@ -371,6 +413,8 @@ public void TryParseUnit_WithCulture(string culture, string abbreviation, AreaDe [InlineData("en-US", AreaDensityUnit.GramPerSquareMeter, "g/m²")] [InlineData("en-US", AreaDensityUnit.KilogramPerSquareMeter, "kg/m²")] [InlineData("en-US", AreaDensityUnit.MilligramPerSquareMeter, "mg/m²")] + [InlineData("en-US", AreaDensityUnit.PoundPerSquareFoot, "lbs/ft²")] + [InlineData("en-US", AreaDensityUnit.PoundPerThousandSquareFeet, "lbs/MSF")] public void GetAbbreviationForCulture(string culture, AreaDensityUnit unit, string expectedAbbreviation) { var defaultAbbreviation = AreaDensity.GetAbbreviation(unit, CultureInfo.GetCultureInfo(culture)); @@ -458,6 +502,8 @@ public void ConversionRoundTrip() AssertEx.EqualTolerance(1, AreaDensity.FromGramsPerSquareMeter(kilogrampersquaremeter.GramsPerSquareMeter).KilogramsPerSquareMeter, GramsPerSquareMeterTolerance); AssertEx.EqualTolerance(1, AreaDensity.FromKilogramsPerSquareMeter(kilogrampersquaremeter.KilogramsPerSquareMeter).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); AssertEx.EqualTolerance(1, AreaDensity.FromMilligramsPerSquareMeter(kilogrampersquaremeter.MilligramsPerSquareMeter).KilogramsPerSquareMeter, MilligramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, AreaDensity.FromPoundPerSquareFoot(kilogrampersquaremeter.PoundPerSquareFoot).KilogramsPerSquareMeter, PoundPerSquareFootTolerance); + AssertEx.EqualTolerance(1, AreaDensity.FromPoundPerThousandSquareFeet(kilogrampersquaremeter.PoundPerThousandSquareFeet).KilogramsPerSquareMeter, PoundPerThousandSquareFeetTolerance); } [Fact] @@ -617,6 +663,8 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() Assert.Equal("1 g/m²", new AreaDensity(1, AreaDensityUnit.GramPerSquareMeter).ToString()); Assert.Equal("1 kg/m²", new AreaDensity(1, AreaDensityUnit.KilogramPerSquareMeter).ToString()); Assert.Equal("1 mg/m²", new AreaDensity(1, AreaDensityUnit.MilligramPerSquareMeter).ToString()); + Assert.Equal("1 lbs/ft²", new AreaDensity(1, AreaDensityUnit.PoundPerSquareFoot).ToString()); + Assert.Equal("1 lbs/MSF", new AreaDensity(1, AreaDensityUnit.PoundPerThousandSquareFeet).ToString()); } [Fact] @@ -628,6 +676,8 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture Assert.Equal("1 g/m²", new AreaDensity(1, AreaDensityUnit.GramPerSquareMeter).ToString(swedishCulture)); Assert.Equal("1 kg/m²", new AreaDensity(1, AreaDensityUnit.KilogramPerSquareMeter).ToString(swedishCulture)); Assert.Equal("1 mg/m²", new AreaDensity(1, AreaDensityUnit.MilligramPerSquareMeter).ToString(swedishCulture)); + Assert.Equal("1 lbs/ft²", new AreaDensity(1, AreaDensityUnit.PoundPerSquareFoot).ToString(swedishCulture)); + Assert.Equal("1 lbs/MSF", new AreaDensity(1, AreaDensityUnit.PoundPerThousandSquareFeet).ToString(swedishCulture)); } [Fact] diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 2b662909c4..7c75006534 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -121,6 +121,8 @@ public static IEnumerable> GetDefaultMappings() yield return new (AreaDensityUnit.GramPerSquareMeter, "GramPerSquareMeter", "GramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Gram)); yield return new (AreaDensityUnit.KilogramPerSquareMeter, "KilogramPerSquareMeter", "KilogramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram)); yield return new (AreaDensityUnit.MilligramPerSquareMeter, "MilligramPerSquareMeter", "MilligramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Milligram)); + yield return new (AreaDensityUnit.PoundPerSquareFoot, "PoundPerSquareFoot", "PoundPerSquareFoot", new BaseUnits(length: LengthUnit.Foot, mass: MassUnit.Pound)); + yield return new (AreaDensityUnit.PoundPerThousandSquareFeet, "PoundPerThousandSquareFeet", "PoundPerThousandSquareFeet", new BaseUnits(length: LengthUnit.Foot, mass: MassUnit.Pound)); } } @@ -241,6 +243,16 @@ public AreaDensity(double value, UnitSystem unitSystem) /// public double MilligramsPerSquareMeter => As(AreaDensityUnit.MilligramPerSquareMeter); + /// + /// Gets a value of this quantity converted into + /// + public double PoundPerSquareFoot => As(AreaDensityUnit.PoundPerSquareFoot); + + /// + /// Gets a value of this quantity converted into + /// + public double PoundPerThousandSquareFeet => As(AreaDensityUnit.PoundPerThousandSquareFeet); + #endregion #region Static Methods @@ -254,6 +266,8 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: AreaDensityUnit -> BaseUnit unitConverter.SetConversionFunction(AreaDensityUnit.GramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter, quantity => quantity.ToUnit(AreaDensityUnit.KilogramPerSquareMeter)); unitConverter.SetConversionFunction(AreaDensityUnit.MilligramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter, quantity => quantity.ToUnit(AreaDensityUnit.KilogramPerSquareMeter)); + unitConverter.SetConversionFunction(AreaDensityUnit.PoundPerSquareFoot, AreaDensityUnit.KilogramPerSquareMeter, quantity => quantity.ToUnit(AreaDensityUnit.KilogramPerSquareMeter)); + unitConverter.SetConversionFunction(AreaDensityUnit.PoundPerThousandSquareFeet, AreaDensityUnit.KilogramPerSquareMeter, quantity => quantity.ToUnit(AreaDensityUnit.KilogramPerSquareMeter)); // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter, quantity => quantity); @@ -261,6 +275,8 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> AreaDensityUnit unitConverter.SetConversionFunction(AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.GramPerSquareMeter, quantity => quantity.ToUnit(AreaDensityUnit.GramPerSquareMeter)); unitConverter.SetConversionFunction(AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.MilligramPerSquareMeter, quantity => quantity.ToUnit(AreaDensityUnit.MilligramPerSquareMeter)); + unitConverter.SetConversionFunction(AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.PoundPerSquareFoot, quantity => quantity.ToUnit(AreaDensityUnit.PoundPerSquareFoot)); + unitConverter.SetConversionFunction(AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.PoundPerThousandSquareFeet, quantity => quantity.ToUnit(AreaDensityUnit.PoundPerThousandSquareFeet)); } /// @@ -312,6 +328,22 @@ public static AreaDensity FromMilligramsPerSquareMeter(double value) return new AreaDensity(value, AreaDensityUnit.MilligramPerSquareMeter); } + /// + /// Creates a from . + /// + public static AreaDensity FromPoundPerSquareFoot(double value) + { + return new AreaDensity(value, AreaDensityUnit.PoundPerSquareFoot); + } + + /// + /// Creates a from . + /// + public static AreaDensity FromPoundPerThousandSquareFeet(double value) + { + return new AreaDensity(value, AreaDensityUnit.PoundPerThousandSquareFeet); + } + /// /// Dynamically convert from value and unit enum to . /// @@ -717,10 +749,14 @@ private bool TryToUnit(AreaDensityUnit unit, [NotNullWhen(true)] out AreaDensity // AreaDensityUnit -> BaseUnit (AreaDensityUnit.GramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value / 1000, AreaDensityUnit.KilogramPerSquareMeter), (AreaDensityUnit.MilligramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value / 1000000, AreaDensityUnit.KilogramPerSquareMeter), + (AreaDensityUnit.PoundPerSquareFoot, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value * 4.8824, AreaDensityUnit.KilogramPerSquareMeter), + (AreaDensityUnit.PoundPerThousandSquareFeet, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value * 4.8824 / 1000, AreaDensityUnit.KilogramPerSquareMeter), // BaseUnit -> AreaDensityUnit (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.GramPerSquareMeter) => new AreaDensity(_value * 1000, AreaDensityUnit.GramPerSquareMeter), (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.MilligramPerSquareMeter) => new AreaDensity(_value * 1000000, AreaDensityUnit.MilligramPerSquareMeter), + (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.PoundPerSquareFoot) => new AreaDensity(_value / 4.8824, AreaDensityUnit.PoundPerSquareFoot), + (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.PoundPerThousandSquareFeet) => new AreaDensity(_value / 4.8824 * 1000, AreaDensityUnit.PoundPerThousandSquareFeet), _ => null }; diff --git a/UnitsNet/GeneratedCode/Resources/AreaDensity.restext b/UnitsNet/GeneratedCode/Resources/AreaDensity.restext index 6a33618aa9..f49fd52017 100644 --- a/UnitsNet/GeneratedCode/Resources/AreaDensity.restext +++ b/UnitsNet/GeneratedCode/Resources/AreaDensity.restext @@ -1,3 +1,5 @@ GramsPerSquareMeter=g/m²,gsm KilogramsPerSquareMeter=kg/m² MilligramsPerSquareMeter=mg/m² +PoundPerSquareFoot=lbs/ft²,lbs/SF +PoundPerThousandSquareFeet=lbs/MSF diff --git a/UnitsNet/GeneratedCode/Units/AreaDensityUnit.g.cs b/UnitsNet/GeneratedCode/Units/AreaDensityUnit.g.cs index bacdc7e8f4..06c176003f 100644 --- a/UnitsNet/GeneratedCode/Units/AreaDensityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/AreaDensityUnit.g.cs @@ -33,6 +33,8 @@ public enum AreaDensityUnit GramPerSquareMeter = 6, KilogramPerSquareMeter = 1, MilligramPerSquareMeter = 10, + PoundPerSquareFoot = 8, + PoundPerThousandSquareFeet = 3, } #pragma warning restore 1591