diff --git a/Common/UnitDefinitions/Volume.json b/Common/UnitDefinitions/Volume.json
index 60734a1b7d..b744737e5d 100644
--- a/Common/UnitDefinitions/Volume.json
+++ b/Common/UnitDefinitions/Volume.json
@@ -347,6 +347,20 @@
}
]
},
+ {
+ "SingularName": "MetricTablespoon",
+ "PluralName": "MetricTablespoons",
+ "XmlDocSummary": "An international metric tablespoon is exactly equal to 15 mL. It is the equivalence of 1 1/2 metric dessert spoons or 3 metric teaspoons.",
+ "XmlDocRemarks": "https://en.wikipedia.org/wiki/Tablespoon#International_metric",
+ "FromUnitToBaseFunc": "{x} * 1.5e-5",
+ "FromBaseToUnitFunc": "{x} / 1.5e-5",
+ "Localization": [
+ {
+ "Culture": "en-US",
+ "Abbreviations": [ "tablespoon", "tbsp", "tbsp.", "tblsp", "tblsp." ]
+ }
+ ]
+ },
{
"SingularName": "UkTablespoon",
"PluralName": "UkTablespoons",
@@ -413,7 +427,7 @@
"Localization": [
{
"Culture": "en-US",
- "Abbreviations": ["cup (U.S. customary)"]
+ "Abbreviations": [ "cup (U.S. customary)" ]
}
]
},
@@ -427,7 +441,7 @@
"Localization": [
{
"Culture": "en-US",
- "Abbreviations": ["cup (U.S.)"]
+ "Abbreviations": [ "cup (U.S.)" ]
}
]
},
diff --git a/Common/UnitEnumValues.g.json b/Common/UnitEnumValues.g.json
index f48526d14b..1df92d739e 100644
--- a/Common/UnitEnumValues.g.json
+++ b/Common/UnitEnumValues.g.json
@@ -1600,7 +1600,8 @@
"UsTablespoon": 51,
"UsTeaspoon": 52,
"Nanoliter": 53,
- "ImperialQuart": 57
+ "ImperialQuart": 57,
+ "MetricTablespoon": 63
},
"VolumeConcentration": {
"CentiliterPerLiter": 1,
diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs
index 6e9b5ee16c..11217d2cf9 100644
--- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs
+++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs
@@ -273,6 +273,11 @@ public Volume(double value, VolumeUnit unit)
///
public double MetricCups => As(VolumeUnit.MetricCup);
+ ///
+ /// Gets a value of this quantity converted into
+ ///
+ public double MetricTablespoons => As(VolumeUnit.MetricTablespoon);
+
///
/// Gets a value of this quantity converted into
///
@@ -547,6 +552,11 @@ public Volume(double value, VolumeUnit unit)
///
public static Volume FromMetricCups(double metriccups) => new Volume(metriccups, VolumeUnit.MetricCup);
+ ///
+ /// Creates a from .
+ ///
+ public static Volume FromMetricTablespoons(double metrictablespoons) => new Volume(metrictablespoons, VolumeUnit.MetricTablespoon);
+
///
/// Creates a from .
///
@@ -701,6 +711,7 @@ private double GetValueInBaseUnit()
VolumeUnit.Megaliter => (_value / 1e3) * 1e6d,
VolumeUnit.MegausGallon => (_value * 0.003785411784) * 1e6d,
VolumeUnit.MetricCup => _value * 0.00025,
+ VolumeUnit.MetricTablespoon => _value * 1.5e-5,
VolumeUnit.MetricTeaspoon => _value * 0.5e-5,
VolumeUnit.Microliter => (_value / 1e3) * 1e-6d,
VolumeUnit.Milliliter => (_value / 1e3) * 1e-3d,
@@ -768,6 +779,7 @@ private double GetValueAs(VolumeUnit unit)
VolumeUnit.Megaliter => (baseUnitValue * 1e3) / 1e6d,
VolumeUnit.MegausGallon => (baseUnitValue / 0.003785411784) / 1e6d,
VolumeUnit.MetricCup => baseUnitValue / 0.00025,
+ VolumeUnit.MetricTablespoon => baseUnitValue / 1.5e-5,
VolumeUnit.MetricTeaspoon => baseUnitValue / 0.5e-5,
VolumeUnit.Microliter => (baseUnitValue * 1e3) / 1e-6d,
VolumeUnit.Milliliter => (baseUnitValue * 1e3) / 1e-3d,
diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeUnit.g.cs
index 84dbccfb05..1a8767f7db 100644
--- a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeUnit.g.cs
+++ b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeUnit.g.cs
@@ -130,6 +130,12 @@ public enum VolumeUnit
/// https://en.wikipedia.org/wiki/Cup_(unit)#Metric_cup
MetricCup = 38,
+ ///
+ /// An international metric tablespoon is exactly equal to 15 mL. It is the equivalence of 1 1/2 metric dessert spoons or metric teaspoons
+ ///
+ /// https://en.wikipedia.org/wiki/Tablespoon#International_metric
+ MetricTablespoon = 63,
+
///
/// The metric teaspoon as a unit of culinary measure is 5 ml (0.18 imp fl oz; 0.17 US fl oz),[17] equal to 5 cm3, 1⁄3 UK/Canadian metric tablespoon, or 1⁄4 Australian metric tablespoon.
///
diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeExtensionsTest.g.cs
index b8450bdd38..7a047c5df7 100644
--- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeExtensionsTest.g.cs
+++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeExtensionsTest.g.cs
@@ -180,6 +180,10 @@ public void NumberToMegausGallonsTest() =>
public void NumberToMetricCupsTest() =>
Assert.Equal(Volume.FromMetricCups(2), 2.MetricCups());
+ [Fact]
+ public void NumberToMetricTablespoonsTest() =>
+ Assert.Equal(Volume.FromMetricTablespoons(2), 2.MetricTablespoons());
+
[Fact]
public void NumberToMetricTeaspoonsTest() =>
Assert.Equal(Volume.FromMetricTeaspoons(2), 2.MetricTeaspoons());
diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeExtensions.g.cs
index d425a5ed28..82828124f6 100644
--- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeExtensions.g.cs
+++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeExtensions.g.cs
@@ -461,6 +461,17 @@ public static Volume MetricCups(this T value)
=> Volume.FromMetricCups(value.ToDouble(null));
#endif
+ ///
+ public static Volume MetricTablespoons(this T value)
+ where T : notnull
+#if NET7_0_OR_GREATER
+ , INumber
+ => Volume.FromMetricTablespoons(double.CreateChecked(value));
+#else
+ , IConvertible
+ => Volume.FromMetricTablespoons(value.ToDouble(null));
+#endif
+
///
public static Volume MetricTeaspoons(this T value)
where T : notnull
diff --git a/UnitsNet.Tests/CustomCode/VolumeTests.cs b/UnitsNet.Tests/CustomCode/VolumeTests.cs
index 857958df8e..0df729bde5 100644
--- a/UnitsNet.Tests/CustomCode/VolumeTests.cs
+++ b/UnitsNet.Tests/CustomCode/VolumeTests.cs
@@ -78,6 +78,8 @@ public class VolumeTests : VolumeTestsBase
protected override double UkTablespoonsInOneCubicMeter => 66666.6666667;
+ protected override double MetricTablespoonsInOneCubicMeter => 66666.6666667;
+
protected override double UsBeerBarrelsInOneCubicMeter => 8.5216790723083;
protected override double UsGallonsInOneCubicMeter => 264.17217;
diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs
index 8def0e2cb0..fe48c8f187 100644
--- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs
@@ -79,6 +79,7 @@ public abstract partial class VolumeTestsBase : QuantityTestsBase
protected abstract double MegalitersInOneCubicMeter { get; }
protected abstract double MegausGallonsInOneCubicMeter { get; }
protected abstract double MetricCupsInOneCubicMeter { get; }
+ protected abstract double MetricTablespoonsInOneCubicMeter { get; }
protected abstract double MetricTeaspoonsInOneCubicMeter { get; }
protected abstract double MicrolitersInOneCubicMeter { get; }
protected abstract double MillilitersInOneCubicMeter { get; }
@@ -135,6 +136,7 @@ public abstract partial class VolumeTestsBase : QuantityTestsBase
protected virtual double MegalitersTolerance { get { return 1e-5; } }
protected virtual double MegausGallonsTolerance { get { return 1e-5; } }
protected virtual double MetricCupsTolerance { get { return 1e-5; } }
+ protected virtual double MetricTablespoonsTolerance { get { return 1e-5; } }
protected virtual double MetricTeaspoonsTolerance { get { return 1e-5; } }
protected virtual double MicrolitersTolerance { get { return 1e-5; } }
protected virtual double MillilitersTolerance { get { return 1e-5; } }
@@ -195,6 +197,7 @@ public abstract partial class VolumeTestsBase : QuantityTestsBase
VolumeUnit.Megaliter => (MegalitersInOneCubicMeter, MegalitersTolerance),
VolumeUnit.MegausGallon => (MegausGallonsInOneCubicMeter, MegausGallonsTolerance),
VolumeUnit.MetricCup => (MetricCupsInOneCubicMeter, MetricCupsTolerance),
+ VolumeUnit.MetricTablespoon => (MetricTablespoonsInOneCubicMeter, MetricTablespoonsTolerance),
VolumeUnit.MetricTeaspoon => (MetricTeaspoonsInOneCubicMeter, MetricTeaspoonsTolerance),
VolumeUnit.Microliter => (MicrolitersInOneCubicMeter, MicrolitersTolerance),
VolumeUnit.Milliliter => (MillilitersInOneCubicMeter, MillilitersTolerance),
@@ -255,6 +258,7 @@ public abstract partial class VolumeTestsBase : QuantityTestsBase
new object[] { VolumeUnit.Megaliter },
new object[] { VolumeUnit.MegausGallon },
new object[] { VolumeUnit.MetricCup },
+ new object[] { VolumeUnit.MetricTablespoon },
new object[] { VolumeUnit.MetricTeaspoon },
new object[] { VolumeUnit.Microliter },
new object[] { VolumeUnit.Milliliter },
@@ -380,6 +384,7 @@ public void CubicMeterToVolumeUnits()
AssertEx.EqualTolerance(MegalitersInOneCubicMeter, cubicmeter.Megaliters, MegalitersTolerance);
AssertEx.EqualTolerance(MegausGallonsInOneCubicMeter, cubicmeter.MegausGallons, MegausGallonsTolerance);
AssertEx.EqualTolerance(MetricCupsInOneCubicMeter, cubicmeter.MetricCups, MetricCupsTolerance);
+ AssertEx.EqualTolerance(MetricTablespoonsInOneCubicMeter, cubicmeter.MetricTablespoons, MetricTablespoonsTolerance);
AssertEx.EqualTolerance(MetricTeaspoonsInOneCubicMeter, cubicmeter.MetricTeaspoons, MetricTeaspoonsTolerance);
AssertEx.EqualTolerance(MicrolitersInOneCubicMeter, cubicmeter.Microliters, MicrolitersTolerance);
AssertEx.EqualTolerance(MillilitersInOneCubicMeter, cubicmeter.Milliliters, MillilitersTolerance);
@@ -400,12 +405,226 @@ public void CubicMeterToVolumeUnits()
[Fact]
public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
{
- Assert.All(EnumHelper.GetValues(), unit =>
- {
- var quantity = Volume.From(1, unit);
- Assert.Equal(1, quantity.Value);
- Assert.Equal(unit, quantity.Unit);
- });
+ var quantity00 = Volume.From(1, VolumeUnit.AcreFoot);
+ AssertEx.EqualTolerance(1, quantity00.AcreFeet, AcreFeetTolerance);
+ Assert.Equal(VolumeUnit.AcreFoot, quantity00.Unit);
+
+ var quantity01 = Volume.From(1, VolumeUnit.AuTablespoon);
+ AssertEx.EqualTolerance(1, quantity01.AuTablespoons, AuTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.AuTablespoon, quantity01.Unit);
+
+ var quantity02 = Volume.From(1, VolumeUnit.BoardFoot);
+ AssertEx.EqualTolerance(1, quantity02.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, quantity02.Unit);
+
+ var quantity03 = Volume.From(1, VolumeUnit.Centiliter);
+ AssertEx.EqualTolerance(1, quantity03.Centiliters, CentilitersTolerance);
+ Assert.Equal(VolumeUnit.Centiliter, quantity03.Unit);
+
+ var quantity04 = Volume.From(1, VolumeUnit.CubicCentimeter);
+ AssertEx.EqualTolerance(1, quantity04.CubicCentimeters, CubicCentimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicCentimeter, quantity04.Unit);
+
+ var quantity05 = Volume.From(1, VolumeUnit.CubicDecimeter);
+ AssertEx.EqualTolerance(1, quantity05.CubicDecimeters, CubicDecimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicDecimeter, quantity05.Unit);
+
+ var quantity06 = Volume.From(1, VolumeUnit.CubicFoot);
+ AssertEx.EqualTolerance(1, quantity06.CubicFeet, CubicFeetTolerance);
+ Assert.Equal(VolumeUnit.CubicFoot, quantity06.Unit);
+
+ var quantity07 = Volume.From(1, VolumeUnit.CubicHectometer);
+ AssertEx.EqualTolerance(1, quantity07.CubicHectometers, CubicHectometersTolerance);
+ Assert.Equal(VolumeUnit.CubicHectometer, quantity07.Unit);
+
+ var quantity08 = Volume.From(1, VolumeUnit.CubicInch);
+ AssertEx.EqualTolerance(1, quantity08.CubicInches, CubicInchesTolerance);
+ Assert.Equal(VolumeUnit.CubicInch, quantity08.Unit);
+
+ var quantity09 = Volume.From(1, VolumeUnit.CubicKilometer);
+ AssertEx.EqualTolerance(1, quantity09.CubicKilometers, CubicKilometersTolerance);
+ Assert.Equal(VolumeUnit.CubicKilometer, quantity09.Unit);
+
+ var quantity10 = Volume.From(1, VolumeUnit.CubicMeter);
+ AssertEx.EqualTolerance(1, quantity10.CubicMeters, CubicMetersTolerance);
+ Assert.Equal(VolumeUnit.CubicMeter, quantity10.Unit);
+
+ var quantity11 = Volume.From(1, VolumeUnit.CubicMicrometer);
+ AssertEx.EqualTolerance(1, quantity11.CubicMicrometers, CubicMicrometersTolerance);
+ Assert.Equal(VolumeUnit.CubicMicrometer, quantity11.Unit);
+
+ var quantity12 = Volume.From(1, VolumeUnit.CubicMile);
+ AssertEx.EqualTolerance(1, quantity12.CubicMiles, CubicMilesTolerance);
+ Assert.Equal(VolumeUnit.CubicMile, quantity12.Unit);
+
+ var quantity13 = Volume.From(1, VolumeUnit.CubicMillimeter);
+ AssertEx.EqualTolerance(1, quantity13.CubicMillimeters, CubicMillimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicMillimeter, quantity13.Unit);
+
+ var quantity14 = Volume.From(1, VolumeUnit.CubicYard);
+ AssertEx.EqualTolerance(1, quantity14.CubicYards, CubicYardsTolerance);
+ Assert.Equal(VolumeUnit.CubicYard, quantity14.Unit);
+
+ var quantity15 = Volume.From(1, VolumeUnit.Decaliter);
+ AssertEx.EqualTolerance(1, quantity15.Decaliters, DecalitersTolerance);
+ Assert.Equal(VolumeUnit.Decaliter, quantity15.Unit);
+
+ var quantity16 = Volume.From(1, VolumeUnit.DecausGallon);
+ AssertEx.EqualTolerance(1, quantity16.DecausGallons, DecausGallonsTolerance);
+ Assert.Equal(VolumeUnit.DecausGallon, quantity16.Unit);
+
+ var quantity17 = Volume.From(1, VolumeUnit.Deciliter);
+ AssertEx.EqualTolerance(1, quantity17.Deciliters, DecilitersTolerance);
+ Assert.Equal(VolumeUnit.Deciliter, quantity17.Unit);
+
+ var quantity18 = Volume.From(1, VolumeUnit.DeciusGallon);
+ AssertEx.EqualTolerance(1, quantity18.DeciusGallons, DeciusGallonsTolerance);
+ Assert.Equal(VolumeUnit.DeciusGallon, quantity18.Unit);
+
+ var quantity19 = Volume.From(1, VolumeUnit.HectocubicFoot);
+ AssertEx.EqualTolerance(1, quantity19.HectocubicFeet, HectocubicFeetTolerance);
+ Assert.Equal(VolumeUnit.HectocubicFoot, quantity19.Unit);
+
+ var quantity20 = Volume.From(1, VolumeUnit.HectocubicMeter);
+ AssertEx.EqualTolerance(1, quantity20.HectocubicMeters, HectocubicMetersTolerance);
+ Assert.Equal(VolumeUnit.HectocubicMeter, quantity20.Unit);
+
+ var quantity21 = Volume.From(1, VolumeUnit.Hectoliter);
+ AssertEx.EqualTolerance(1, quantity21.Hectoliters, HectolitersTolerance);
+ Assert.Equal(VolumeUnit.Hectoliter, quantity21.Unit);
+
+ var quantity22 = Volume.From(1, VolumeUnit.HectousGallon);
+ AssertEx.EqualTolerance(1, quantity22.HectousGallons, HectousGallonsTolerance);
+ Assert.Equal(VolumeUnit.HectousGallon, quantity22.Unit);
+
+ var quantity23 = Volume.From(1, VolumeUnit.ImperialBeerBarrel);
+ AssertEx.EqualTolerance(1, quantity23.ImperialBeerBarrels, ImperialBeerBarrelsTolerance);
+ Assert.Equal(VolumeUnit.ImperialBeerBarrel, quantity23.Unit);
+
+ var quantity24 = Volume.From(1, VolumeUnit.ImperialGallon);
+ AssertEx.EqualTolerance(1, quantity24.ImperialGallons, ImperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.ImperialGallon, quantity24.Unit);
+
+ var quantity25 = Volume.From(1, VolumeUnit.ImperialOunce);
+ AssertEx.EqualTolerance(1, quantity25.ImperialOunces, ImperialOuncesTolerance);
+ Assert.Equal(VolumeUnit.ImperialOunce, quantity25.Unit);
+
+ var quantity26 = Volume.From(1, VolumeUnit.ImperialPint);
+ AssertEx.EqualTolerance(1, quantity26.ImperialPints, ImperialPintsTolerance);
+ Assert.Equal(VolumeUnit.ImperialPint, quantity26.Unit);
+
+ var quantity27 = Volume.From(1, VolumeUnit.ImperialQuart);
+ AssertEx.EqualTolerance(1, quantity27.ImperialQuarts, ImperialQuartsTolerance);
+ Assert.Equal(VolumeUnit.ImperialQuart, quantity27.Unit);
+
+ var quantity28 = Volume.From(1, VolumeUnit.KilocubicFoot);
+ AssertEx.EqualTolerance(1, quantity28.KilocubicFeet, KilocubicFeetTolerance);
+ Assert.Equal(VolumeUnit.KilocubicFoot, quantity28.Unit);
+
+ var quantity29 = Volume.From(1, VolumeUnit.KilocubicMeter);
+ AssertEx.EqualTolerance(1, quantity29.KilocubicMeters, KilocubicMetersTolerance);
+ Assert.Equal(VolumeUnit.KilocubicMeter, quantity29.Unit);
+
+ var quantity30 = Volume.From(1, VolumeUnit.KiloimperialGallon);
+ AssertEx.EqualTolerance(1, quantity30.KiloimperialGallons, KiloimperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.KiloimperialGallon, quantity30.Unit);
+
+ var quantity31 = Volume.From(1, VolumeUnit.Kiloliter);
+ AssertEx.EqualTolerance(1, quantity31.Kiloliters, KilolitersTolerance);
+ Assert.Equal(VolumeUnit.Kiloliter, quantity31.Unit);
+
+ var quantity32 = Volume.From(1, VolumeUnit.KilousGallon);
+ AssertEx.EqualTolerance(1, quantity32.KilousGallons, KilousGallonsTolerance);
+ Assert.Equal(VolumeUnit.KilousGallon, quantity32.Unit);
+
+ var quantity33 = Volume.From(1, VolumeUnit.Liter);
+ AssertEx.EqualTolerance(1, quantity33.Liters, LitersTolerance);
+ Assert.Equal(VolumeUnit.Liter, quantity33.Unit);
+
+ var quantity34 = Volume.From(1, VolumeUnit.MegacubicFoot);
+ AssertEx.EqualTolerance(1, quantity34.MegacubicFeet, MegacubicFeetTolerance);
+ Assert.Equal(VolumeUnit.MegacubicFoot, quantity34.Unit);
+
+ var quantity35 = Volume.From(1, VolumeUnit.MegaimperialGallon);
+ AssertEx.EqualTolerance(1, quantity35.MegaimperialGallons, MegaimperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.MegaimperialGallon, quantity35.Unit);
+
+ var quantity36 = Volume.From(1, VolumeUnit.Megaliter);
+ AssertEx.EqualTolerance(1, quantity36.Megaliters, MegalitersTolerance);
+ Assert.Equal(VolumeUnit.Megaliter, quantity36.Unit);
+
+ var quantity37 = Volume.From(1, VolumeUnit.MegausGallon);
+ AssertEx.EqualTolerance(1, quantity37.MegausGallons, MegausGallonsTolerance);
+ Assert.Equal(VolumeUnit.MegausGallon, quantity37.Unit);
+
+ var quantity38 = Volume.From(1, VolumeUnit.MetricCup);
+ AssertEx.EqualTolerance(1, quantity38.MetricCups, MetricCupsTolerance);
+ Assert.Equal(VolumeUnit.MetricCup, quantity38.Unit);
+
+ var quantity39 = Volume.From(1, VolumeUnit.MetricTablespoon);
+ AssertEx.EqualTolerance(1, quantity39.MetricTablespoons, MetricTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTablespoon, quantity39.Unit);
+
+ var quantity40 = Volume.From(1, VolumeUnit.MetricTeaspoon);
+ AssertEx.EqualTolerance(1, quantity40.MetricTeaspoons, MetricTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTeaspoon, quantity40.Unit);
+
+ var quantity41 = Volume.From(1, VolumeUnit.Microliter);
+ AssertEx.EqualTolerance(1, quantity41.Microliters, MicrolitersTolerance);
+ Assert.Equal(VolumeUnit.Microliter, quantity41.Unit);
+
+ var quantity42 = Volume.From(1, VolumeUnit.Milliliter);
+ AssertEx.EqualTolerance(1, quantity42.Milliliters, MillilitersTolerance);
+ Assert.Equal(VolumeUnit.Milliliter, quantity42.Unit);
+
+ var quantity43 = Volume.From(1, VolumeUnit.Nanoliter);
+ AssertEx.EqualTolerance(1, quantity43.Nanoliters, NanolitersTolerance);
+ Assert.Equal(VolumeUnit.Nanoliter, quantity43.Unit);
+
+ var quantity44 = Volume.From(1, VolumeUnit.OilBarrel);
+ AssertEx.EqualTolerance(1, quantity44.OilBarrels, OilBarrelsTolerance);
+ Assert.Equal(VolumeUnit.OilBarrel, quantity44.Unit);
+
+ var quantity45 = Volume.From(1, VolumeUnit.UkTablespoon);
+ AssertEx.EqualTolerance(1, quantity45.UkTablespoons, UkTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.UkTablespoon, quantity45.Unit);
+
+ var quantity46 = Volume.From(1, VolumeUnit.UsBeerBarrel);
+ AssertEx.EqualTolerance(1, quantity46.UsBeerBarrels, UsBeerBarrelsTolerance);
+ Assert.Equal(VolumeUnit.UsBeerBarrel, quantity46.Unit);
+
+ var quantity47 = Volume.From(1, VolumeUnit.UsCustomaryCup);
+ AssertEx.EqualTolerance(1, quantity47.UsCustomaryCups, UsCustomaryCupsTolerance);
+ Assert.Equal(VolumeUnit.UsCustomaryCup, quantity47.Unit);
+
+ var quantity48 = Volume.From(1, VolumeUnit.UsGallon);
+ AssertEx.EqualTolerance(1, quantity48.UsGallons, UsGallonsTolerance);
+ Assert.Equal(VolumeUnit.UsGallon, quantity48.Unit);
+
+ var quantity49 = Volume.From(1, VolumeUnit.UsLegalCup);
+ AssertEx.EqualTolerance(1, quantity49.UsLegalCups, UsLegalCupsTolerance);
+ Assert.Equal(VolumeUnit.UsLegalCup, quantity49.Unit);
+
+ var quantity50 = Volume.From(1, VolumeUnit.UsOunce);
+ AssertEx.EqualTolerance(1, quantity50.UsOunces, UsOuncesTolerance);
+ Assert.Equal(VolumeUnit.UsOunce, quantity50.Unit);
+
+ var quantity51 = Volume.From(1, VolumeUnit.UsPint);
+ AssertEx.EqualTolerance(1, quantity51.UsPints, UsPintsTolerance);
+ Assert.Equal(VolumeUnit.UsPint, quantity51.Unit);
+
+ var quantity52 = Volume.From(1, VolumeUnit.UsQuart);
+ AssertEx.EqualTolerance(1, quantity52.UsQuarts, UsQuartsTolerance);
+ Assert.Equal(VolumeUnit.UsQuart, quantity52.Unit);
+
+ var quantity53 = Volume.From(1, VolumeUnit.UsTablespoon);
+ AssertEx.EqualTolerance(1, quantity53.UsTablespoons, UsTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.UsTablespoon, quantity53.Unit);
+
+ var quantity54 = Volume.From(1, VolumeUnit.UsTeaspoon);
+ AssertEx.EqualTolerance(1, quantity54.UsTeaspoons, UsTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.UsTeaspoon, quantity54.Unit);
+
}
[Fact]
@@ -469,6 +688,7 @@ public void As()
AssertEx.EqualTolerance(MegalitersInOneCubicMeter, cubicmeter.As(VolumeUnit.Megaliter), MegalitersTolerance);
AssertEx.EqualTolerance(MegausGallonsInOneCubicMeter, cubicmeter.As(VolumeUnit.MegausGallon), MegausGallonsTolerance);
AssertEx.EqualTolerance(MetricCupsInOneCubicMeter, cubicmeter.As(VolumeUnit.MetricCup), MetricCupsTolerance);
+ AssertEx.EqualTolerance(MetricTablespoonsInOneCubicMeter, cubicmeter.As(VolumeUnit.MetricTablespoon), MetricTablespoonsTolerance);
AssertEx.EqualTolerance(MetricTeaspoonsInOneCubicMeter, cubicmeter.As(VolumeUnit.MetricTeaspoon), MetricTeaspoonsTolerance);
AssertEx.EqualTolerance(MicrolitersInOneCubicMeter, cubicmeter.As(VolumeUnit.Microliter), MicrolitersTolerance);
AssertEx.EqualTolerance(MillilitersInOneCubicMeter, cubicmeter.As(VolumeUnit.Milliliter), MillilitersTolerance);
@@ -520,6 +740,1375 @@ public void As_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
Assert.Throws(() => quantity.As(unsupportedUnitSystem));
}
+ [Fact]
+ public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits()
+ {
+ var quantity = new Volume(value: 1, unit: Volume.BaseUnit);
+ var expectedUnit = Volume.Info.GetDefaultUnit(UnitSystem.SI);
+ var expectedValue = quantity.As(expectedUnit);
+
+ Assert.Multiple(() =>
+ {
+ Volume quantityToConvert = quantity;
+
+ Volume convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI);
+
+ Assert.Equal(expectedUnit, convertedQuantity.Unit);
+ Assert.Equal(expectedValue, convertedQuantity.Value);
+ }, () =>
+ {
+ IQuantity quantityToConvert = quantity;
+
+ IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI);
+
+ Assert.Equal(expectedUnit, convertedQuantity.Unit);
+ Assert.Equal(expectedValue, convertedQuantity.Value);
+ }, () =>
+ {
+ IQuantity quantityToConvert = quantity;
+
+ IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI);
+
+ Assert.Equal(expectedUnit, convertedQuantity.Unit);
+ Assert.Equal(expectedValue, convertedQuantity.Value);
+ });
+ }
+
+ [Fact]
+ public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull()
+ {
+ UnitSystem nullUnitSystem = null!;
+ Assert.Multiple(() =>
+ {
+ var quantity = new Volume(value: 1, unit: Volume.BaseUnit);
+ Assert.Throws(() => quantity.ToUnit(nullUnitSystem));
+ }, () =>
+ {
+ IQuantity quantity = new Volume(value: 1, unit: Volume.BaseUnit);
+ Assert.Throws(() => quantity.ToUnit(nullUnitSystem));
+ }, () =>
+ {
+ IQuantity quantity = new Volume(value: 1, unit: Volume.BaseUnit);
+ Assert.Throws(() => quantity.ToUnit(nullUnitSystem));
+ });
+ }
+
+ [Fact]
+ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
+ {
+ var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits);
+ Assert.Multiple(() =>
+ {
+ var quantity = new Volume(value: 1, unit: Volume.BaseUnit);
+ Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem));
+ }, () =>
+ {
+ IQuantity quantity = new Volume(value: 1, unit: Volume.BaseUnit);
+ Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem));
+ }, () =>
+ {
+ IQuantity quantity = new Volume(value: 1, unit: Volume.BaseUnit);
+ Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem));
+ });
+ }
+
+ [Fact]
+ public void Parse()
+ {
+ try
+ {
+ var parsed = Volume.Parse("1 ac-ft", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.AcreFeet, AcreFeetTolerance);
+ Assert.Equal(VolumeUnit.AcreFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 acre-foot", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.AcreFeet, AcreFeetTolerance);
+ Assert.Equal(VolumeUnit.AcreFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 acre-feet", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.AcreFeet, AcreFeetTolerance);
+ Assert.Equal(VolumeUnit.AcreFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 tablespoon (A.U.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.AuTablespoons, AuTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.AuTablespoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 bf", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 board foot", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 board feet", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 pmp", CultureInfo.GetCultureInfo("fr-CA"));
+ AssertEx.EqualTolerance(1, parsed.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 pied-planche", CultureInfo.GetCultureInfo("fr-CA"));
+ AssertEx.EqualTolerance(1, parsed.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 pied de planche", CultureInfo.GetCultureInfo("fr-CA"));
+ AssertEx.EqualTolerance(1, parsed.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 cl", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.Centiliters, CentilitersTolerance);
+ Assert.Equal(VolumeUnit.Centiliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 сл", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.Centiliters, CentilitersTolerance);
+ Assert.Equal(VolumeUnit.Centiliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 cm³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.CubicCentimeters, CubicCentimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicCentimeter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 см³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.CubicCentimeters, CubicCentimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicCentimeter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 dm³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.CubicDecimeters, CubicDecimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicDecimeter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 дм³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.CubicDecimeters, CubicDecimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicDecimeter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 ft³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.CubicFeet, CubicFeetTolerance);
+ Assert.Equal(VolumeUnit.CubicFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 фут³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.CubicFeet, CubicFeetTolerance);
+ Assert.Equal(VolumeUnit.CubicFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 hm³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.CubicHectometers, CubicHectometersTolerance);
+ Assert.Equal(VolumeUnit.CubicHectometer, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 гм³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.CubicHectometers, CubicHectometersTolerance);
+ Assert.Equal(VolumeUnit.CubicHectometer, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 in³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.CubicInches, CubicInchesTolerance);
+ Assert.Equal(VolumeUnit.CubicInch, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 дюйм³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.CubicInches, CubicInchesTolerance);
+ Assert.Equal(VolumeUnit.CubicInch, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 km³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.CubicKilometers, CubicKilometersTolerance);
+ Assert.Equal(VolumeUnit.CubicKilometer, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 км³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.CubicKilometers, CubicKilometersTolerance);
+ Assert.Equal(VolumeUnit.CubicKilometer, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 m³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.CubicMeters, CubicMetersTolerance);
+ Assert.Equal(VolumeUnit.CubicMeter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 м³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.CubicMeters, CubicMetersTolerance);
+ Assert.Equal(VolumeUnit.CubicMeter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 µm³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.CubicMicrometers, CubicMicrometersTolerance);
+ Assert.Equal(VolumeUnit.CubicMicrometer, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 мкм³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.CubicMicrometers, CubicMicrometersTolerance);
+ Assert.Equal(VolumeUnit.CubicMicrometer, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 mi³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.CubicMiles, CubicMilesTolerance);
+ Assert.Equal(VolumeUnit.CubicMile, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 миля³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.CubicMiles, CubicMilesTolerance);
+ Assert.Equal(VolumeUnit.CubicMile, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 mm³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.CubicMillimeters, CubicMillimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicMillimeter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 мм³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.CubicMillimeters, CubicMillimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicMillimeter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 yd³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.CubicYards, CubicYardsTolerance);
+ Assert.Equal(VolumeUnit.CubicYard, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 ярд³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.CubicYards, CubicYardsTolerance);
+ Assert.Equal(VolumeUnit.CubicYard, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 dal", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.Decaliters, DecalitersTolerance);
+ Assert.Equal(VolumeUnit.Decaliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 дал", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.Decaliters, DecalitersTolerance);
+ Assert.Equal(VolumeUnit.Decaliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 dagal (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.DecausGallons, DecausGallonsTolerance);
+ Assert.Equal(VolumeUnit.DecausGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 даАмериканский галлон", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.DecausGallons, DecausGallonsTolerance);
+ Assert.Equal(VolumeUnit.DecausGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 dl", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.Deciliters, DecilitersTolerance);
+ Assert.Equal(VolumeUnit.Deciliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 дл", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.Deciliters, DecilitersTolerance);
+ Assert.Equal(VolumeUnit.Deciliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 dgal (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.DeciusGallons, DeciusGallonsTolerance);
+ Assert.Equal(VolumeUnit.DeciusGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 дАмериканский галлон", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.DeciusGallons, DeciusGallonsTolerance);
+ Assert.Equal(VolumeUnit.DeciusGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 hft³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.HectocubicFeet, HectocubicFeetTolerance);
+ Assert.Equal(VolumeUnit.HectocubicFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 гфут³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.HectocubicFeet, HectocubicFeetTolerance);
+ Assert.Equal(VolumeUnit.HectocubicFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 hm³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.HectocubicMeters, HectocubicMetersTolerance);
+ Assert.Equal(VolumeUnit.HectocubicMeter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 гм³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.HectocubicMeters, HectocubicMetersTolerance);
+ Assert.Equal(VolumeUnit.HectocubicMeter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 hl", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.Hectoliters, HectolitersTolerance);
+ Assert.Equal(VolumeUnit.Hectoliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 гл", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.Hectoliters, HectolitersTolerance);
+ Assert.Equal(VolumeUnit.Hectoliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 hgal (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.HectousGallons, HectousGallonsTolerance);
+ Assert.Equal(VolumeUnit.HectousGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 гАмериканский галлон", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.HectousGallons, HectousGallonsTolerance);
+ Assert.Equal(VolumeUnit.HectousGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 bl (imp.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.ImperialBeerBarrels, ImperialBeerBarrelsTolerance);
+ Assert.Equal(VolumeUnit.ImperialBeerBarrel, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 gal (imp.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.ImperialGallons, ImperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.ImperialGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 Английский галлон", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.ImperialGallons, ImperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.ImperialGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 oz (imp.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.ImperialOunces, ImperialOuncesTolerance);
+ Assert.Equal(VolumeUnit.ImperialOunce, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 Английская унция", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.ImperialOunces, ImperialOuncesTolerance);
+ Assert.Equal(VolumeUnit.ImperialOunce, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 pt (imp.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.ImperialPints, ImperialPintsTolerance);
+ Assert.Equal(VolumeUnit.ImperialPint, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 UK pt", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.ImperialPints, ImperialPintsTolerance);
+ Assert.Equal(VolumeUnit.ImperialPint, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 pt", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.ImperialPints, ImperialPintsTolerance);
+ Assert.Equal(VolumeUnit.ImperialPint, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 p", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.ImperialPints, ImperialPintsTolerance);
+ Assert.Equal(VolumeUnit.ImperialPint, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 qt (imp.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.ImperialQuarts, ImperialQuartsTolerance);
+ Assert.Equal(VolumeUnit.ImperialQuart, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 kft³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.KilocubicFeet, KilocubicFeetTolerance);
+ Assert.Equal(VolumeUnit.KilocubicFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 кфут³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.KilocubicFeet, KilocubicFeetTolerance);
+ Assert.Equal(VolumeUnit.KilocubicFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 km³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.KilocubicMeters, KilocubicMetersTolerance);
+ Assert.Equal(VolumeUnit.KilocubicMeter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 км³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.KilocubicMeters, KilocubicMetersTolerance);
+ Assert.Equal(VolumeUnit.KilocubicMeter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 kgal (imp.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.KiloimperialGallons, KiloimperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.KiloimperialGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 кАнглийский галлон", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.KiloimperialGallons, KiloimperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.KiloimperialGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 kl", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.Kiloliters, KilolitersTolerance);
+ Assert.Equal(VolumeUnit.Kiloliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 кл", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.Kiloliters, KilolitersTolerance);
+ Assert.Equal(VolumeUnit.Kiloliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 kgal (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.KilousGallons, KilousGallonsTolerance);
+ Assert.Equal(VolumeUnit.KilousGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 кАмериканский галлон", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.KilousGallons, KilousGallonsTolerance);
+ Assert.Equal(VolumeUnit.KilousGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 l", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.Liters, LitersTolerance);
+ Assert.Equal(VolumeUnit.Liter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 л", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.Liters, LitersTolerance);
+ Assert.Equal(VolumeUnit.Liter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 Mft³", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MegacubicFeet, MegacubicFeetTolerance);
+ Assert.Equal(VolumeUnit.MegacubicFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 Мфут³", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.MegacubicFeet, MegacubicFeetTolerance);
+ Assert.Equal(VolumeUnit.MegacubicFoot, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 Mgal (imp.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MegaimperialGallons, MegaimperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.MegaimperialGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 МАнглийский галлон", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.MegaimperialGallons, MegaimperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.MegaimperialGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 Ml", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.Megaliters, MegalitersTolerance);
+ Assert.Equal(VolumeUnit.Megaliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 Мл", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.Megaliters, MegalitersTolerance);
+ Assert.Equal(VolumeUnit.Megaliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 Mgal (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MegausGallons, MegausGallonsTolerance);
+ Assert.Equal(VolumeUnit.MegausGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 МАмериканский галлон", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.MegausGallons, MegausGallonsTolerance);
+ Assert.Equal(VolumeUnit.MegausGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 metric cup", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricCups, MetricCupsTolerance);
+ Assert.Equal(VolumeUnit.MetricCup, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 tablespoon", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTablespoons, MetricTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTablespoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 tbsp", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTablespoons, MetricTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTablespoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 tbsp.", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTablespoons, MetricTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTablespoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 tblsp", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTablespoons, MetricTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTablespoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 tblsp.", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTablespoons, MetricTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTablespoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 tsp", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTeaspoons, MetricTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTeaspoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 t", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTeaspoons, MetricTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTeaspoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 ts", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTeaspoons, MetricTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTeaspoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 tspn", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTeaspoons, MetricTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTeaspoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 t.", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTeaspoons, MetricTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTeaspoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 ts.", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTeaspoons, MetricTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTeaspoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 tsp.", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTeaspoons, MetricTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTeaspoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 tspn.", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTeaspoons, MetricTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTeaspoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 teaspoon", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.MetricTeaspoons, MetricTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTeaspoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 µl", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.Microliters, MicrolitersTolerance);
+ Assert.Equal(VolumeUnit.Microliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 мкл", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.Microliters, MicrolitersTolerance);
+ Assert.Equal(VolumeUnit.Microliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 ml", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.Milliliters, MillilitersTolerance);
+ Assert.Equal(VolumeUnit.Milliliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 мл", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.Milliliters, MillilitersTolerance);
+ Assert.Equal(VolumeUnit.Milliliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 nl", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.Nanoliters, NanolitersTolerance);
+ Assert.Equal(VolumeUnit.Nanoliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 нл", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.Nanoliters, NanolitersTolerance);
+ Assert.Equal(VolumeUnit.Nanoliter, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 bbl", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.OilBarrels, OilBarrelsTolerance);
+ Assert.Equal(VolumeUnit.OilBarrel, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 tablespoon (U.K.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.UkTablespoons, UkTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.UkTablespoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 bl (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.UsBeerBarrels, UsBeerBarrelsTolerance);
+ Assert.Equal(VolumeUnit.UsBeerBarrel, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 cup (U.S. customary)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.UsCustomaryCups, UsCustomaryCupsTolerance);
+ Assert.Equal(VolumeUnit.UsCustomaryCup, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 gal (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.UsGallons, UsGallonsTolerance);
+ Assert.Equal(VolumeUnit.UsGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 Американский галлон", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.UsGallons, UsGallonsTolerance);
+ Assert.Equal(VolumeUnit.UsGallon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 cup (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.UsLegalCups, UsLegalCupsTolerance);
+ Assert.Equal(VolumeUnit.UsLegalCup, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 oz (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.UsOunces, UsOuncesTolerance);
+ Assert.Equal(VolumeUnit.UsOunce, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 Американская унция", CultureInfo.GetCultureInfo("ru-RU"));
+ AssertEx.EqualTolerance(1, parsed.UsOunces, UsOuncesTolerance);
+ Assert.Equal(VolumeUnit.UsOunce, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 pt (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.UsPints, UsPintsTolerance);
+ Assert.Equal(VolumeUnit.UsPint, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 qt (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.UsQuarts, UsQuartsTolerance);
+ Assert.Equal(VolumeUnit.UsQuart, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 tablespoon (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.UsTablespoons, UsTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.UsTablespoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ try
+ {
+ var parsed = Volume.Parse("1 teaspoon (U.S.)", CultureInfo.GetCultureInfo("en-US"));
+ AssertEx.EqualTolerance(1, parsed.UsTeaspoons, UsTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.UsTeaspoon, parsed.Unit);
+ } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ }
+
+ }
+
+ [Fact]
+ public void TryParse()
+ {
+ {
+ Assert.True(Volume.TryParse("1 ac-ft", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.AcreFeet, AcreFeetTolerance);
+ Assert.Equal(VolumeUnit.AcreFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 acre-foot", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.AcreFeet, AcreFeetTolerance);
+ Assert.Equal(VolumeUnit.AcreFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 acre-feet", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.AcreFeet, AcreFeetTolerance);
+ Assert.Equal(VolumeUnit.AcreFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 tablespoon (A.U.)", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.AuTablespoons, AuTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.AuTablespoon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 bf", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 board foot", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 board feet", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 pmp", CultureInfo.GetCultureInfo("fr-CA"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 pied-planche", CultureInfo.GetCultureInfo("fr-CA"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 pied de planche", CultureInfo.GetCultureInfo("fr-CA"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.BoardFeet, BoardFeetTolerance);
+ Assert.Equal(VolumeUnit.BoardFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 cl", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.Centiliters, CentilitersTolerance);
+ Assert.Equal(VolumeUnit.Centiliter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 сл", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.Centiliters, CentilitersTolerance);
+ Assert.Equal(VolumeUnit.Centiliter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 cm³", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicCentimeters, CubicCentimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicCentimeter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 см³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicCentimeters, CubicCentimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicCentimeter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 dm³", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicDecimeters, CubicDecimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicDecimeter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 дм³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicDecimeters, CubicDecimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicDecimeter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 ft³", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicFeet, CubicFeetTolerance);
+ Assert.Equal(VolumeUnit.CubicFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 фут³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicFeet, CubicFeetTolerance);
+ Assert.Equal(VolumeUnit.CubicFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 in³", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicInches, CubicInchesTolerance);
+ Assert.Equal(VolumeUnit.CubicInch, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 дюйм³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicInches, CubicInchesTolerance);
+ Assert.Equal(VolumeUnit.CubicInch, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 m³", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicMeters, CubicMetersTolerance);
+ Assert.Equal(VolumeUnit.CubicMeter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 м³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicMeters, CubicMetersTolerance);
+ Assert.Equal(VolumeUnit.CubicMeter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 µm³", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicMicrometers, CubicMicrometersTolerance);
+ Assert.Equal(VolumeUnit.CubicMicrometer, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 мкм³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicMicrometers, CubicMicrometersTolerance);
+ Assert.Equal(VolumeUnit.CubicMicrometer, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 mi³", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicMiles, CubicMilesTolerance);
+ Assert.Equal(VolumeUnit.CubicMile, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 миля³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicMiles, CubicMilesTolerance);
+ Assert.Equal(VolumeUnit.CubicMile, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 mm³", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicMillimeters, CubicMillimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicMillimeter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 мм³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicMillimeters, CubicMillimetersTolerance);
+ Assert.Equal(VolumeUnit.CubicMillimeter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 yd³", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicYards, CubicYardsTolerance);
+ Assert.Equal(VolumeUnit.CubicYard, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 ярд³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.CubicYards, CubicYardsTolerance);
+ Assert.Equal(VolumeUnit.CubicYard, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 dal", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.Decaliters, DecalitersTolerance);
+ Assert.Equal(VolumeUnit.Decaliter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 дал", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.Decaliters, DecalitersTolerance);
+ Assert.Equal(VolumeUnit.Decaliter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 dagal (U.S.)", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.DecausGallons, DecausGallonsTolerance);
+ Assert.Equal(VolumeUnit.DecausGallon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 даАмериканский галлон", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.DecausGallons, DecausGallonsTolerance);
+ Assert.Equal(VolumeUnit.DecausGallon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 dl", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.Deciliters, DecilitersTolerance);
+ Assert.Equal(VolumeUnit.Deciliter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 дл", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.Deciliters, DecilitersTolerance);
+ Assert.Equal(VolumeUnit.Deciliter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 dgal (U.S.)", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.DeciusGallons, DeciusGallonsTolerance);
+ Assert.Equal(VolumeUnit.DeciusGallon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 дАмериканский галлон", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.DeciusGallons, DeciusGallonsTolerance);
+ Assert.Equal(VolumeUnit.DeciusGallon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 hft³", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.HectocubicFeet, HectocubicFeetTolerance);
+ Assert.Equal(VolumeUnit.HectocubicFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 гфут³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.HectocubicFeet, HectocubicFeetTolerance);
+ Assert.Equal(VolumeUnit.HectocubicFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 hl", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.Hectoliters, HectolitersTolerance);
+ Assert.Equal(VolumeUnit.Hectoliter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 гл", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.Hectoliters, HectolitersTolerance);
+ Assert.Equal(VolumeUnit.Hectoliter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 hgal (U.S.)", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.HectousGallons, HectousGallonsTolerance);
+ Assert.Equal(VolumeUnit.HectousGallon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 гАмериканский галлон", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.HectousGallons, HectousGallonsTolerance);
+ Assert.Equal(VolumeUnit.HectousGallon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 bl (imp.)", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.ImperialBeerBarrels, ImperialBeerBarrelsTolerance);
+ Assert.Equal(VolumeUnit.ImperialBeerBarrel, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 gal (imp.)", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.ImperialGallons, ImperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.ImperialGallon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 Английский галлон", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.ImperialGallons, ImperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.ImperialGallon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 oz (imp.)", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.ImperialOunces, ImperialOuncesTolerance);
+ Assert.Equal(VolumeUnit.ImperialOunce, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 Английская унция", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.ImperialOunces, ImperialOuncesTolerance);
+ Assert.Equal(VolumeUnit.ImperialOunce, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 pt (imp.)", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.ImperialPints, ImperialPintsTolerance);
+ Assert.Equal(VolumeUnit.ImperialPint, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 UK pt", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.ImperialPints, ImperialPintsTolerance);
+ Assert.Equal(VolumeUnit.ImperialPint, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 pt", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.ImperialPints, ImperialPintsTolerance);
+ Assert.Equal(VolumeUnit.ImperialPint, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 p", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.ImperialPints, ImperialPintsTolerance);
+ Assert.Equal(VolumeUnit.ImperialPint, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 qt (imp.)", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.ImperialQuarts, ImperialQuartsTolerance);
+ Assert.Equal(VolumeUnit.ImperialQuart, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 kft³", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.KilocubicFeet, KilocubicFeetTolerance);
+ Assert.Equal(VolumeUnit.KilocubicFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 кфут³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.KilocubicFeet, KilocubicFeetTolerance);
+ Assert.Equal(VolumeUnit.KilocubicFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 kgal (imp.)", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.KiloimperialGallons, KiloimperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.KiloimperialGallon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 кАнглийский галлон", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.KiloimperialGallons, KiloimperialGallonsTolerance);
+ Assert.Equal(VolumeUnit.KiloimperialGallon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 kl", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.Kiloliters, KilolitersTolerance);
+ Assert.Equal(VolumeUnit.Kiloliter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 кл", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.Kiloliters, KilolitersTolerance);
+ Assert.Equal(VolumeUnit.Kiloliter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 kgal (U.S.)", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.KilousGallons, KilousGallonsTolerance);
+ Assert.Equal(VolumeUnit.KilousGallon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 кАмериканский галлон", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.KilousGallons, KilousGallonsTolerance);
+ Assert.Equal(VolumeUnit.KilousGallon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 l", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.Liters, LitersTolerance);
+ Assert.Equal(VolumeUnit.Liter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 л", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.Liters, LitersTolerance);
+ Assert.Equal(VolumeUnit.Liter, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 Mft³", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.MegacubicFeet, MegacubicFeetTolerance);
+ Assert.Equal(VolumeUnit.MegacubicFoot, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 Мфут³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.MegacubicFeet, MegacubicFeetTolerance);
+ Assert.Equal(VolumeUnit.MegacubicFoot, parsed.Unit);
+ }
+
+ {
+ var quantity = Volume.From(1, unit);
+ Assert.Equal(1, quantity.Value);
+ Assert.Equal(unit, quantity.Unit);
+ });
+ }
+
+ [Fact]
+ public void FromCubicMeters_WithInfinityValue_DoNotThrowsArgumentException()
+ {
+ var exception1 = Record.Exception(() => Volume.FromCubicMeters(double.PositiveInfinity));
+ var exception2 = Record.Exception(() => Volume.FromCubicMeters(double.NegativeInfinity));
+
+ Assert.Null(exception1);
+ Assert.Null(exception2);
+ }
+
+ [Fact]
+ public void FromCubicMeters_WithNanValue_DoNotThrowsArgumentException()
+ {
+ var exception = Record.Exception(() => Volume.FromCubicMeters(double.NaN));
+
+ Assert.Null(exception);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 tablespoon", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.MetricTablespoons, MetricTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTablespoon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 tbsp", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.MetricTablespoons, MetricTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTablespoon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 tbsp.", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.MetricTablespoons, MetricTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTablespoon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 tblsp", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.MetricTablespoons, MetricTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTablespoon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 tblsp.", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.MetricTablespoons, MetricTablespoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTablespoon, parsed.Unit);
+ }
+
+ {
+ Assert.True(Volume.TryParse("1 tsp", CultureInfo.GetCultureInfo("en-US"), out var parsed));
+ AssertEx.EqualTolerance(1, parsed.MetricTeaspoons, MetricTeaspoonsTolerance);
+ Assert.Equal(VolumeUnit.MetricTeaspoon, parsed.Unit);
+ }
+
+ [Fact]
+ public virtual void BaseUnit_HasSIBase()
+ {
+ var baseUnitInfo = Volume.Info.BaseUnitInfo;
+ Assert.True(baseUnitInfo.BaseUnits.IsSubsetOf(UnitSystem.SI.BaseUnits));
+ }
+
+ [Fact]
+ public virtual void As_UnitSystem_SI_ReturnsQuantityInSIUnits()
+ {
+ var quantity = new Volume(value: 1, unit: Volume.BaseUnit);
+ var expectedValue = quantity.As(Volume.Info.GetDefaultUnit(UnitSystem.SI));
+
+ var convertedValue = quantity.As(UnitSystem.SI);
+
+ Assert.Equal(expectedValue, convertedValue);
+ }
+
+ [Fact]
+ public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull()
+ {
+ var quantity = new Volume(value: 1, unit: Volume.BaseUnit);
+ UnitSystem nullUnitSystem = null!;
+ Assert.Throws(() => quantity.As(nullUnitSystem));
+ }
+
+ [Fact]
+ public void As_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
+ {
+ var quantity = new Volume(value: 1, unit: Volume.BaseUnit);
+ var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits);
+ Assert.Throws(() => quantity.As(unsupportedUnitSystem));
+ }
+
[Fact]
public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits()
{
@@ -890,6 +2479,11 @@ public void TryParseWithAmbiguousAbbreviation(string culture, string quantityStr
[InlineData("Ml", VolumeUnit.Megaliter)]
[InlineData("Mgal (U.S.)", VolumeUnit.MegausGallon)]
[InlineData("metric cup", VolumeUnit.MetricCup)]
+ [InlineData("tablespoon", VolumeUnit.MetricTablespoon)]
+ [InlineData("tbsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("tbsp.", VolumeUnit.MetricTablespoon)]
+ [InlineData("tblsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("tblsp.", VolumeUnit.MetricTablespoon)]
[InlineData("tsp", VolumeUnit.MetricTeaspoon)]
[InlineData("t", VolumeUnit.MetricTeaspoon)]
[InlineData("ts", VolumeUnit.MetricTeaspoon)]
@@ -964,6 +2558,11 @@ public void ParseUnit_WithUsEnglishCurrentCulture(string abbreviation, VolumeUni
[InlineData("Ml", VolumeUnit.Megaliter)]
[InlineData("Mgal (U.S.)", VolumeUnit.MegausGallon)]
[InlineData("metric cup", VolumeUnit.MetricCup)]
+ [InlineData("tablespoon", VolumeUnit.MetricTablespoon)]
+ [InlineData("tbsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("tbsp.", VolumeUnit.MetricTablespoon)]
+ [InlineData("tblsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("tblsp.", VolumeUnit.MetricTablespoon)]
[InlineData("tsp", VolumeUnit.MetricTeaspoon)]
[InlineData("t", VolumeUnit.MetricTeaspoon)]
[InlineData("ts", VolumeUnit.MetricTeaspoon)]
@@ -1038,6 +2637,11 @@ public void ParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(string
[InlineData("en-US", "Ml", VolumeUnit.Megaliter)]
[InlineData("en-US", "Mgal (U.S.)", VolumeUnit.MegausGallon)]
[InlineData("en-US", "metric cup", VolumeUnit.MetricCup)]
+ [InlineData("en-US", "tablespoon", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tbsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tbsp.", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tblsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tblsp.", VolumeUnit.MetricTablespoon)]
[InlineData("en-US", "tsp", VolumeUnit.MetricTeaspoon)]
[InlineData("en-US", "t", VolumeUnit.MetricTeaspoon)]
[InlineData("en-US", "ts", VolumeUnit.MetricTeaspoon)]
@@ -1147,6 +2751,11 @@ public void ParseUnit_WithCurrentCulture(string culture, string abbreviation, Vo
[InlineData("en-US", "Ml", VolumeUnit.Megaliter)]
[InlineData("en-US", "Mgal (U.S.)", VolumeUnit.MegausGallon)]
[InlineData("en-US", "metric cup", VolumeUnit.MetricCup)]
+ [InlineData("en-US", "tablespoon", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tbsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tbsp.", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tblsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tblsp.", VolumeUnit.MetricTablespoon)]
[InlineData("en-US", "tsp", VolumeUnit.MetricTeaspoon)]
[InlineData("en-US", "t", VolumeUnit.MetricTeaspoon)]
[InlineData("en-US", "ts", VolumeUnit.MetricTeaspoon)]
@@ -1265,6 +2874,11 @@ public void ParseUnitWithAmbiguousAbbreviation(string culture, string abbreviati
[InlineData("Ml", VolumeUnit.Megaliter)]
[InlineData("Mgal (U.S.)", VolumeUnit.MegausGallon)]
[InlineData("metric cup", VolumeUnit.MetricCup)]
+ [InlineData("tablespoon", VolumeUnit.MetricTablespoon)]
+ [InlineData("tbsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("tbsp.", VolumeUnit.MetricTablespoon)]
+ [InlineData("tblsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("tblsp.", VolumeUnit.MetricTablespoon)]
[InlineData("tsp", VolumeUnit.MetricTeaspoon)]
[InlineData("t", VolumeUnit.MetricTeaspoon)]
[InlineData("ts", VolumeUnit.MetricTeaspoon)]
@@ -1339,6 +2953,11 @@ public void TryParseUnit_WithUsEnglishCurrentCulture(string abbreviation, Volume
[InlineData("Ml", VolumeUnit.Megaliter)]
[InlineData("Mgal (U.S.)", VolumeUnit.MegausGallon)]
[InlineData("metric cup", VolumeUnit.MetricCup)]
+ [InlineData("tablespoon", VolumeUnit.MetricTablespoon)]
+ [InlineData("tbsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("tbsp.", VolumeUnit.MetricTablespoon)]
+ [InlineData("tblsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("tblsp.", VolumeUnit.MetricTablespoon)]
[InlineData("tsp", VolumeUnit.MetricTeaspoon)]
[InlineData("t", VolumeUnit.MetricTeaspoon)]
[InlineData("ts", VolumeUnit.MetricTeaspoon)]
@@ -1413,6 +3032,11 @@ public void TryParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(stri
[InlineData("en-US", "Ml", VolumeUnit.Megaliter)]
[InlineData("en-US", "Mgal (U.S.)", VolumeUnit.MegausGallon)]
[InlineData("en-US", "metric cup", VolumeUnit.MetricCup)]
+ [InlineData("en-US", "tablespoon", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tbsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tbsp.", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tblsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tblsp.", VolumeUnit.MetricTablespoon)]
[InlineData("en-US", "tsp", VolumeUnit.MetricTeaspoon)]
[InlineData("en-US", "t", VolumeUnit.MetricTeaspoon)]
[InlineData("en-US", "ts", VolumeUnit.MetricTeaspoon)]
@@ -1522,6 +3146,11 @@ public void TryParseUnit_WithCurrentCulture(string culture, string abbreviation,
[InlineData("en-US", "Ml", VolumeUnit.Megaliter)]
[InlineData("en-US", "Mgal (U.S.)", VolumeUnit.MegausGallon)]
[InlineData("en-US", "metric cup", VolumeUnit.MetricCup)]
+ [InlineData("en-US", "tablespoon", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tbsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tbsp.", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tblsp", VolumeUnit.MetricTablespoon)]
+ [InlineData("en-US", "tblsp.", VolumeUnit.MetricTablespoon)]
[InlineData("en-US", "tsp", VolumeUnit.MetricTeaspoon)]
[InlineData("en-US", "t", VolumeUnit.MetricTeaspoon)]
[InlineData("en-US", "ts", VolumeUnit.MetricTeaspoon)]
@@ -1813,6 +3442,7 @@ public void ConversionRoundTrip()
AssertEx.EqualTolerance(1, Volume.FromMegaliters(cubicmeter.Megaliters).CubicMeters, MegalitersTolerance);
AssertEx.EqualTolerance(1, Volume.FromMegausGallons(cubicmeter.MegausGallons).CubicMeters, MegausGallonsTolerance);
AssertEx.EqualTolerance(1, Volume.FromMetricCups(cubicmeter.MetricCups).CubicMeters, MetricCupsTolerance);
+ AssertEx.EqualTolerance(1, Volume.FromMetricTablespoons(cubicmeter.MetricTablespoons).CubicMeters, MetricTablespoonsTolerance);
AssertEx.EqualTolerance(1, Volume.FromMetricTeaspoons(cubicmeter.MetricTeaspoons).CubicMeters, MetricTeaspoonsTolerance);
AssertEx.EqualTolerance(1, Volume.FromMicroliters(cubicmeter.Microliters).CubicMeters, MicrolitersTolerance);
AssertEx.EqualTolerance(1, Volume.FromMilliliters(cubicmeter.Milliliters).CubicMeters, MillilitersTolerance);
@@ -2023,6 +3653,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture()
Assert.Equal("1 Ml", new Volume(1, VolumeUnit.Megaliter).ToString());
Assert.Equal("1 Mgal (U.S.)", new Volume(1, VolumeUnit.MegausGallon).ToString());
Assert.Equal("1 metric cup", new Volume(1, VolumeUnit.MetricCup).ToString());
+ Assert.Equal("1 tablespoon", new Volume(1, VolumeUnit.MetricTablespoon).ToString());
Assert.Equal("1 tsp", new Volume(1, VolumeUnit.MetricTeaspoon).ToString());
Assert.Equal("1 µl", new Volume(1, VolumeUnit.Microliter).ToString());
Assert.Equal("1 ml", new Volume(1, VolumeUnit.Milliliter).ToString());
@@ -2085,6 +3716,7 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture
Assert.Equal("1 Ml", new Volume(1, VolumeUnit.Megaliter).ToString(swedishCulture));
Assert.Equal("1 Mgal (U.S.)", new Volume(1, VolumeUnit.MegausGallon).ToString(swedishCulture));
Assert.Equal("1 metric cup", new Volume(1, VolumeUnit.MetricCup).ToString(swedishCulture));
+ Assert.Equal("1 tablespoon", new Volume(1, VolumeUnit.MetricTablespoon).ToString(swedishCulture));
Assert.Equal("1 tsp", new Volume(1, VolumeUnit.MetricTeaspoon).ToString(swedishCulture));
Assert.Equal("1 µl", new Volume(1, VolumeUnit.Microliter).ToString(swedishCulture));
Assert.Equal("1 ml", new Volume(1, VolumeUnit.Milliliter).ToString(swedishCulture));
diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs
index a0ad2c8736..7f00434352 100644
--- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs
@@ -170,6 +170,7 @@ public static IEnumerable> GetDefaultMappings()
yield return new (VolumeUnit.Megaliter, "Megaliter", "Megaliters", new BaseUnits(length: LengthUnit.Decameter));
yield return new (VolumeUnit.MegausGallon, "MegausGallon", "MegausGallons", BaseUnits.Undefined);
yield return new (VolumeUnit.MetricCup, "MetricCup", "MetricCups", BaseUnits.Undefined);
+ yield return new (VolumeUnit.MetricTablespoon, "MetricTablespoon", "MetricTablespoons", BaseUnits.Undefined);
yield return new (VolumeUnit.MetricTeaspoon, "MetricTeaspoon", "MetricTeaspoons", BaseUnits.Undefined);
yield return new (VolumeUnit.Microliter, "Microliter", "Microliters", new BaseUnits(length: LengthUnit.Millimeter));
yield return new (VolumeUnit.Milliliter, "Milliliter", "Milliliters", new BaseUnits(length: LengthUnit.Centimeter));
@@ -490,6 +491,11 @@ public Volume(double value, UnitSystem unitSystem)
///
public double MetricCups => As(VolumeUnit.MetricCup);
+ ///
+ /// Gets a value of this quantity converted into
+ ///
+ public double MetricTablespoons => As(VolumeUnit.MetricTablespoon);
+
///
/// Gets a value of this quantity converted into
///
@@ -614,6 +620,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter)
unitConverter.SetConversionFunction(VolumeUnit.Megaliter, VolumeUnit.CubicMeter, quantity => quantity.ToUnit(VolumeUnit.CubicMeter));
unitConverter.SetConversionFunction(VolumeUnit.MegausGallon, VolumeUnit.CubicMeter, quantity => quantity.ToUnit(VolumeUnit.CubicMeter));
unitConverter.SetConversionFunction(VolumeUnit.MetricCup, VolumeUnit.CubicMeter, quantity => quantity.ToUnit(VolumeUnit.CubicMeter));
+ unitConverter.SetConversionFunction(VolumeUnit.MetricTablespoon, VolumeUnit.CubicMeter, quantity => quantity.ToUnit(VolumeUnit.CubicMeter));
unitConverter.SetConversionFunction(VolumeUnit.MetricTeaspoon, VolumeUnit.CubicMeter, quantity => quantity.ToUnit(VolumeUnit.CubicMeter));
unitConverter.SetConversionFunction(VolumeUnit.Microliter, VolumeUnit.CubicMeter, quantity => quantity.ToUnit(VolumeUnit.CubicMeter));
unitConverter.SetConversionFunction(VolumeUnit.Milliliter, VolumeUnit.CubicMeter, quantity => quantity.ToUnit(VolumeUnit.CubicMeter));
@@ -672,6 +679,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter)
unitConverter.SetConversionFunction(VolumeUnit.CubicMeter, VolumeUnit.Megaliter, quantity => quantity.ToUnit(VolumeUnit.Megaliter));
unitConverter.SetConversionFunction(VolumeUnit.CubicMeter, VolumeUnit.MegausGallon, quantity => quantity.ToUnit(VolumeUnit.MegausGallon));
unitConverter.SetConversionFunction(VolumeUnit.CubicMeter, VolumeUnit.MetricCup, quantity => quantity.ToUnit(VolumeUnit.MetricCup));
+ unitConverter.SetConversionFunction(VolumeUnit.CubicMeter, VolumeUnit.MetricTablespoon, quantity => quantity.ToUnit(VolumeUnit.MetricTablespoon));
unitConverter.SetConversionFunction(VolumeUnit.CubicMeter, VolumeUnit.MetricTeaspoon, quantity => quantity.ToUnit(VolumeUnit.MetricTeaspoon));
unitConverter.SetConversionFunction(VolumeUnit.CubicMeter, VolumeUnit.Microliter, quantity => quantity.ToUnit(VolumeUnit.Microliter));
unitConverter.SetConversionFunction(VolumeUnit.CubicMeter, VolumeUnit.Milliliter, quantity => quantity.ToUnit(VolumeUnit.Milliliter));
@@ -1026,6 +1034,14 @@ public static Volume FromMetricCups(double value)
return new Volume(value, VolumeUnit.MetricCup);
}
+ ///
+ /// Creates a from .
+ ///
+ public static Volume FromMetricTablespoons(double value)
+ {
+ return new Volume(value, VolumeUnit.MetricTablespoon);
+ }
+
///
/// Creates a from .
///
@@ -1659,6 +1675,7 @@ private bool TryToUnit(VolumeUnit unit, [NotNullWhen(true)] out Volume? converte
(VolumeUnit.Megaliter, VolumeUnit.CubicMeter) => new Volume((_value / 1e3) * 1e6d, VolumeUnit.CubicMeter),
(VolumeUnit.MegausGallon, VolumeUnit.CubicMeter) => new Volume((_value * 0.003785411784) * 1e6d, VolumeUnit.CubicMeter),
(VolumeUnit.MetricCup, VolumeUnit.CubicMeter) => new Volume(_value * 0.00025, VolumeUnit.CubicMeter),
+ (VolumeUnit.MetricTablespoon, VolumeUnit.CubicMeter) => new Volume(_value * 1.5e-5, VolumeUnit.CubicMeter),
(VolumeUnit.MetricTeaspoon, VolumeUnit.CubicMeter) => new Volume(_value * 0.5e-5, VolumeUnit.CubicMeter),
(VolumeUnit.Microliter, VolumeUnit.CubicMeter) => new Volume((_value / 1e3) * 1e-6d, VolumeUnit.CubicMeter),
(VolumeUnit.Milliliter, VolumeUnit.CubicMeter) => new Volume((_value / 1e3) * 1e-3d, VolumeUnit.CubicMeter),
@@ -1714,6 +1731,7 @@ private bool TryToUnit(VolumeUnit unit, [NotNullWhen(true)] out Volume? converte
(VolumeUnit.CubicMeter, VolumeUnit.Megaliter) => new Volume((_value * 1e3) / 1e6d, VolumeUnit.Megaliter),
(VolumeUnit.CubicMeter, VolumeUnit.MegausGallon) => new Volume((_value / 0.003785411784) / 1e6d, VolumeUnit.MegausGallon),
(VolumeUnit.CubicMeter, VolumeUnit.MetricCup) => new Volume(_value / 0.00025, VolumeUnit.MetricCup),
+ (VolumeUnit.CubicMeter, VolumeUnit.MetricTablespoon) => new Volume(_value / 1.5e-5, VolumeUnit.MetricTablespoon),
(VolumeUnit.CubicMeter, VolumeUnit.MetricTeaspoon) => new Volume(_value / 0.5e-5, VolumeUnit.MetricTeaspoon),
(VolumeUnit.CubicMeter, VolumeUnit.Microliter) => new Volume((_value * 1e3) / 1e-6d, VolumeUnit.Microliter),
(VolumeUnit.CubicMeter, VolumeUnit.Milliliter) => new Volume((_value * 1e3) / 1e-3d, VolumeUnit.Milliliter),
diff --git a/UnitsNet/GeneratedCode/Resources/Volume.restext b/UnitsNet/GeneratedCode/Resources/Volume.restext
index ddf8cb58da..5e5bc9e419 100644
--- a/UnitsNet/GeneratedCode/Resources/Volume.restext
+++ b/UnitsNet/GeneratedCode/Resources/Volume.restext
@@ -37,6 +37,7 @@ MegaimperialGallons=Mgal (imp.)
Megaliters=Ml
MegausGallons=Mgal (U.S.)
MetricCups=metric cup
+MetricTablespoons=tablespoon,tbsp,tbsp.,tblsp,tblsp.
MetricTeaspoons=tsp,t,ts,tspn,t.,ts.,tsp.,tspn.,teaspoon
Microliters=µl
Milliliters=ml
diff --git a/UnitsNet/GeneratedCode/Units/VolumeUnit.g.cs b/UnitsNet/GeneratedCode/Units/VolumeUnit.g.cs
index 84dbccfb05..1a8767f7db 100644
--- a/UnitsNet/GeneratedCode/Units/VolumeUnit.g.cs
+++ b/UnitsNet/GeneratedCode/Units/VolumeUnit.g.cs
@@ -130,6 +130,12 @@ public enum VolumeUnit
/// https://en.wikipedia.org/wiki/Cup_(unit)#Metric_cup
MetricCup = 38,
+ ///
+ /// An international metric tablespoon is exactly equal to 15 mL. It is the equivalence of 1 1/2 metric dessert spoons or metric teaspoons
+ ///
+ /// https://en.wikipedia.org/wiki/Tablespoon#International_metric
+ MetricTablespoon = 63,
+
///
/// The metric teaspoon as a unit of culinary measure is 5 ml (0.18 imp fl oz; 0.17 US fl oz),[17] equal to 5 cm3, 1⁄3 UK/Canadian metric tablespoon, or 1⁄4 Australian metric tablespoon.
///