diff --git a/Common/UnitDefinitions/FluidResistance.json b/Common/UnitDefinitions/FluidResistance.json new file mode 100644 index 0000000000..130d0f86cd --- /dev/null +++ b/Common/UnitDefinitions/FluidResistance.json @@ -0,0 +1,415 @@ +{ + "Name": "FluidResistance", + "BaseUnit": "PascalSecondPerCubicMeter", + "XmlDocSummary": "Fluid Resistance is a force acting opposite to the relative motion of any object moving with respect to a surrounding fluid. Fluid Resistance is sometimes referred to as drag or fluid friction.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Friction#Fluid", + "BaseDimensions": { + "M": 1, + "L": -4, + "T": -1 + }, + "Units": [ + { + "SingularName": "PascalSecondPerLiter", + "PluralName": "PascalSecondsPerLiter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 1e3", + "FromBaseToUnitFunc": "{x} / 1e3", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "Pa·s/l" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "Па·с/л" ] + } + ] + }, + { + "SingularName": "PascalMinutePerLiter", + "PluralName": "PascalMinutesPerLiter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 6e4", + "FromBaseToUnitFunc": "{x} / 6e4", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "Pa·min/l" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "Па·мин/л" ] + } + ] + }, + { + "SingularName": "PascalSecondPerMilliliter", + "PluralName": "PascalSecondsPerMilliliter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 1e6", + "FromBaseToUnitFunc": "{x} / 1e6", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "Pa·s/ml" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "Па·с/мл" ] + } + ] + }, + { + "SingularName": "PascalMinutePerMilliliter", + "PluralName": "PascalMinutesPerMilliliter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 6e7", + "FromBaseToUnitFunc": "{x} / 6e7", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "Pa·min/ml" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "Па·мин/мл" ] + } + ] + }, + { + "SingularName": "PascalSecondPerCubicMeter", + "PluralName": "PascalSecondsPerCubicMeter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x}", + "FromBaseToUnitFunc": "{x}", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "Pa·s/m³" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "Па·с/м³" ] + } + ] + }, + { + "SingularName": "PascalMinutePerCubicMeter", + "PluralName": "PascalMinutesPerCubicMeter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 60", + "FromBaseToUnitFunc": "{x} / 60", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "Pa·min/m³" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "Па·мин/м³" ] + } + ] + }, + { + "SingularName": "PascalSecondPerCubicCentimeter", + "PluralName": "PascalSecondsPerCubicCentimeter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 1e6", + "FromBaseToUnitFunc": "{x} / 1e6", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "Pa·s/cm³" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "Па·с/см³" ] + } + ] + }, + { + "SingularName": "PascalMinutePerCubicCentimeter", + "PluralName": "PascalMinutesPerCubicCentimeter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 6e7", + "FromBaseToUnitFunc": "{x} / 6e7", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "Pa·min/cm³" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "Па·мин/см³" ] + } + ] + }, + { + "SingularName": "MegapascalSecondPerCubicMeter", + "PluralName": "MegapascalSecondsPerCubicMeter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 1e6", + "FromBaseToUnitFunc": "{x} / 1e6", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Vascular_resistance", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "MPa·s/m³" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "МПа·с/м³" ] + } + ] + }, + { + "SingularName": "DyneSecondPerCentimeterToTheFifth", + "PluralName": "DyneSecondsPerCentimeterToTheFifth", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 1e-5", + "FromBaseToUnitFunc": "{x} / 1e-5", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Vascular_resistance", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "dyn·s/cm⁵", "dyn·s·cm⁻⁵" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "дин·с/см⁵", "дин·с·см⁻⁵" ] + } + ] + }, + { + "SingularName": "MillimeterMercurySecondPerLiter", + "PluralName": "MillimeterMercurySecondsPerLiter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 1.33322368e5", + "FromBaseToUnitFunc": "{x} / 1.33322368e5", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "mmHg·s/l" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "мм рт.ст·с/л" ] + } + ] + }, + { + "SingularName": "MillimeterMercuryMinutePerLiter", + "PluralName": "MillimeterMercuryMinutesPerLiter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 7.99934208e6", + "FromBaseToUnitFunc": "{x} / 7.99934208e6", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "mmHg·min/l" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "мм рт.ст·мин/л" ] + } + ] + }, + { + "SingularName": "MillimeterMercurySecondPerMilliliter", + "PluralName": "MillimeterMercurySecondsPerMilliliter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 1.33322368e8", + "FromBaseToUnitFunc": "{x} / 1.33322368e8", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "mmHg·s/ml" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "мм рт.ст·с/мл" ] + } + ] + }, + { + "SingularName": "MillimeterMercuryMinutePerMilliliter", + "PluralName": "MillimeterMercuryMinutesPerMilliliter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 7.99934208e9", + "FromBaseToUnitFunc": "{x} / 7.99934208e9", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "mmHg·min/ml" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "мм рт.ст·мин/мл" ] + } + ] + }, + { + "SingularName": "MillimeterMercurySecondPerCubicCentimeter", + "PluralName": "MillimeterMercurySecondsPerCubicCentimeter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 1.33322368e8", + "FromBaseToUnitFunc": "{x} / 1.33322368e8", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "mmHg·s/cm³" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "мм рт.ст·с/см³" ] + } + ] + }, + { + "SingularName": "MillimeterMercuryMinutePerCubicCentimeter", + "PluralName": "MillimeterMercuryMinutesPerCubicCentimeter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 7.99934208e9", + "FromBaseToUnitFunc": "{x} / 7.99934208e9", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "mmHg·min/cm³" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "мм рт.ст·мин/см³" ] + } + ] + }, + { + "SingularName": "MillimeterMercurySecondPerCubicMeter", + "PluralName": "MillimeterMercurySecondsPerCubicMeter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 133.322368", + "FromBaseToUnitFunc": "{x} / 133.322368", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "mmHg·s/m³" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "мм рт.ст·с/м³" ] + } + ] + }, + { + "SingularName": "MillimeterMercuryMinutePerCubicMeter", + "PluralName": "MillimeterMercuryMinutesPerCubicMeter", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 7.99934208e3", + "FromBaseToUnitFunc": "{x} / 7.99934208e3", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "mmHg·min/m³" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "мм рт.ст·мин/м³" ] + } + ] + }, + { + "SingularName": "WoodUnit", + "PluralName": "WoodUnits", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 7.99934208e6", + "FromBaseToUnitFunc": "{x} / 7.99934208e6", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Vascular_resistance", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "WU", "HRU" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "ЕВ", "ЕГС" ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Common/UnitEnumValues.g.json b/Common/UnitEnumValues.g.json index 59a164a718..61e715b277 100644 --- a/Common/UnitEnumValues.g.json +++ b/Common/UnitEnumValues.g.json @@ -1928,6 +1928,27 @@ "MilligraySquareMeter": 11, "MilligraySquareMillimeter": 12 }, + "FluidResistance": { + "DyneSecondPerCentimeterToTheFifth": 6, + "MegapascalSecondPerCubicMeter": 7, + "MillimeterMercuryMinutePerCubicCentimeter": 3, + "MillimeterMercuryMinutePerCubicMeter": 5, + "MillimeterMercuryMinutePerLiter": 2, + "MillimeterMercuryMinutePerMilliliter": 9, + "MillimeterMercurySecondPerCubicCentimeter": 8, + "MillimeterMercurySecondPerCubicMeter": 10, + "MillimeterMercurySecondPerLiter": 4, + "MillimeterMercurySecondPerMilliliter": 1, + "PascalMinutePerCubicCentimeter": 19, + "PascalMinutePerCubicMeter": 16, + "PascalMinutePerLiter": 15, + "PascalMinutePerMilliliter": 12, + "PascalSecondPerCubicCentimeter": 18, + "PascalSecondPerCubicMeter": 13, + "PascalSecondPerLiter": 11, + "PascalSecondPerMilliliter": 20, + "WoodUnit": 17 + }, "ElectricApparentEnergy": { "KilovoltampereHour": 7, "MegavoltampereHour": 3, diff --git a/UnitsNet.NanoFramework/GeneratedCode/FluidResistance/FluidResistance.nfproj b/UnitsNet.NanoFramework/GeneratedCode/FluidResistance/FluidResistance.nfproj new file mode 100644 index 0000000000..6fae96c9b0 --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/FluidResistance/FluidResistance.nfproj @@ -0,0 +1,42 @@ + + + + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {d19281dc-72f6-62a9-18d5-b845d6fd8d99} + Library + Properties + 512 + UnitsNet + UnitsNet.FluidResistance + v1.0 + bin\$(Configuration)\$(AssemblyName).xml + + + + + + + + + + ..\packages\nanoFramework.CoreLibrary.1.15.5\lib\mscorlib.dll + True + True + + + + + + + + + + + + diff --git a/UnitsNet.NanoFramework/GeneratedCode/FluidResistance/UnitsNet.NanoFramework.FluidResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/FluidResistance/UnitsNet.NanoFramework.FluidResistance.nuspec new file mode 100644 index 0000000000..24b3811816 --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/FluidResistance/UnitsNet.NanoFramework.FluidResistance.nuspec @@ -0,0 +1,26 @@ + + + + UnitsNet.nanoFramework.FluidResistance + 5.64.0 + Units.NET FluidResistance - nanoFramework + Andreas Gullberg Larsen,nanoframework + UnitsNet + MIT-0 + https://github.com/angularsen/UnitsNet + false + Adds FluidResistance units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. + https://raw.githubusercontent.com/angularsen/UnitsNet/ce85185429be345d77eb2ce09c99d59cc9ab8aed/Docs/Images/logo-32.png + + + Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). + en-US + nanoframework fluidresistance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable + + + + + + + + diff --git a/UnitsNet.NanoFramework/GeneratedCode/FluidResistance/packages.config b/UnitsNet.NanoFramework/GeneratedCode/FluidResistance/packages.config new file mode 100644 index 0000000000..313a8dccdf --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/FluidResistance/packages.config @@ -0,0 +1,4 @@ + + + + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/FluidResistance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/FluidResistance.g.cs new file mode 100644 index 0000000000..d813a38a4a --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/FluidResistance.g.cs @@ -0,0 +1,396 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using UnitsNet.Units; + +namespace UnitsNet +{ + /// + /// + /// Fluid Resistance is a force acting opposite to the relative motion of any object moving with respect to a surrounding fluid. Fluid Resistance is sometimes referred to as drag or fluid friction. + /// + /// + /// https://en.wikipedia.org/wiki/Friction#Fluid + /// + public struct FluidResistance + { + /// + /// The numeric value this quantity was constructed with. + /// + private readonly double _value; + + /// + /// The unit this quantity was constructed with. + /// + private readonly FluidResistanceUnit _unit; + + /// + /// The numeric value this quantity was constructed with. + /// + public double Value => _value; + + /// + public FluidResistanceUnit Unit => _unit; + + /// + /// Creates the quantity with the given numeric value and unit. + /// + /// The numeric value to construct this quantity with. + /// The unit representation to construct this quantity with. + /// If value is NaN or Infinity. + public FluidResistance(double value, FluidResistanceUnit unit) + { + _value = value; + _unit = unit; + } + + /// + /// The base unit of FluidResistance, which is Second. All conversions go via this value. + /// + public static FluidResistanceUnit BaseUnit { get; } = FluidResistanceUnit.PascalSecondPerCubicMeter; + + /// + /// Represents the largest possible value of FluidResistance. + /// + public static FluidResistance MaxValue { get; } = new FluidResistance(double.MaxValue, BaseUnit); + + /// + /// Represents the smallest possible value of FluidResistance. + /// + public static FluidResistance MinValue { get; } = new FluidResistance(double.MinValue, BaseUnit); + + /// + /// Gets an instance of this quantity with a value of 0 in the base unit Second. + /// + public static FluidResistance Zero { get; } = new FluidResistance(0, BaseUnit); + #region Conversion Properties + + /// + /// Gets a value of this quantity converted into + /// + public double DyneSecondsPerCentimeterToTheFifth => As(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth); + + /// + /// Gets a value of this quantity converted into + /// + public double MegapascalSecondsPerCubicMeter => As(FluidResistanceUnit.MegapascalSecondPerCubicMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercuryMinutesPerCubicCentimeter => As(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercuryMinutesPerCubicMeter => As(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercuryMinutesPerLiter => As(FluidResistanceUnit.MillimeterMercuryMinutePerLiter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercuryMinutesPerMilliliter => As(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercurySecondsPerCubicCentimeter => As(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercurySecondsPerCubicMeter => As(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercurySecondsPerLiter => As(FluidResistanceUnit.MillimeterMercurySecondPerLiter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercurySecondsPerMilliliter => As(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalMinutesPerCubicCentimeter => As(FluidResistanceUnit.PascalMinutePerCubicCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalMinutesPerCubicMeter => As(FluidResistanceUnit.PascalMinutePerCubicMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalMinutesPerLiter => As(FluidResistanceUnit.PascalMinutePerLiter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalMinutesPerMilliliter => As(FluidResistanceUnit.PascalMinutePerMilliliter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalSecondsPerCubicCentimeter => As(FluidResistanceUnit.PascalSecondPerCubicCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalSecondsPerCubicMeter => As(FluidResistanceUnit.PascalSecondPerCubicMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalSecondsPerLiter => As(FluidResistanceUnit.PascalSecondPerLiter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalSecondsPerMilliliter => As(FluidResistanceUnit.PascalSecondPerMilliliter); + + /// + /// Gets a value of this quantity converted into + /// + public double WoodUnits => As(FluidResistanceUnit.WoodUnit); + + #endregion + + #region Static Factory Methods + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromDyneSecondsPerCentimeterToTheFifth(double dynesecondspercentimetertothefifth) => new FluidResistance(dynesecondspercentimetertothefifth, FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMegapascalSecondsPerCubicMeter(double megapascalsecondspercubicmeter) => new FluidResistance(megapascalsecondspercubicmeter, FluidResistanceUnit.MegapascalSecondPerCubicMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercuryMinutesPerCubicCentimeter(double millimetermercuryminutespercubiccentimeter) => new FluidResistance(millimetermercuryminutespercubiccentimeter, FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercuryMinutesPerCubicMeter(double millimetermercuryminutespercubicmeter) => new FluidResistance(millimetermercuryminutespercubicmeter, FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercuryMinutesPerLiter(double millimetermercuryminutesperliter) => new FluidResistance(millimetermercuryminutesperliter, FluidResistanceUnit.MillimeterMercuryMinutePerLiter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercuryMinutesPerMilliliter(double millimetermercuryminutespermilliliter) => new FluidResistance(millimetermercuryminutespermilliliter, FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercurySecondsPerCubicCentimeter(double millimetermercurysecondspercubiccentimeter) => new FluidResistance(millimetermercurysecondspercubiccentimeter, FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercurySecondsPerCubicMeter(double millimetermercurysecondspercubicmeter) => new FluidResistance(millimetermercurysecondspercubicmeter, FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercurySecondsPerLiter(double millimetermercurysecondsperliter) => new FluidResistance(millimetermercurysecondsperliter, FluidResistanceUnit.MillimeterMercurySecondPerLiter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercurySecondsPerMilliliter(double millimetermercurysecondspermilliliter) => new FluidResistance(millimetermercurysecondspermilliliter, FluidResistanceUnit.MillimeterMercurySecondPerMilliliter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalMinutesPerCubicCentimeter(double pascalminutespercubiccentimeter) => new FluidResistance(pascalminutespercubiccentimeter, FluidResistanceUnit.PascalMinutePerCubicCentimeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalMinutesPerCubicMeter(double pascalminutespercubicmeter) => new FluidResistance(pascalminutespercubicmeter, FluidResistanceUnit.PascalMinutePerCubicMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalMinutesPerLiter(double pascalminutesperliter) => new FluidResistance(pascalminutesperliter, FluidResistanceUnit.PascalMinutePerLiter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalMinutesPerMilliliter(double pascalminutespermilliliter) => new FluidResistance(pascalminutespermilliliter, FluidResistanceUnit.PascalMinutePerMilliliter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalSecondsPerCubicCentimeter(double pascalsecondspercubiccentimeter) => new FluidResistance(pascalsecondspercubiccentimeter, FluidResistanceUnit.PascalSecondPerCubicCentimeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalSecondsPerCubicMeter(double pascalsecondspercubicmeter) => new FluidResistance(pascalsecondspercubicmeter, FluidResistanceUnit.PascalSecondPerCubicMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalSecondsPerLiter(double pascalsecondsperliter) => new FluidResistance(pascalsecondsperliter, FluidResistanceUnit.PascalSecondPerLiter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalSecondsPerMilliliter(double pascalsecondspermilliliter) => new FluidResistance(pascalsecondspermilliliter, FluidResistanceUnit.PascalSecondPerMilliliter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromWoodUnits(double woodunits) => new FluidResistance(woodunits, FluidResistanceUnit.WoodUnit); + + /// + /// Dynamically convert from value and unit enum to . + /// + /// Value to convert from. + /// Unit to convert from. + /// FluidResistance unit value. + public static FluidResistance From(double value, FluidResistanceUnit fromUnit) + { + return new FluidResistance(value, fromUnit); + } + + #endregion + + #region Conversion Methods + + /// + /// Convert to the unit representation . + /// + /// Value converted to the specified unit. + public double As(FluidResistanceUnit unit) => GetValueAs(unit); + + /// + /// Converts this FluidResistance to another FluidResistance with the unit representation . + /// + /// A FluidResistance with the specified unit. + public FluidResistance ToUnit(FluidResistanceUnit unit) + { + var convertedValue = GetValueAs(unit); + return new FluidResistance(convertedValue, unit); + } + + /// + /// Converts the current value + unit to the base unit. + /// This is typically the first step in converting from one unit to another. + /// + /// The value in the base unit representation. + private double GetValueInBaseUnit() + { + return Unit switch + { + FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth => _value * 1e-5, + FluidResistanceUnit.MegapascalSecondPerCubicMeter => _value * 1e6, + FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter => _value * 7.99934208e9, + FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter => _value * 7.99934208e3, + FluidResistanceUnit.MillimeterMercuryMinutePerLiter => _value * 7.99934208e6, + FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter => _value * 7.99934208e9, + FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter => _value * 1.33322368e8, + FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter => _value * 133.322368, + FluidResistanceUnit.MillimeterMercurySecondPerLiter => _value * 1.33322368e5, + FluidResistanceUnit.MillimeterMercurySecondPerMilliliter => _value * 1.33322368e8, + FluidResistanceUnit.PascalMinutePerCubicCentimeter => _value * 6e7, + FluidResistanceUnit.PascalMinutePerCubicMeter => _value * 60, + FluidResistanceUnit.PascalMinutePerLiter => _value * 6e4, + FluidResistanceUnit.PascalMinutePerMilliliter => _value * 6e7, + FluidResistanceUnit.PascalSecondPerCubicCentimeter => _value * 1e6, + FluidResistanceUnit.PascalSecondPerCubicMeter => _value, + FluidResistanceUnit.PascalSecondPerLiter => _value * 1e3, + FluidResistanceUnit.PascalSecondPerMilliliter => _value * 1e6, + FluidResistanceUnit.WoodUnit => _value * 7.99934208e6, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; + } + + private double GetValueAs(FluidResistanceUnit unit) + { + if (Unit == unit) + return _value; + + var baseUnitValue = GetValueInBaseUnit(); + + return unit switch + { + FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth => baseUnitValue / 1e-5, + FluidResistanceUnit.MegapascalSecondPerCubicMeter => baseUnitValue / 1e6, + FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter => baseUnitValue / 7.99934208e9, + FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter => baseUnitValue / 7.99934208e3, + FluidResistanceUnit.MillimeterMercuryMinutePerLiter => baseUnitValue / 7.99934208e6, + FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter => baseUnitValue / 7.99934208e9, + FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter => baseUnitValue / 1.33322368e8, + FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter => baseUnitValue / 133.322368, + FluidResistanceUnit.MillimeterMercurySecondPerLiter => baseUnitValue / 1.33322368e5, + FluidResistanceUnit.MillimeterMercurySecondPerMilliliter => baseUnitValue / 1.33322368e8, + FluidResistanceUnit.PascalMinutePerCubicCentimeter => baseUnitValue / 6e7, + FluidResistanceUnit.PascalMinutePerCubicMeter => baseUnitValue / 60, + FluidResistanceUnit.PascalMinutePerLiter => baseUnitValue / 6e4, + FluidResistanceUnit.PascalMinutePerMilliliter => baseUnitValue / 6e7, + FluidResistanceUnit.PascalSecondPerCubicCentimeter => baseUnitValue / 1e6, + FluidResistanceUnit.PascalSecondPerCubicMeter => baseUnitValue, + FluidResistanceUnit.PascalSecondPerLiter => baseUnitValue / 1e3, + FluidResistanceUnit.PascalSecondPerMilliliter => baseUnitValue / 1e6, + FluidResistanceUnit.WoodUnit => baseUnitValue / 7.99934208e6, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; + } + + #endregion + } +} + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/FluidResistanceUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/FluidResistanceUnit.g.cs new file mode 100644 index 0000000000..a32cb873c5 --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/FluidResistanceUnit.g.cs @@ -0,0 +1,53 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Units +{ + // Disable missing XML comment warnings for the generated unit enums. + #pragma warning disable 1591 + + public enum FluidResistanceUnit + { + /// https://en.wikipedia.org/wiki/Vascular_resistance + DyneSecondPerCentimeterToTheFifth = 6, + /// https://en.wikipedia.org/wiki/Vascular_resistance + MegapascalSecondPerCubicMeter = 7, + MillimeterMercuryMinutePerCubicCentimeter = 3, + MillimeterMercuryMinutePerCubicMeter = 5, + MillimeterMercuryMinutePerLiter = 2, + MillimeterMercuryMinutePerMilliliter = 9, + MillimeterMercurySecondPerCubicCentimeter = 8, + MillimeterMercurySecondPerCubicMeter = 10, + MillimeterMercurySecondPerLiter = 4, + MillimeterMercurySecondPerMilliliter = 1, + PascalMinutePerCubicCentimeter = 19, + PascalMinutePerCubicMeter = 16, + PascalMinutePerLiter = 15, + PascalMinutePerMilliliter = 12, + PascalSecondPerCubicCentimeter = 18, + PascalSecondPerCubicMeter = 13, + PascalSecondPerLiter = 11, + PascalSecondPerMilliliter = 20, + /// https://en.wikipedia.org/wiki/Vascular_resistance + WoodUnit = 17, + } + + #pragma warning restore 1591 +} diff --git a/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln b/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln index 686fcf0b76..ce0f3e87d9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln +++ b/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln @@ -96,6 +96,8 @@ Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "EnergyDensity", "EnergyDens EndProject Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "Entropy", "Entropy\Entropy.nfproj", "{816884bb-a5f6-5c07-967b-bb8f21d724b7}" EndProject +Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "FluidResistance", "FluidResistance\FluidResistance.nfproj", "{d19281dc-72f6-62a9-18d5-b845d6fd8d99}" +EndProject Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "Force", "Force\Force.nfproj", "{5517dacf-b1ff-6515-e5b6-b5081f92f407}" EndProject Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "ForceChangeRate", "ForceChangeRate\ForceChangeRate.nfproj", "{97ad732d-4ce5-2027-aabc-844002d29c23}" @@ -558,6 +560,12 @@ Global {816884bb-a5f6-5c07-967b-bb8f21d724b7}.Release|Any CPU.ActiveCfg = Release|Any CPU {816884bb-a5f6-5c07-967b-bb8f21d724b7}.Release|Any CPU.Build.0 = Release|Any CPU {816884bb-a5f6-5c07-967b-bb8f21d724b7}.Release|Any CPU.Deploy.0 = Release|Any CPU +{d19281dc-72f6-62a9-18d5-b845d6fd8d99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU +{d19281dc-72f6-62a9-18d5-b845d6fd8d99}.Debug|Any CPU.Build.0 = Debug|Any CPU +{d19281dc-72f6-62a9-18d5-b845d6fd8d99}.Debug|Any CPU.Deploy.0 = Debug|Any CPU +{d19281dc-72f6-62a9-18d5-b845d6fd8d99}.Release|Any CPU.ActiveCfg = Release|Any CPU +{d19281dc-72f6-62a9-18d5-b845d6fd8d99}.Release|Any CPU.Build.0 = Release|Any CPU +{d19281dc-72f6-62a9-18d5-b845d6fd8d99}.Release|Any CPU.Deploy.0 = Release|Any CPU {5517dacf-b1ff-6515-e5b6-b5081f92f407}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5517dacf-b1ff-6515-e5b6-b5081f92f407}.Debug|Any CPU.Build.0 = Debug|Any CPU {5517dacf-b1ff-6515-e5b6-b5081f92f407}.Debug|Any CPU.Deploy.0 = Debug|Any CPU diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToFluidResistanceExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToFluidResistanceExtensionsTest.g.cs new file mode 100644 index 0000000000..900684db11 --- /dev/null +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToFluidResistanceExtensionsTest.g.cs @@ -0,0 +1,104 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using UnitsNet.NumberExtensions.NumberToFluidResistance; +using Xunit; + +namespace UnitsNet.Tests +{ + public class NumberToFluidResistanceExtensionsTests + { + [Fact] + public void NumberToDyneSecondsPerCentimeterToTheFifthTest() => + Assert.Equal(FluidResistance.FromDyneSecondsPerCentimeterToTheFifth(2), 2.DyneSecondsPerCentimeterToTheFifth()); + + [Fact] + public void NumberToMegapascalSecondsPerCubicMeterTest() => + Assert.Equal(FluidResistance.FromMegapascalSecondsPerCubicMeter(2), 2.MegapascalSecondsPerCubicMeter()); + + [Fact] + public void NumberToMillimeterMercuryMinutesPerCubicCentimeterTest() => + Assert.Equal(FluidResistance.FromMillimeterMercuryMinutesPerCubicCentimeter(2), 2.MillimeterMercuryMinutesPerCubicCentimeter()); + + [Fact] + public void NumberToMillimeterMercuryMinutesPerCubicMeterTest() => + Assert.Equal(FluidResistance.FromMillimeterMercuryMinutesPerCubicMeter(2), 2.MillimeterMercuryMinutesPerCubicMeter()); + + [Fact] + public void NumberToMillimeterMercuryMinutesPerLiterTest() => + Assert.Equal(FluidResistance.FromMillimeterMercuryMinutesPerLiter(2), 2.MillimeterMercuryMinutesPerLiter()); + + [Fact] + public void NumberToMillimeterMercuryMinutesPerMilliliterTest() => + Assert.Equal(FluidResistance.FromMillimeterMercuryMinutesPerMilliliter(2), 2.MillimeterMercuryMinutesPerMilliliter()); + + [Fact] + public void NumberToMillimeterMercurySecondsPerCubicCentimeterTest() => + Assert.Equal(FluidResistance.FromMillimeterMercurySecondsPerCubicCentimeter(2), 2.MillimeterMercurySecondsPerCubicCentimeter()); + + [Fact] + public void NumberToMillimeterMercurySecondsPerCubicMeterTest() => + Assert.Equal(FluidResistance.FromMillimeterMercurySecondsPerCubicMeter(2), 2.MillimeterMercurySecondsPerCubicMeter()); + + [Fact] + public void NumberToMillimeterMercurySecondsPerLiterTest() => + Assert.Equal(FluidResistance.FromMillimeterMercurySecondsPerLiter(2), 2.MillimeterMercurySecondsPerLiter()); + + [Fact] + public void NumberToMillimeterMercurySecondsPerMilliliterTest() => + Assert.Equal(FluidResistance.FromMillimeterMercurySecondsPerMilliliter(2), 2.MillimeterMercurySecondsPerMilliliter()); + + [Fact] + public void NumberToPascalMinutesPerCubicCentimeterTest() => + Assert.Equal(FluidResistance.FromPascalMinutesPerCubicCentimeter(2), 2.PascalMinutesPerCubicCentimeter()); + + [Fact] + public void NumberToPascalMinutesPerCubicMeterTest() => + Assert.Equal(FluidResistance.FromPascalMinutesPerCubicMeter(2), 2.PascalMinutesPerCubicMeter()); + + [Fact] + public void NumberToPascalMinutesPerLiterTest() => + Assert.Equal(FluidResistance.FromPascalMinutesPerLiter(2), 2.PascalMinutesPerLiter()); + + [Fact] + public void NumberToPascalMinutesPerMilliliterTest() => + Assert.Equal(FluidResistance.FromPascalMinutesPerMilliliter(2), 2.PascalMinutesPerMilliliter()); + + [Fact] + public void NumberToPascalSecondsPerCubicCentimeterTest() => + Assert.Equal(FluidResistance.FromPascalSecondsPerCubicCentimeter(2), 2.PascalSecondsPerCubicCentimeter()); + + [Fact] + public void NumberToPascalSecondsPerCubicMeterTest() => + Assert.Equal(FluidResistance.FromPascalSecondsPerCubicMeter(2), 2.PascalSecondsPerCubicMeter()); + + [Fact] + public void NumberToPascalSecondsPerLiterTest() => + Assert.Equal(FluidResistance.FromPascalSecondsPerLiter(2), 2.PascalSecondsPerLiter()); + + [Fact] + public void NumberToPascalSecondsPerMilliliterTest() => + Assert.Equal(FluidResistance.FromPascalSecondsPerMilliliter(2), 2.PascalSecondsPerMilliliter()); + + [Fact] + public void NumberToWoodUnitsTest() => + Assert.Equal(FluidResistance.FromWoodUnits(2), 2.WoodUnits()); + + } +} diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToFluidResistanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToFluidResistanceExtensions.g.cs new file mode 100644 index 0000000000..6b8d4a08db --- /dev/null +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToFluidResistanceExtensions.g.cs @@ -0,0 +1,188 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; + +#if NET7_0_OR_GREATER +using System.Numerics; +#endif + +#nullable enable + +namespace UnitsNet.NumberExtensions.NumberToFluidResistance +{ + /// + /// A number to FluidResistance Extensions + /// + public static class NumberToFluidResistanceExtensions + { + /// + public static FluidResistance DyneSecondsPerCentimeterToTheFifth(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromDyneSecondsPerCentimeterToTheFifth(Convert.ToDouble(value)); + + /// + public static FluidResistance MegapascalSecondsPerCubicMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromMegapascalSecondsPerCubicMeter(Convert.ToDouble(value)); + + /// + public static FluidResistance MillimeterMercuryMinutesPerCubicCentimeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromMillimeterMercuryMinutesPerCubicCentimeter(Convert.ToDouble(value)); + + /// + public static FluidResistance MillimeterMercuryMinutesPerCubicMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromMillimeterMercuryMinutesPerCubicMeter(Convert.ToDouble(value)); + + /// + public static FluidResistance MillimeterMercuryMinutesPerLiter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromMillimeterMercuryMinutesPerLiter(Convert.ToDouble(value)); + + /// + public static FluidResistance MillimeterMercuryMinutesPerMilliliter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromMillimeterMercuryMinutesPerMilliliter(Convert.ToDouble(value)); + + /// + public static FluidResistance MillimeterMercurySecondsPerCubicCentimeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromMillimeterMercurySecondsPerCubicCentimeter(Convert.ToDouble(value)); + + /// + public static FluidResistance MillimeterMercurySecondsPerCubicMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromMillimeterMercurySecondsPerCubicMeter(Convert.ToDouble(value)); + + /// + public static FluidResistance MillimeterMercurySecondsPerLiter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromMillimeterMercurySecondsPerLiter(Convert.ToDouble(value)); + + /// + public static FluidResistance MillimeterMercurySecondsPerMilliliter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromMillimeterMercurySecondsPerMilliliter(Convert.ToDouble(value)); + + /// + public static FluidResistance PascalMinutesPerCubicCentimeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromPascalMinutesPerCubicCentimeter(Convert.ToDouble(value)); + + /// + public static FluidResistance PascalMinutesPerCubicMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromPascalMinutesPerCubicMeter(Convert.ToDouble(value)); + + /// + public static FluidResistance PascalMinutesPerLiter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromPascalMinutesPerLiter(Convert.ToDouble(value)); + + /// + public static FluidResistance PascalMinutesPerMilliliter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromPascalMinutesPerMilliliter(Convert.ToDouble(value)); + + /// + public static FluidResistance PascalSecondsPerCubicCentimeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromPascalSecondsPerCubicCentimeter(Convert.ToDouble(value)); + + /// + public static FluidResistance PascalSecondsPerCubicMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromPascalSecondsPerCubicMeter(Convert.ToDouble(value)); + + /// + public static FluidResistance PascalSecondsPerLiter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromPascalSecondsPerLiter(Convert.ToDouble(value)); + + /// + public static FluidResistance PascalSecondsPerMilliliter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromPascalSecondsPerMilliliter(Convert.ToDouble(value)); + + /// + public static FluidResistance WoodUnits(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => FluidResistance.FromWoodUnits(Convert.ToDouble(value)); + + } +} diff --git a/UnitsNet.Tests/CustomCode/FluidResistanceTests.cs b/UnitsNet.Tests/CustomCode/FluidResistanceTests.cs new file mode 100644 index 0000000000..c0521d9c2e --- /dev/null +++ b/UnitsNet.Tests/CustomCode/FluidResistanceTests.cs @@ -0,0 +1,49 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; + +namespace UnitsNet.Tests.CustomCode +{ + public class FluidResistanceTests : FluidResistanceTestsBase + { + // https://www.vcalc.com/wiki/Fluid-Resistance-Unit-Conversion + + protected override bool SupportsSIUnitSystem => false; + protected override double DyneSecondsPerCentimeterToTheFifthInOnePascalSecondPerCubicMeter => 1e5; // dyn·s/cm⁵ + protected override double MegapascalSecondsPerCubicMeterInOnePascalSecondPerCubicMeter => 1e-6; // MPa·s/m³ + protected override double MillimeterMercuryMinutesPerCubicCentimeterInOnePascalSecondPerCubicMeter => 1.25010625903202e-10; // mmHg·min/cm³ + protected override double MillimeterMercuryMinutesPerCubicMeterInOnePascalSecondPerCubicMeter => 1.25010625903202e-4; // mmHg·min/m³ + protected override double MillimeterMercuryMinutesPerLiterInOnePascalSecondPerCubicMeter => 1.25010625903202e-7; // mmHg·min/l + protected override double MillimeterMercuryMinutesPerMilliliterInOnePascalSecondPerCubicMeter => 1.25010625903202e-10; // mmHg·min/ml + protected override double MillimeterMercurySecondsPerCubicCentimeterInOnePascalSecondPerCubicMeter => 7.5006375541921e-9; // mmHg·s/cm³ + protected override double MillimeterMercurySecondsPerCubicMeterInOnePascalSecondPerCubicMeter => 7.50063755419211e-3; // mmHg·s/m³ + protected override double MillimeterMercurySecondsPerLiterInOnePascalSecondPerCubicMeter => 7.50063755419211e-6; // mmHg·s/l + protected override double MillimeterMercurySecondsPerMilliliterInOnePascalSecondPerCubicMeter => 7.5006375541921e-9; // mmHg·s/ml + protected override double PascalMinutesPerCubicCentimeterInOnePascalSecondPerCubicMeter => 1.66666666666667e-8; // Pa·min/cm³ + protected override double PascalMinutesPerCubicMeterInOnePascalSecondPerCubicMeter => 1.66666666666667e-2; // Pa·min/m³ + protected override double PascalMinutesPerLiterInOnePascalSecondPerCubicMeter => 1.66666666666667e-5; // Pa·min/l + protected override double PascalMinutesPerMilliliterInOnePascalSecondPerCubicMeter => 1.66666666666667e-8; // Pa·min/ml + protected override double PascalSecondsPerCubicCentimeterInOnePascalSecondPerCubicMeter => 1e-6; // Pa·s/cm³ + protected override double PascalSecondsPerCubicMeterInOnePascalSecondPerCubicMeter => 1; // Pa·s/m³ + protected override double PascalSecondsPerLiterInOnePascalSecondPerCubicMeter => 1e-3; // Pa·s/l + protected override double PascalSecondsPerMilliliterInOnePascalSecondPerCubicMeter => 1e-6; // Pa·s/ml + protected override double WoodUnitsInOnePascalSecondPerCubicMeter => 1.25010625903202e-7; // WU + } +} diff --git a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs index 0966041166..36f623126d 100644 --- a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs +++ b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs @@ -81,6 +81,7 @@ void Assertion(int expectedValue, Enum expectedUnit, IQuantity quantity) Assertion(3, EnergyUnit.WattHour, Quantity.From(3, EnergyUnit.WattHour)); Assertion(3, EnergyDensityUnit.WattHourPerCubicMeter, Quantity.From(3, EnergyDensityUnit.WattHourPerCubicMeter)); Assertion(3, EntropyUnit.MegajoulePerKelvin, Quantity.From(3, EntropyUnit.MegajoulePerKelvin)); + Assertion(3, FluidResistanceUnit.WoodUnit, Quantity.From(3, FluidResistanceUnit.WoodUnit)); Assertion(3, ForceUnit.TonneForce, Quantity.From(3, ForceUnit.TonneForce)); Assertion(3, ForceChangeRateUnit.PoundForcePerSecond, Quantity.From(3, ForceChangeRateUnit.PoundForcePerSecond)); Assertion(3, ForcePerLengthUnit.TonneForcePerMillimeter, Quantity.From(3, ForcePerLengthUnit.TonneForcePerMillimeter)); @@ -222,6 +223,7 @@ public void QuantityInfo_IsSameAsStaticInfoProperty() Assertion(Energy.Info, Energy.Zero); Assertion(EnergyDensity.Info, EnergyDensity.Zero); Assertion(Entropy.Info, Entropy.Zero); + Assertion(FluidResistance.Info, FluidResistance.Zero); Assertion(Force.Info, Force.Zero); Assertion(ForceChangeRate.Info, ForceChangeRate.Zero); Assertion(ForcePerLength.Info, ForcePerLength.Zero); @@ -363,6 +365,7 @@ public void Dimensions_IsSameAsStaticBaseDimensions() Assertion(Energy.BaseDimensions, Energy.Zero); Assertion(EnergyDensity.BaseDimensions, EnergyDensity.Zero); Assertion(Entropy.BaseDimensions, Entropy.Zero); + Assertion(FluidResistance.BaseDimensions, FluidResistance.Zero); Assertion(Force.BaseDimensions, Force.Zero); Assertion(ForceChangeRate.BaseDimensions, ForceChangeRate.Zero); Assertion(ForcePerLength.BaseDimensions, ForcePerLength.Zero); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs new file mode 100644 index 0000000000..fb270794fb --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FluidResistanceTestsBase.g.cs @@ -0,0 +1,1851 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading; +using UnitsNet.Tests.TestsBase; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of FluidResistance. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class FluidResistanceTestsBase : QuantityTestsBase + { + protected abstract double DyneSecondsPerCentimeterToTheFifthInOnePascalSecondPerCubicMeter { get; } + protected abstract double MegapascalSecondsPerCubicMeterInOnePascalSecondPerCubicMeter { get; } + protected abstract double MillimeterMercuryMinutesPerCubicCentimeterInOnePascalSecondPerCubicMeter { get; } + protected abstract double MillimeterMercuryMinutesPerCubicMeterInOnePascalSecondPerCubicMeter { get; } + protected abstract double MillimeterMercuryMinutesPerLiterInOnePascalSecondPerCubicMeter { get; } + protected abstract double MillimeterMercuryMinutesPerMilliliterInOnePascalSecondPerCubicMeter { get; } + protected abstract double MillimeterMercurySecondsPerCubicCentimeterInOnePascalSecondPerCubicMeter { get; } + protected abstract double MillimeterMercurySecondsPerCubicMeterInOnePascalSecondPerCubicMeter { get; } + protected abstract double MillimeterMercurySecondsPerLiterInOnePascalSecondPerCubicMeter { get; } + protected abstract double MillimeterMercurySecondsPerMilliliterInOnePascalSecondPerCubicMeter { get; } + protected abstract double PascalMinutesPerCubicCentimeterInOnePascalSecondPerCubicMeter { get; } + protected abstract double PascalMinutesPerCubicMeterInOnePascalSecondPerCubicMeter { get; } + protected abstract double PascalMinutesPerLiterInOnePascalSecondPerCubicMeter { get; } + protected abstract double PascalMinutesPerMilliliterInOnePascalSecondPerCubicMeter { get; } + protected abstract double PascalSecondsPerCubicCentimeterInOnePascalSecondPerCubicMeter { get; } + protected abstract double PascalSecondsPerCubicMeterInOnePascalSecondPerCubicMeter { get; } + protected abstract double PascalSecondsPerLiterInOnePascalSecondPerCubicMeter { get; } + protected abstract double PascalSecondsPerMilliliterInOnePascalSecondPerCubicMeter { get; } + protected abstract double WoodUnitsInOnePascalSecondPerCubicMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DyneSecondsPerCentimeterToTheFifthTolerance { get { return 1e-5; } } + protected virtual double MegapascalSecondsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double MillimeterMercuryMinutesPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double MillimeterMercuryMinutesPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double MillimeterMercuryMinutesPerLiterTolerance { get { return 1e-5; } } + protected virtual double MillimeterMercuryMinutesPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double MillimeterMercurySecondsPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double MillimeterMercurySecondsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double MillimeterMercurySecondsPerLiterTolerance { get { return 1e-5; } } + protected virtual double MillimeterMercurySecondsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double PascalMinutesPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double PascalMinutesPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double PascalMinutesPerLiterTolerance { get { return 1e-5; } } + protected virtual double PascalMinutesPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double PascalSecondsPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double PascalSecondsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double PascalSecondsPerLiterTolerance { get { return 1e-5; } } + protected virtual double PascalSecondsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double WoodUnitsTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(FluidResistanceUnit unit) + { + return unit switch + { + FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth => (DyneSecondsPerCentimeterToTheFifthInOnePascalSecondPerCubicMeter, DyneSecondsPerCentimeterToTheFifthTolerance), + FluidResistanceUnit.MegapascalSecondPerCubicMeter => (MegapascalSecondsPerCubicMeterInOnePascalSecondPerCubicMeter, MegapascalSecondsPerCubicMeterTolerance), + FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter => (MillimeterMercuryMinutesPerCubicCentimeterInOnePascalSecondPerCubicMeter, MillimeterMercuryMinutesPerCubicCentimeterTolerance), + FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter => (MillimeterMercuryMinutesPerCubicMeterInOnePascalSecondPerCubicMeter, MillimeterMercuryMinutesPerCubicMeterTolerance), + FluidResistanceUnit.MillimeterMercuryMinutePerLiter => (MillimeterMercuryMinutesPerLiterInOnePascalSecondPerCubicMeter, MillimeterMercuryMinutesPerLiterTolerance), + FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter => (MillimeterMercuryMinutesPerMilliliterInOnePascalSecondPerCubicMeter, MillimeterMercuryMinutesPerMilliliterTolerance), + FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter => (MillimeterMercurySecondsPerCubicCentimeterInOnePascalSecondPerCubicMeter, MillimeterMercurySecondsPerCubicCentimeterTolerance), + FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter => (MillimeterMercurySecondsPerCubicMeterInOnePascalSecondPerCubicMeter, MillimeterMercurySecondsPerCubicMeterTolerance), + FluidResistanceUnit.MillimeterMercurySecondPerLiter => (MillimeterMercurySecondsPerLiterInOnePascalSecondPerCubicMeter, MillimeterMercurySecondsPerLiterTolerance), + FluidResistanceUnit.MillimeterMercurySecondPerMilliliter => (MillimeterMercurySecondsPerMilliliterInOnePascalSecondPerCubicMeter, MillimeterMercurySecondsPerMilliliterTolerance), + FluidResistanceUnit.PascalMinutePerCubicCentimeter => (PascalMinutesPerCubicCentimeterInOnePascalSecondPerCubicMeter, PascalMinutesPerCubicCentimeterTolerance), + FluidResistanceUnit.PascalMinutePerCubicMeter => (PascalMinutesPerCubicMeterInOnePascalSecondPerCubicMeter, PascalMinutesPerCubicMeterTolerance), + FluidResistanceUnit.PascalMinutePerLiter => (PascalMinutesPerLiterInOnePascalSecondPerCubicMeter, PascalMinutesPerLiterTolerance), + FluidResistanceUnit.PascalMinutePerMilliliter => (PascalMinutesPerMilliliterInOnePascalSecondPerCubicMeter, PascalMinutesPerMilliliterTolerance), + FluidResistanceUnit.PascalSecondPerCubicCentimeter => (PascalSecondsPerCubicCentimeterInOnePascalSecondPerCubicMeter, PascalSecondsPerCubicCentimeterTolerance), + FluidResistanceUnit.PascalSecondPerCubicMeter => (PascalSecondsPerCubicMeterInOnePascalSecondPerCubicMeter, PascalSecondsPerCubicMeterTolerance), + FluidResistanceUnit.PascalSecondPerLiter => (PascalSecondsPerLiterInOnePascalSecondPerCubicMeter, PascalSecondsPerLiterTolerance), + FluidResistanceUnit.PascalSecondPerMilliliter => (PascalSecondsPerMilliliterInOnePascalSecondPerCubicMeter, PascalSecondsPerMilliliterTolerance), + FluidResistanceUnit.WoodUnit => (WoodUnitsInOnePascalSecondPerCubicMeter, WoodUnitsTolerance), + _ => throw new NotSupportedException() + }; + } + + public static IEnumerable UnitTypes = new List + { + new object[] { FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth }, + new object[] { FluidResistanceUnit.MegapascalSecondPerCubicMeter }, + new object[] { FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter }, + new object[] { FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter }, + new object[] { FluidResistanceUnit.MillimeterMercuryMinutePerLiter }, + new object[] { FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter }, + new object[] { FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter }, + new object[] { FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter }, + new object[] { FluidResistanceUnit.MillimeterMercurySecondPerLiter }, + new object[] { FluidResistanceUnit.MillimeterMercurySecondPerMilliliter }, + new object[] { FluidResistanceUnit.PascalMinutePerCubicCentimeter }, + new object[] { FluidResistanceUnit.PascalMinutePerCubicMeter }, + new object[] { FluidResistanceUnit.PascalMinutePerLiter }, + new object[] { FluidResistanceUnit.PascalMinutePerMilliliter }, + new object[] { FluidResistanceUnit.PascalSecondPerCubicCentimeter }, + new object[] { FluidResistanceUnit.PascalSecondPerCubicMeter }, + new object[] { FluidResistanceUnit.PascalSecondPerLiter }, + new object[] { FluidResistanceUnit.PascalSecondPerMilliliter }, + new object[] { FluidResistanceUnit.WoodUnit }, + }; + + [Fact] + public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() + { + var quantity = new FluidResistance(); + Assert.Equal(0, quantity.Value); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicMeter, quantity.Unit); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new FluidResistance(double.PositiveInfinity, FluidResistanceUnit.PascalSecondPerCubicMeter)); + Assert.Throws(() => new FluidResistance(double.NegativeInfinity, FluidResistanceUnit.PascalSecondPerCubicMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new FluidResistance(double.NaN, FluidResistanceUnit.PascalSecondPerCubicMeter)); + } + + [Fact] + public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException() + { + Assert.Throws(() => new FluidResistance(value: 1, unitSystem: null)); + } + + //[Fact] + //public void Ctor_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() + //{ + // Func TestCode = () => new FluidResistance(value: 1, unitSystem: UnitSystem.SI); + // if (SupportsSIUnitSystem) + // { + // var quantity = (FluidResistance) TestCode(); + // Assert.Equal(1, quantity.Value); + // } + // else + // { + // Assert.Throws(TestCode); + // } + //} + + [Fact] + public void FluidResistance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() + { + var quantity = new FluidResistance(1, FluidResistanceUnit.PascalSecondPerCubicMeter); + + QuantityInfo quantityInfo = quantity.QuantityInfo; + + Assert.Equal(FluidResistance.Zero, quantityInfo.Zero); + Assert.Equal("FluidResistance", quantityInfo.Name); + + var units = EnumUtils.GetEnumValues().OrderBy(x => x.ToString()).ToArray(); + var unitNames = units.Select(x => x.ToString()); + } + + [Fact] + public void PascalSecondPerCubicMeterToFluidResistanceUnits() + { + FluidResistance pascalsecondpercubicmeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); + AssertEx.EqualTolerance(DyneSecondsPerCentimeterToTheFifthInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.DyneSecondsPerCentimeterToTheFifth, DyneSecondsPerCentimeterToTheFifthTolerance); + AssertEx.EqualTolerance(MegapascalSecondsPerCubicMeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.MegapascalSecondsPerCubicMeter, MegapascalSecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(MillimeterMercuryMinutesPerCubicCentimeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.MillimeterMercuryMinutesPerCubicCentimeter, MillimeterMercuryMinutesPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(MillimeterMercuryMinutesPerCubicMeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.MillimeterMercuryMinutesPerCubicMeter, MillimeterMercuryMinutesPerCubicMeterTolerance); + AssertEx.EqualTolerance(MillimeterMercuryMinutesPerLiterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.MillimeterMercuryMinutesPerLiter, MillimeterMercuryMinutesPerLiterTolerance); + AssertEx.EqualTolerance(MillimeterMercuryMinutesPerMilliliterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.MillimeterMercuryMinutesPerMilliliter, MillimeterMercuryMinutesPerMilliliterTolerance); + AssertEx.EqualTolerance(MillimeterMercurySecondsPerCubicCentimeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.MillimeterMercurySecondsPerCubicCentimeter, MillimeterMercurySecondsPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(MillimeterMercurySecondsPerCubicMeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.MillimeterMercurySecondsPerCubicMeter, MillimeterMercurySecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(MillimeterMercurySecondsPerLiterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.MillimeterMercurySecondsPerLiter, MillimeterMercurySecondsPerLiterTolerance); + AssertEx.EqualTolerance(MillimeterMercurySecondsPerMilliliterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.MillimeterMercurySecondsPerMilliliter, MillimeterMercurySecondsPerMilliliterTolerance); + AssertEx.EqualTolerance(PascalMinutesPerCubicCentimeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.PascalMinutesPerCubicCentimeter, PascalMinutesPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(PascalMinutesPerCubicMeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.PascalMinutesPerCubicMeter, PascalMinutesPerCubicMeterTolerance); + AssertEx.EqualTolerance(PascalMinutesPerLiterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.PascalMinutesPerLiter, PascalMinutesPerLiterTolerance); + AssertEx.EqualTolerance(PascalMinutesPerMilliliterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.PascalMinutesPerMilliliter, PascalMinutesPerMilliliterTolerance); + AssertEx.EqualTolerance(PascalSecondsPerCubicCentimeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.PascalSecondsPerCubicCentimeter, PascalSecondsPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(PascalSecondsPerCubicMeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(PascalSecondsPerLiterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.PascalSecondsPerLiter, PascalSecondsPerLiterTolerance); + AssertEx.EqualTolerance(PascalSecondsPerMilliliterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.PascalSecondsPerMilliliter, PascalSecondsPerMilliliterTolerance); + AssertEx.EqualTolerance(WoodUnitsInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.WoodUnits, WoodUnitsTolerance); + } + + [Fact] + public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() + { + var quantity00 = FluidResistance.From(1, FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth); + AssertEx.EqualTolerance(1, quantity00.DyneSecondsPerCentimeterToTheFifth, DyneSecondsPerCentimeterToTheFifthTolerance); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, quantity00.Unit); + + var quantity01 = FluidResistance.From(1, FluidResistanceUnit.MegapascalSecondPerCubicMeter); + AssertEx.EqualTolerance(1, quantity01.MegapascalSecondsPerCubicMeter, MegapascalSecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MegapascalSecondPerCubicMeter, quantity01.Unit); + + var quantity02 = FluidResistance.From(1, FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter); + AssertEx.EqualTolerance(1, quantity02.MillimeterMercuryMinutesPerCubicCentimeter, MillimeterMercuryMinutesPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, quantity02.Unit); + + var quantity03 = FluidResistance.From(1, FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter); + AssertEx.EqualTolerance(1, quantity03.MillimeterMercuryMinutesPerCubicMeter, MillimeterMercuryMinutesPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, quantity03.Unit); + + var quantity04 = FluidResistance.From(1, FluidResistanceUnit.MillimeterMercuryMinutePerLiter); + AssertEx.EqualTolerance(1, quantity04.MillimeterMercuryMinutesPerLiter, MillimeterMercuryMinutesPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerLiter, quantity04.Unit); + + var quantity05 = FluidResistance.From(1, FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter); + AssertEx.EqualTolerance(1, quantity05.MillimeterMercuryMinutesPerMilliliter, MillimeterMercuryMinutesPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, quantity05.Unit); + + var quantity06 = FluidResistance.From(1, FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter); + AssertEx.EqualTolerance(1, quantity06.MillimeterMercurySecondsPerCubicCentimeter, MillimeterMercurySecondsPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, quantity06.Unit); + + var quantity07 = FluidResistance.From(1, FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter); + AssertEx.EqualTolerance(1, quantity07.MillimeterMercurySecondsPerCubicMeter, MillimeterMercurySecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, quantity07.Unit); + + var quantity08 = FluidResistance.From(1, FluidResistanceUnit.MillimeterMercurySecondPerLiter); + AssertEx.EqualTolerance(1, quantity08.MillimeterMercurySecondsPerLiter, MillimeterMercurySecondsPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerLiter, quantity08.Unit); + + var quantity09 = FluidResistance.From(1, FluidResistanceUnit.MillimeterMercurySecondPerMilliliter); + AssertEx.EqualTolerance(1, quantity09.MillimeterMercurySecondsPerMilliliter, MillimeterMercurySecondsPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, quantity09.Unit); + + var quantity10 = FluidResistance.From(1, FluidResistanceUnit.PascalMinutePerCubicCentimeter); + AssertEx.EqualTolerance(1, quantity10.PascalMinutesPerCubicCentimeter, PascalMinutesPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicCentimeter, quantity10.Unit); + + var quantity11 = FluidResistance.From(1, FluidResistanceUnit.PascalMinutePerCubicMeter); + AssertEx.EqualTolerance(1, quantity11.PascalMinutesPerCubicMeter, PascalMinutesPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicMeter, quantity11.Unit); + + var quantity12 = FluidResistance.From(1, FluidResistanceUnit.PascalMinutePerLiter); + AssertEx.EqualTolerance(1, quantity12.PascalMinutesPerLiter, PascalMinutesPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerLiter, quantity12.Unit); + + var quantity13 = FluidResistance.From(1, FluidResistanceUnit.PascalMinutePerMilliliter); + AssertEx.EqualTolerance(1, quantity13.PascalMinutesPerMilliliter, PascalMinutesPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerMilliliter, quantity13.Unit); + + var quantity14 = FluidResistance.From(1, FluidResistanceUnit.PascalSecondPerCubicCentimeter); + AssertEx.EqualTolerance(1, quantity14.PascalSecondsPerCubicCentimeter, PascalSecondsPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicCentimeter, quantity14.Unit); + + var quantity15 = FluidResistance.From(1, FluidResistanceUnit.PascalSecondPerCubicMeter); + AssertEx.EqualTolerance(1, quantity15.PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicMeter, quantity15.Unit); + + var quantity16 = FluidResistance.From(1, FluidResistanceUnit.PascalSecondPerLiter); + AssertEx.EqualTolerance(1, quantity16.PascalSecondsPerLiter, PascalSecondsPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerLiter, quantity16.Unit); + + var quantity17 = FluidResistance.From(1, FluidResistanceUnit.PascalSecondPerMilliliter); + AssertEx.EqualTolerance(1, quantity17.PascalSecondsPerMilliliter, PascalSecondsPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerMilliliter, quantity17.Unit); + + var quantity18 = FluidResistance.From(1, FluidResistanceUnit.WoodUnit); + AssertEx.EqualTolerance(1, quantity18.WoodUnits, WoodUnitsTolerance); + Assert.Equal(FluidResistanceUnit.WoodUnit, quantity18.Unit); + + } + + [Fact] + public void FromPascalSecondsPerCubicMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => FluidResistance.FromPascalSecondsPerCubicMeter(double.PositiveInfinity)); + Assert.Throws(() => FluidResistance.FromPascalSecondsPerCubicMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromPascalSecondsPerCubicMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => FluidResistance.FromPascalSecondsPerCubicMeter(double.NaN)); + } + + [Fact] + public void As() + { + var pascalsecondpercubicmeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); + AssertEx.EqualTolerance(DyneSecondsPerCentimeterToTheFifthInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth), DyneSecondsPerCentimeterToTheFifthTolerance); + AssertEx.EqualTolerance(MegapascalSecondsPerCubicMeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.MegapascalSecondPerCubicMeter), MegapascalSecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(MillimeterMercuryMinutesPerCubicCentimeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter), MillimeterMercuryMinutesPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(MillimeterMercuryMinutesPerCubicMeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter), MillimeterMercuryMinutesPerCubicMeterTolerance); + AssertEx.EqualTolerance(MillimeterMercuryMinutesPerLiterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.MillimeterMercuryMinutePerLiter), MillimeterMercuryMinutesPerLiterTolerance); + AssertEx.EqualTolerance(MillimeterMercuryMinutesPerMilliliterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter), MillimeterMercuryMinutesPerMilliliterTolerance); + AssertEx.EqualTolerance(MillimeterMercurySecondsPerCubicCentimeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter), MillimeterMercurySecondsPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(MillimeterMercurySecondsPerCubicMeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter), MillimeterMercurySecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(MillimeterMercurySecondsPerLiterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.MillimeterMercurySecondPerLiter), MillimeterMercurySecondsPerLiterTolerance); + AssertEx.EqualTolerance(MillimeterMercurySecondsPerMilliliterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter), MillimeterMercurySecondsPerMilliliterTolerance); + AssertEx.EqualTolerance(PascalMinutesPerCubicCentimeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.PascalMinutePerCubicCentimeter), PascalMinutesPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(PascalMinutesPerCubicMeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.PascalMinutePerCubicMeter), PascalMinutesPerCubicMeterTolerance); + AssertEx.EqualTolerance(PascalMinutesPerLiterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.PascalMinutePerLiter), PascalMinutesPerLiterTolerance); + AssertEx.EqualTolerance(PascalMinutesPerMilliliterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.PascalMinutePerMilliliter), PascalMinutesPerMilliliterTolerance); + AssertEx.EqualTolerance(PascalSecondsPerCubicCentimeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.PascalSecondPerCubicCentimeter), PascalSecondsPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(PascalSecondsPerCubicMeterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.PascalSecondPerCubicMeter), PascalSecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(PascalSecondsPerLiterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.PascalSecondPerLiter), PascalSecondsPerLiterTolerance); + AssertEx.EqualTolerance(PascalSecondsPerMilliliterInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.PascalSecondPerMilliliter), PascalSecondsPerMilliliterTolerance); + AssertEx.EqualTolerance(WoodUnitsInOnePascalSecondPerCubicMeter, pascalsecondpercubicmeter.As(FluidResistanceUnit.WoodUnit), WoodUnitsTolerance); + } + + //[Fact] + //public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() + //{ + // var quantity = new FluidResistance(value: 1, unit: FluidResistance.BaseUnit); + // Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); + + // if (SupportsSIUnitSystem) + // { + // var value = Convert.ToDouble(AsWithSIUnitSystem()); + // Assert.Equal(1, value); + // } + // else + // { + // Assert.Throws(AsWithSIUnitSystem); + // } + //} + + [Fact] + public void Parse() + { + try + { + var parsed = FluidResistance.Parse("1 dyn·s/cm⁵", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.DyneSecondsPerCentimeterToTheFifth, DyneSecondsPerCentimeterToTheFifthTolerance); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 dyn·s·cm⁻⁵", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.DyneSecondsPerCentimeterToTheFifth, DyneSecondsPerCentimeterToTheFifthTolerance); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 дин·с/см⁵", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.DyneSecondsPerCentimeterToTheFifth, DyneSecondsPerCentimeterToTheFifthTolerance); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 дин·с·см⁻⁵", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.DyneSecondsPerCentimeterToTheFifth, DyneSecondsPerCentimeterToTheFifthTolerance); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 MPa·s/m³", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MegapascalSecondsPerCubicMeter, MegapascalSecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MegapascalSecondPerCubicMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 МПа·с/м³", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.MegapascalSecondsPerCubicMeter, MegapascalSecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MegapascalSecondPerCubicMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 mmHg·min/cm³", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerCubicCentimeter, MillimeterMercuryMinutesPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 мм рт.ст·мин/см³", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerCubicCentimeter, MillimeterMercuryMinutesPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 mmHg·min/m³", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerCubicMeter, MillimeterMercuryMinutesPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 мм рт.ст·мин/м³", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerCubicMeter, MillimeterMercuryMinutesPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 mmHg·min/l", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerLiter, MillimeterMercuryMinutesPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerLiter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 мм рт.ст·мин/л", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerLiter, MillimeterMercuryMinutesPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerLiter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 mmHg·min/ml", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerMilliliter, MillimeterMercuryMinutesPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 мм рт.ст·мин/мл", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerMilliliter, MillimeterMercuryMinutesPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 mmHg·s/cm³", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerCubicCentimeter, MillimeterMercurySecondsPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 мм рт.ст·с/см³", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerCubicCentimeter, MillimeterMercurySecondsPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 mmHg·s/m³", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerCubicMeter, MillimeterMercurySecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 мм рт.ст·с/м³", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerCubicMeter, MillimeterMercurySecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 mmHg·s/l", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerLiter, MillimeterMercurySecondsPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerLiter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 мм рт.ст·с/л", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerLiter, MillimeterMercurySecondsPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerLiter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 mmHg·s/ml", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerMilliliter, MillimeterMercurySecondsPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 мм рт.ст·с/мл", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerMilliliter, MillimeterMercurySecondsPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Pa·min/cm³", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerCubicCentimeter, PascalMinutesPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicCentimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Па·мин/см³", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerCubicCentimeter, PascalMinutesPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicCentimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Pa·min/m³", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerCubicMeter, PascalMinutesPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Па·мин/м³", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerCubicMeter, PascalMinutesPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Pa·min/l", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerLiter, PascalMinutesPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerLiter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Па·мин/л", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerLiter, PascalMinutesPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerLiter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Pa·min/ml", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerMilliliter, PascalMinutesPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerMilliliter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Па·мин/мл", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerMilliliter, PascalMinutesPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerMilliliter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Pa·s/cm³", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerCubicCentimeter, PascalSecondsPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicCentimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Па·с/см³", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerCubicCentimeter, PascalSecondsPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicCentimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Pa·s/m³", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Па·с/м³", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Pa·s/l", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerLiter, PascalSecondsPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerLiter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Па·с/л", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerLiter, PascalSecondsPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerLiter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Pa·s/ml", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerMilliliter, PascalSecondsPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerMilliliter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 Па·с/мл", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerMilliliter, PascalSecondsPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerMilliliter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 WU", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.WoodUnits, WoodUnitsTolerance); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 HRU", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.WoodUnits, WoodUnitsTolerance); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 ЕВ", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.WoodUnits, WoodUnitsTolerance); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = FluidResistance.Parse("1 ЕГС", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.WoodUnits, WoodUnitsTolerance); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + } + + [Fact] + public void TryParse() + { + { + Assert.True(FluidResistance.TryParse("1 dyn·s/cm⁵", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DyneSecondsPerCentimeterToTheFifth, DyneSecondsPerCentimeterToTheFifthTolerance); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 dyn·s·cm⁻⁵", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DyneSecondsPerCentimeterToTheFifth, DyneSecondsPerCentimeterToTheFifthTolerance); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 дин·с/см⁵", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DyneSecondsPerCentimeterToTheFifth, DyneSecondsPerCentimeterToTheFifthTolerance); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 дин·с·см⁻⁵", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DyneSecondsPerCentimeterToTheFifth, DyneSecondsPerCentimeterToTheFifthTolerance); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 MPa·s/m³", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MegapascalSecondsPerCubicMeter, MegapascalSecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MegapascalSecondPerCubicMeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 МПа·с/м³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MegapascalSecondsPerCubicMeter, MegapascalSecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MegapascalSecondPerCubicMeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 mmHg·min/cm³", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerCubicCentimeter, MillimeterMercuryMinutesPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 мм рт.ст·мин/см³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerCubicCentimeter, MillimeterMercuryMinutesPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 mmHg·min/m³", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerCubicMeter, MillimeterMercuryMinutesPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 мм рт.ст·мин/м³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerCubicMeter, MillimeterMercuryMinutesPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 mmHg·min/l", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerLiter, MillimeterMercuryMinutesPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerLiter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 мм рт.ст·мин/л", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerLiter, MillimeterMercuryMinutesPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerLiter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 mmHg·min/ml", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerMilliliter, MillimeterMercuryMinutesPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 мм рт.ст·мин/мл", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercuryMinutesPerMilliliter, MillimeterMercuryMinutesPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 mmHg·s/cm³", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerCubicCentimeter, MillimeterMercurySecondsPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 мм рт.ст·с/см³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerCubicCentimeter, MillimeterMercurySecondsPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 mmHg·s/m³", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerCubicMeter, MillimeterMercurySecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 мм рт.ст·с/м³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerCubicMeter, MillimeterMercurySecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 mmHg·s/l", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerLiter, MillimeterMercurySecondsPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerLiter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 мм рт.ст·с/л", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerLiter, MillimeterMercurySecondsPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerLiter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 mmHg·s/ml", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerMilliliter, MillimeterMercurySecondsPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 мм рт.ст·с/мл", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillimeterMercurySecondsPerMilliliter, MillimeterMercurySecondsPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Pa·min/cm³", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerCubicCentimeter, PascalMinutesPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicCentimeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Па·мин/см³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerCubicCentimeter, PascalMinutesPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicCentimeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Pa·min/m³", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerCubicMeter, PascalMinutesPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicMeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Па·мин/м³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerCubicMeter, PascalMinutesPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicMeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Pa·min/l", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerLiter, PascalMinutesPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerLiter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Па·мин/л", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerLiter, PascalMinutesPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerLiter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Pa·min/ml", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerMilliliter, PascalMinutesPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerMilliliter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Па·мин/мл", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalMinutesPerMilliliter, PascalMinutesPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.PascalMinutePerMilliliter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Pa·s/cm³", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerCubicCentimeter, PascalSecondsPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicCentimeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Па·с/см³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerCubicCentimeter, PascalSecondsPerCubicCentimeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicCentimeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Pa·s/m³", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicMeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Па·с/м³", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicMeter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Pa·s/l", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerLiter, PascalSecondsPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerLiter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Па·с/л", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerLiter, PascalSecondsPerLiterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerLiter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Pa·s/ml", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerMilliliter, PascalSecondsPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerMilliliter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 Па·с/мл", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PascalSecondsPerMilliliter, PascalSecondsPerMilliliterTolerance); + Assert.Equal(FluidResistanceUnit.PascalSecondPerMilliliter, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 WU", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.WoodUnits, WoodUnitsTolerance); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 HRU", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.WoodUnits, WoodUnitsTolerance); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 ЕВ", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.WoodUnits, WoodUnitsTolerance); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsed.Unit); + } + + { + Assert.True(FluidResistance.TryParse("1 ЕГС", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.WoodUnits, WoodUnitsTolerance); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsed.Unit); + } + + } + + [Fact] + public void ParseUnit() + { + try + { + var parsedUnit = FluidResistance.ParseUnit("dyn·s/cm⁵", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("dyn·s·cm⁻⁵", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("дин·с/см⁵", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("дин·с·см⁻⁵", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("MPa·s/m³", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.MegapascalSecondPerCubicMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("МПа·с/м³", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.MegapascalSecondPerCubicMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("mmHg·min/cm³", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("мм рт.ст·мин/см³", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("mmHg·min/m³", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("мм рт.ст·мин/м³", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("mmHg·min/l", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerLiter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("мм рт.ст·мин/л", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerLiter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("mmHg·min/ml", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("мм рт.ст·мин/мл", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("mmHg·s/cm³", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("мм рт.ст·с/см³", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("mmHg·s/m³", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("мм рт.ст·с/м³", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("mmHg·s/l", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerLiter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("мм рт.ст·с/л", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerLiter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("mmHg·s/ml", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("мм рт.ст·с/мл", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Pa·min/cm³", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicCentimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Па·мин/см³", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicCentimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Pa·min/m³", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Па·мин/м³", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Pa·min/l", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.PascalMinutePerLiter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Па·мин/л", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.PascalMinutePerLiter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Pa·min/ml", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.PascalMinutePerMilliliter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Па·мин/мл", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.PascalMinutePerMilliliter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Pa·s/cm³", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicCentimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Па·с/см³", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicCentimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Pa·s/m³", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Па·с/м³", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Pa·s/l", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.PascalSecondPerLiter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Па·с/л", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.PascalSecondPerLiter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Pa·s/ml", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.PascalSecondPerMilliliter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("Па·с/мл", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.PascalSecondPerMilliliter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("WU", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("HRU", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("ЕВ", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = FluidResistance.ParseUnit("ЕГС", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + } + + [Fact] + public void TryParseUnit() + { + { + Assert.True(FluidResistance.TryParseUnit("dyn·s/cm⁵", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("dyn·s·cm⁻⁵", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("дин·с/см⁵", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("дин·с·см⁻⁵", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("MPa·s/m³", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MegapascalSecondPerCubicMeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("МПа·с/м³", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MegapascalSecondPerCubicMeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("mmHg·min/cm³", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("мм рт.ст·мин/см³", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("mmHg·min/m³", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("мм рт.ст·мин/м³", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("mmHg·min/l", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerLiter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("мм рт.ст·мин/л", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerLiter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("mmHg·min/ml", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("мм рт.ст·мин/мл", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("mmHg·s/cm³", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("мм рт.ст·с/см³", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("mmHg·s/m³", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("мм рт.ст·с/м³", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("mmHg·s/l", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerLiter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("мм рт.ст·с/л", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerLiter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("mmHg·s/ml", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("мм рт.ст·с/мл", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Pa·min/cm³", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicCentimeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Па·мин/см³", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicCentimeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Pa·min/m³", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicMeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Па·мин/м³", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalMinutePerCubicMeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Pa·min/l", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalMinutePerLiter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Па·мин/л", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalMinutePerLiter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Pa·min/ml", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalMinutePerMilliliter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Па·мин/мл", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalMinutePerMilliliter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Pa·s/cm³", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicCentimeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Па·с/см³", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicCentimeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Pa·s/m³", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicMeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Па·с/м³", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalSecondPerCubicMeter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Pa·s/l", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalSecondPerLiter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Па·с/л", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalSecondPerLiter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Pa·s/ml", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalSecondPerMilliliter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("Па·с/мл", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.PascalSecondPerMilliliter, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("WU", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("HRU", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("ЕВ", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsedUnit); + } + + { + Assert.True(FluidResistance.TryParseUnit("ЕГС", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(FluidResistanceUnit.WoodUnit, parsedUnit); + } + + } + + [Theory] + [MemberData(nameof(UnitTypes))] + public void ToUnit(FluidResistanceUnit unit) + { + var inBaseUnits = FluidResistance.From(1.0, FluidResistance.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); + + var conversionFactor = GetConversionFactor(unit); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + Assert.Equal(unit, converted.Unit); + } + + [Theory] + [MemberData(nameof(UnitTypes))] + public void ToUnit_WithSameUnits_AreEqual(FluidResistanceUnit unit) + { + var quantity = FluidResistance.From(3.0, unit); + var toUnitWithSameUnit = quantity.ToUnit(unit); + Assert.Equal(quantity, toUnitWithSameUnit); + } + + [Theory] + [MemberData(nameof(UnitTypes))] + public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(FluidResistanceUnit unit) + { + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = FluidResistance.Units.First(u => u != FluidResistance.BaseUnit); + + var quantity = FluidResistance.From(3.0, fromUnit); + var converted = quantity.ToUnit(unit); + Assert.Equal(converted.Unit, unit); + } + + [Theory] + [MemberData(nameof(UnitTypes))] + public virtual void ToUnit_FromDefaultQuantity_ReturnsQuantityWithGivenUnit(FluidResistanceUnit unit) + { + var quantity = default(FluidResistance); + var converted = quantity.ToUnit(unit); + Assert.Equal(converted.Unit, unit); + } + + [Fact] + public void ConversionRoundTrip() + { + FluidResistance pascalsecondpercubicmeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); + AssertEx.EqualTolerance(1, FluidResistance.FromDyneSecondsPerCentimeterToTheFifth(pascalsecondpercubicmeter.DyneSecondsPerCentimeterToTheFifth).PascalSecondsPerCubicMeter, DyneSecondsPerCentimeterToTheFifthTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromMegapascalSecondsPerCubicMeter(pascalsecondpercubicmeter.MegapascalSecondsPerCubicMeter).PascalSecondsPerCubicMeter, MegapascalSecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromMillimeterMercuryMinutesPerCubicCentimeter(pascalsecondpercubicmeter.MillimeterMercuryMinutesPerCubicCentimeter).PascalSecondsPerCubicMeter, MillimeterMercuryMinutesPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromMillimeterMercuryMinutesPerCubicMeter(pascalsecondpercubicmeter.MillimeterMercuryMinutesPerCubicMeter).PascalSecondsPerCubicMeter, MillimeterMercuryMinutesPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromMillimeterMercuryMinutesPerLiter(pascalsecondpercubicmeter.MillimeterMercuryMinutesPerLiter).PascalSecondsPerCubicMeter, MillimeterMercuryMinutesPerLiterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromMillimeterMercuryMinutesPerMilliliter(pascalsecondpercubicmeter.MillimeterMercuryMinutesPerMilliliter).PascalSecondsPerCubicMeter, MillimeterMercuryMinutesPerMilliliterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromMillimeterMercurySecondsPerCubicCentimeter(pascalsecondpercubicmeter.MillimeterMercurySecondsPerCubicCentimeter).PascalSecondsPerCubicMeter, MillimeterMercurySecondsPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromMillimeterMercurySecondsPerCubicMeter(pascalsecondpercubicmeter.MillimeterMercurySecondsPerCubicMeter).PascalSecondsPerCubicMeter, MillimeterMercurySecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromMillimeterMercurySecondsPerLiter(pascalsecondpercubicmeter.MillimeterMercurySecondsPerLiter).PascalSecondsPerCubicMeter, MillimeterMercurySecondsPerLiterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromMillimeterMercurySecondsPerMilliliter(pascalsecondpercubicmeter.MillimeterMercurySecondsPerMilliliter).PascalSecondsPerCubicMeter, MillimeterMercurySecondsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromPascalMinutesPerCubicCentimeter(pascalsecondpercubicmeter.PascalMinutesPerCubicCentimeter).PascalSecondsPerCubicMeter, PascalMinutesPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromPascalMinutesPerCubicMeter(pascalsecondpercubicmeter.PascalMinutesPerCubicMeter).PascalSecondsPerCubicMeter, PascalMinutesPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromPascalMinutesPerLiter(pascalsecondpercubicmeter.PascalMinutesPerLiter).PascalSecondsPerCubicMeter, PascalMinutesPerLiterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromPascalMinutesPerMilliliter(pascalsecondpercubicmeter.PascalMinutesPerMilliliter).PascalSecondsPerCubicMeter, PascalMinutesPerMilliliterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromPascalSecondsPerCubicCentimeter(pascalsecondpercubicmeter.PascalSecondsPerCubicCentimeter).PascalSecondsPerCubicMeter, PascalSecondsPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromPascalSecondsPerCubicMeter(pascalsecondpercubicmeter.PascalSecondsPerCubicMeter).PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromPascalSecondsPerLiter(pascalsecondpercubicmeter.PascalSecondsPerLiter).PascalSecondsPerCubicMeter, PascalSecondsPerLiterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromPascalSecondsPerMilliliter(pascalsecondpercubicmeter.PascalSecondsPerMilliliter).PascalSecondsPerCubicMeter, PascalSecondsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, FluidResistance.FromWoodUnits(pascalsecondpercubicmeter.WoodUnits).PascalSecondsPerCubicMeter, WoodUnitsTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + FluidResistance v = FluidResistance.FromPascalSecondsPerCubicMeter(1); + AssertEx.EqualTolerance(-1, -v.PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (FluidResistance.FromPascalSecondsPerCubicMeter(3)-v).PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (FluidResistance.FromPascalSecondsPerCubicMeter(10)/5).PascalSecondsPerCubicMeter, PascalSecondsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, FluidResistance.FromPascalSecondsPerCubicMeter(10)/FluidResistance.FromPascalSecondsPerCubicMeter(5), PascalSecondsPerCubicMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + FluidResistance onePascalSecondPerCubicMeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); + FluidResistance twoPascalSecondsPerCubicMeter = FluidResistance.FromPascalSecondsPerCubicMeter(2); + + Assert.True(onePascalSecondPerCubicMeter < twoPascalSecondsPerCubicMeter); + Assert.True(onePascalSecondPerCubicMeter <= twoPascalSecondsPerCubicMeter); + Assert.True(twoPascalSecondsPerCubicMeter > onePascalSecondPerCubicMeter); + Assert.True(twoPascalSecondsPerCubicMeter >= onePascalSecondPerCubicMeter); + + Assert.False(onePascalSecondPerCubicMeter > twoPascalSecondsPerCubicMeter); + Assert.False(onePascalSecondPerCubicMeter >= twoPascalSecondsPerCubicMeter); + Assert.False(twoPascalSecondsPerCubicMeter < onePascalSecondPerCubicMeter); + Assert.False(twoPascalSecondsPerCubicMeter <= onePascalSecondPerCubicMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + FluidResistance pascalsecondpercubicmeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); + Assert.Equal(0, pascalsecondpercubicmeter.CompareTo(pascalsecondpercubicmeter)); + Assert.True(pascalsecondpercubicmeter.CompareTo(FluidResistance.Zero) > 0); + Assert.True(FluidResistance.Zero.CompareTo(pascalsecondpercubicmeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + FluidResistance pascalsecondpercubicmeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); + Assert.Throws(() => pascalsecondpercubicmeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + FluidResistance pascalsecondpercubicmeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); + Assert.Throws(() => pascalsecondpercubicmeter.CompareTo(null)); + } + + [Theory] + [InlineData(1, FluidResistanceUnit.PascalSecondPerCubicMeter, 1, FluidResistanceUnit.PascalSecondPerCubicMeter, true)] // Same value and unit. + [InlineData(1, FluidResistanceUnit.PascalSecondPerCubicMeter, 2, FluidResistanceUnit.PascalSecondPerCubicMeter, false)] // Different value. + [InlineData(2, FluidResistanceUnit.PascalSecondPerCubicMeter, 1, FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, false)] // Different value and unit. + [InlineData(1, FluidResistanceUnit.PascalSecondPerCubicMeter, 1, FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, false)] // Different unit. + public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, FluidResistanceUnit unitA, double valueB, FluidResistanceUnit unitB, bool expectEqual) + { + var a = new FluidResistance(valueA, unitA); + var b = new FluidResistance(valueB, unitB); + + // Operator overloads. + Assert.Equal(expectEqual, a == b); + Assert.Equal(expectEqual, b == a); + Assert.Equal(!expectEqual, a != b); + Assert.Equal(!expectEqual, b != a); + + // IEquatable + Assert.Equal(expectEqual, a.Equals(b)); + Assert.Equal(expectEqual, b.Equals(a)); + + // IEquatable + Assert.Equal(expectEqual, a.Equals((object)b)); + Assert.Equal(expectEqual, b.Equals((object)a)); + } + + [Fact] + public void Equals_Null_ReturnsFalse() + { + var a = FluidResistance.Zero; + + Assert.False(a.Equals((object)null)); + + // "The result of the expression is always 'false'..." + #pragma warning disable CS8073 + Assert.False(a == null); + Assert.False(null == a); + Assert.True(a != null); + Assert.True(null != a); + #pragma warning restore CS8073 + } + + [Fact] + public void Equals_RelativeTolerance_IsImplemented() + { + var v = FluidResistance.FromPascalSecondsPerCubicMeter(1); + Assert.True(v.Equals(FluidResistance.FromPascalSecondsPerCubicMeter(1), PascalSecondsPerCubicMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(FluidResistance.Zero, PascalSecondsPerCubicMeterTolerance, ComparisonType.Relative)); + Assert.True(FluidResistance.FromPascalSecondsPerCubicMeter(100).Equals(FluidResistance.FromPascalSecondsPerCubicMeter(120), (double)0.3m, ComparisonType.Relative)); + Assert.False(FluidResistance.FromPascalSecondsPerCubicMeter(100).Equals(FluidResistance.FromPascalSecondsPerCubicMeter(120), (double)0.1m, ComparisonType.Relative)); + } + + [Fact] + public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + { + var v = FluidResistance.FromPascalSecondsPerCubicMeter(1); + Assert.Throws(() => v.Equals(FluidResistance.FromPascalSecondsPerCubicMeter(1), -1, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + FluidResistance pascalsecondpercubicmeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); + Assert.False(pascalsecondpercubicmeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + FluidResistance pascalsecondpercubicmeter = FluidResistance.FromPascalSecondsPerCubicMeter(1); + Assert.False(pascalsecondpercubicmeter.Equals(null)); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(FluidResistanceUnit)).Cast(); + foreach (var unit in units) + { + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(FluidResistance.BaseDimensions is null); + } + + [Fact] + public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() + { + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); + try { + Assert.Equal("1 dyn·s/cm⁵", new FluidResistance(1, FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth).ToString()); + Assert.Equal("1 MPa·s/m³", new FluidResistance(1, FluidResistanceUnit.MegapascalSecondPerCubicMeter).ToString()); + Assert.Equal("1 mmHg·min/cm³", new FluidResistance(1, FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter).ToString()); + Assert.Equal("1 mmHg·min/m³", new FluidResistance(1, FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter).ToString()); + Assert.Equal("1 mmHg·min/l", new FluidResistance(1, FluidResistanceUnit.MillimeterMercuryMinutePerLiter).ToString()); + Assert.Equal("1 mmHg·min/ml", new FluidResistance(1, FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter).ToString()); + Assert.Equal("1 mmHg·s/cm³", new FluidResistance(1, FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter).ToString()); + Assert.Equal("1 mmHg·s/m³", new FluidResistance(1, FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter).ToString()); + Assert.Equal("1 mmHg·s/l", new FluidResistance(1, FluidResistanceUnit.MillimeterMercurySecondPerLiter).ToString()); + Assert.Equal("1 mmHg·s/ml", new FluidResistance(1, FluidResistanceUnit.MillimeterMercurySecondPerMilliliter).ToString()); + Assert.Equal("1 Pa·min/cm³", new FluidResistance(1, FluidResistanceUnit.PascalMinutePerCubicCentimeter).ToString()); + Assert.Equal("1 Pa·min/m³", new FluidResistance(1, FluidResistanceUnit.PascalMinutePerCubicMeter).ToString()); + Assert.Equal("1 Pa·min/l", new FluidResistance(1, FluidResistanceUnit.PascalMinutePerLiter).ToString()); + Assert.Equal("1 Pa·min/ml", new FluidResistance(1, FluidResistanceUnit.PascalMinutePerMilliliter).ToString()); + Assert.Equal("1 Pa·s/cm³", new FluidResistance(1, FluidResistanceUnit.PascalSecondPerCubicCentimeter).ToString()); + Assert.Equal("1 Pa·s/m³", new FluidResistance(1, FluidResistanceUnit.PascalSecondPerCubicMeter).ToString()); + Assert.Equal("1 Pa·s/l", new FluidResistance(1, FluidResistanceUnit.PascalSecondPerLiter).ToString()); + Assert.Equal("1 Pa·s/ml", new FluidResistance(1, FluidResistanceUnit.PascalSecondPerMilliliter).ToString()); + Assert.Equal("1 WU", new FluidResistance(1, FluidResistanceUnit.WoodUnit).ToString()); + } + finally + { + Thread.CurrentThread.CurrentCulture = prevCulture; + } + } + + [Fact] + public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCultureSinceThereAreNoMappings() + { + // Chose this culture, because we don't currently have any abbreviations mapped for that culture and we expect the en-US to be used as fallback. + var swedishCulture = CultureInfo.GetCultureInfo("sv-SE"); + + Assert.Equal("1 dyn·s/cm⁵", new FluidResistance(1, FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth).ToString(swedishCulture)); + Assert.Equal("1 MPa·s/m³", new FluidResistance(1, FluidResistanceUnit.MegapascalSecondPerCubicMeter).ToString(swedishCulture)); + Assert.Equal("1 mmHg·min/cm³", new FluidResistance(1, FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter).ToString(swedishCulture)); + Assert.Equal("1 mmHg·min/m³", new FluidResistance(1, FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter).ToString(swedishCulture)); + Assert.Equal("1 mmHg·min/l", new FluidResistance(1, FluidResistanceUnit.MillimeterMercuryMinutePerLiter).ToString(swedishCulture)); + Assert.Equal("1 mmHg·min/ml", new FluidResistance(1, FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter).ToString(swedishCulture)); + Assert.Equal("1 mmHg·s/cm³", new FluidResistance(1, FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter).ToString(swedishCulture)); + Assert.Equal("1 mmHg·s/m³", new FluidResistance(1, FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter).ToString(swedishCulture)); + Assert.Equal("1 mmHg·s/l", new FluidResistance(1, FluidResistanceUnit.MillimeterMercurySecondPerLiter).ToString(swedishCulture)); + Assert.Equal("1 mmHg·s/ml", new FluidResistance(1, FluidResistanceUnit.MillimeterMercurySecondPerMilliliter).ToString(swedishCulture)); + Assert.Equal("1 Pa·min/cm³", new FluidResistance(1, FluidResistanceUnit.PascalMinutePerCubicCentimeter).ToString(swedishCulture)); + Assert.Equal("1 Pa·min/m³", new FluidResistance(1, FluidResistanceUnit.PascalMinutePerCubicMeter).ToString(swedishCulture)); + Assert.Equal("1 Pa·min/l", new FluidResistance(1, FluidResistanceUnit.PascalMinutePerLiter).ToString(swedishCulture)); + Assert.Equal("1 Pa·min/ml", new FluidResistance(1, FluidResistanceUnit.PascalMinutePerMilliliter).ToString(swedishCulture)); + Assert.Equal("1 Pa·s/cm³", new FluidResistance(1, FluidResistanceUnit.PascalSecondPerCubicCentimeter).ToString(swedishCulture)); + Assert.Equal("1 Pa·s/m³", new FluidResistance(1, FluidResistanceUnit.PascalSecondPerCubicMeter).ToString(swedishCulture)); + Assert.Equal("1 Pa·s/l", new FluidResistance(1, FluidResistanceUnit.PascalSecondPerLiter).ToString(swedishCulture)); + Assert.Equal("1 Pa·s/ml", new FluidResistance(1, FluidResistanceUnit.PascalSecondPerMilliliter).ToString(swedishCulture)); + Assert.Equal("1 WU", new FluidResistance(1, FluidResistanceUnit.WoodUnit).ToString(swedishCulture)); + } + + [Fact] + public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() + { + var oldCulture = CultureInfo.CurrentCulture; + try + { + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; + Assert.Equal("0.1 Pa·s/m³", new FluidResistance(0.123456, FluidResistanceUnit.PascalSecondPerCubicMeter).ToString("s1")); + Assert.Equal("0.12 Pa·s/m³", new FluidResistance(0.123456, FluidResistanceUnit.PascalSecondPerCubicMeter).ToString("s2")); + Assert.Equal("0.123 Pa·s/m³", new FluidResistance(0.123456, FluidResistanceUnit.PascalSecondPerCubicMeter).ToString("s3")); + Assert.Equal("0.1235 Pa·s/m³", new FluidResistance(0.123456, FluidResistanceUnit.PascalSecondPerCubicMeter).ToString("s4")); + } + finally + { + CultureInfo.CurrentCulture = oldCulture; + } + } + + [Fact] + public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixForGivenCulture() + { + var culture = CultureInfo.InvariantCulture; + Assert.Equal("0.1 Pa·s/m³", new FluidResistance(0.123456, FluidResistanceUnit.PascalSecondPerCubicMeter).ToString("s1", culture)); + Assert.Equal("0.12 Pa·s/m³", new FluidResistance(0.123456, FluidResistanceUnit.PascalSecondPerCubicMeter).ToString("s2", culture)); + Assert.Equal("0.123 Pa·s/m³", new FluidResistance(0.123456, FluidResistanceUnit.PascalSecondPerCubicMeter).ToString("s3", culture)); + Assert.Equal("0.1235 Pa·s/m³", new FluidResistance(0.123456, FluidResistanceUnit.PascalSecondPerCubicMeter).ToString("s4", culture)); + } + + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); + + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); + } + + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); + } + + [Fact] + public void Convert_ToBool_ThrowsInvalidCastException() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Throws(() => Convert.ToBoolean(quantity)); + } + + [Fact] + public void Convert_ToByte_EqualsValueAsSameType() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + } + + [Fact] + public void Convert_ToChar_ThrowsInvalidCastException() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Throws(() => Convert.ToChar(quantity)); + } + + [Fact] + public void Convert_ToDateTime_ThrowsInvalidCastException() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Throws(() => Convert.ToDateTime(quantity)); + } + + [Fact] + public void Convert_ToDecimal_EqualsValueAsSameType() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); + } + + [Fact] + public void Convert_ToDouble_EqualsValueAsSameType() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal((double)quantity.Value, Convert.ToDouble(quantity)); + } + + [Fact] + public void Convert_ToInt16_EqualsValueAsSameType() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + } + + [Fact] + public void Convert_ToInt32_EqualsValueAsSameType() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + } + + [Fact] + public void Convert_ToInt64_EqualsValueAsSameType() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + } + + [Fact] + public void Convert_ToSByte_EqualsValueAsSameType() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + } + + [Fact] + public void Convert_ToSingle_EqualsValueAsSameType() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + } + + [Fact] + public void Convert_ToString_EqualsToString() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); + } + + [Fact] + public void Convert_ToUInt16_EqualsValueAsSameType() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + } + + [Fact] + public void Convert_ToUInt32_EqualsValueAsSameType() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + } + + [Fact] + public void Convert_ToUInt64_EqualsValueAsSameType() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + } + + [Fact] + public void Convert_ChangeType_SelfType_EqualsSelf() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(FluidResistance))); + } + + [Fact] + public void Convert_ChangeType_UnitType_EqualsUnit() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(FluidResistanceUnit))); + } + + [Fact] + public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal(FluidResistance.Info, Convert.ChangeType(quantity, typeof(QuantityInfo))); + } + + [Fact] + public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal(FluidResistance.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); + } + + [Fact] + public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Throws(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); + } + + [Fact] + public void GetHashCode_Equals() + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(1.0); + Assert.Equal(new {FluidResistance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + } + + [Theory] + [InlineData(1.0)] + [InlineData(-1.0)] + public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) + { + var quantity = FluidResistance.FromPascalSecondsPerCubicMeter(value); + Assert.Equal(FluidResistance.FromPascalSecondsPerCubicMeter(-value), -quantity); + } + } +} diff --git a/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs new file mode 100644 index 0000000000..e7ffa5140b --- /dev/null +++ b/UnitsNet/GeneratedCode/Quantities/FluidResistance.g.cs @@ -0,0 +1,1295 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Linq; +using System.Runtime.Serialization; +using UnitsNet.InternalHelpers; +using UnitsNet.Units; + +#nullable enable + +// ReSharper disable once CheckNamespace + +namespace UnitsNet +{ + /// + /// + /// Fluid Resistance is a force acting opposite to the relative motion of any object moving with respect to a surrounding fluid. Fluid Resistance is sometimes referred to as drag or fluid friction. + /// + /// + /// https://en.wikipedia.org/wiki/Friction#Fluid + /// + [DataContract] + [DebuggerTypeProxy(typeof(QuantityDisplay))] + public readonly partial struct FluidResistance : + IArithmeticQuantity, + IComparable, + IComparable, + IConvertible, + IEquatable, + IFormattable + { + /// + /// The numeric value this quantity was constructed with. + /// + [DataMember(Name = "Value", Order = 1)] + private readonly double _value; + + /// + /// The unit this quantity was constructed with. + /// + [DataMember(Name = "Unit", Order = 2)] + private readonly FluidResistanceUnit? _unit; + + static FluidResistance() + { + BaseDimensions = new BaseDimensions(-4, 1, -1, 0, 0, 0, 0); + BaseUnit = FluidResistanceUnit.PascalSecondPerCubicMeter; + Units = Enum.GetValues(typeof(FluidResistanceUnit)).Cast().ToArray(); + Zero = new FluidResistance(0, BaseUnit); + Info = new QuantityInfo("FluidResistance", + new UnitInfo[] + { + new UnitInfo(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, "DyneSecondsPerCentimeterToTheFifth", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.MegapascalSecondPerCubicMeter, "MegapascalSecondsPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, "MillimeterMercuryMinutesPerCubicCentimeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, "MillimeterMercuryMinutesPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.MillimeterMercuryMinutePerLiter, "MillimeterMercuryMinutesPerLiter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, "MillimeterMercuryMinutesPerMilliliter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, "MillimeterMercurySecondsPerCubicCentimeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, "MillimeterMercurySecondsPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.MillimeterMercurySecondPerLiter, "MillimeterMercurySecondsPerLiter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, "MillimeterMercurySecondsPerMilliliter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.PascalMinutePerCubicCentimeter, "PascalMinutesPerCubicCentimeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.PascalMinutePerCubicMeter, "PascalMinutesPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.PascalMinutePerLiter, "PascalMinutesPerLiter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.PascalMinutePerMilliliter, "PascalMinutesPerMilliliter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.PascalSecondPerCubicCentimeter, "PascalSecondsPerCubicCentimeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.PascalSecondPerCubicMeter, "PascalSecondsPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.PascalSecondPerLiter, "PascalSecondsPerLiter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.PascalSecondPerMilliliter, "PascalSecondsPerMilliliter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + new UnitInfo(FluidResistanceUnit.WoodUnit, "WoodUnits", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second), "FluidResistance"), + }, + BaseUnit, Zero, BaseDimensions); + + DefaultConversionFunctions = new UnitConverter(); + RegisterDefaultConversions(DefaultConversionFunctions); + } + + /// + /// Creates the quantity with the given numeric value and unit. + /// + /// The numeric value to construct this quantity with. + /// The unit representation to construct this quantity with. + /// If value is NaN or Infinity. + public FluidResistance(double value, FluidResistanceUnit unit) + { + _value = Guard.EnsureValidNumber(value, nameof(value)); + _unit = unit; + } + + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// If multiple compatible units were found, the first match is used. + /// + /// The numeric value to construct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + public FluidResistance(double value, UnitSystem unitSystem) + { + if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); + + var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); + var firstUnitInfo = unitInfos.FirstOrDefault(); + + _value = Guard.EnsureValidNumber(value, nameof(value)); + _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); + } + + #region Static Properties + + /// + /// The containing the default generated conversion functions for instances. + /// + public static UnitConverter DefaultConversionFunctions { get; } + + /// + public static QuantityInfo Info { get; } + + /// + /// The of this quantity. + /// + public static BaseDimensions BaseDimensions { get; } + + /// + /// The base unit of FluidResistance, which is PascalSecondPerCubicMeter. All conversions go via this value. + /// + public static FluidResistanceUnit BaseUnit { get; } + + /// + /// All units of measurement for the FluidResistance quantity. + /// + public static FluidResistanceUnit[] Units { get; } + + /// + /// Gets an instance of this quantity with a value of 0 in the base unit PascalSecondPerCubicMeter. + /// + public static FluidResistance Zero { get; } + + /// + public static FluidResistance AdditiveIdentity => Zero; + + #endregion + + #region Properties + + /// + /// The numeric value this quantity was constructed with. + /// + public double Value => _value; + + /// + QuantityValue IQuantity.Value => _value; + + Enum IQuantity.Unit => Unit; + + /// + public FluidResistanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + + /// + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + + /// + /// The of this quantity. + /// + public BaseDimensions Dimensions => FluidResistance.BaseDimensions; + + #endregion + + #region Conversion Properties + + /// + /// Gets a value of this quantity converted into + /// + public double DyneSecondsPerCentimeterToTheFifth => As(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth); + + /// + /// Gets a value of this quantity converted into + /// + public double MegapascalSecondsPerCubicMeter => As(FluidResistanceUnit.MegapascalSecondPerCubicMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercuryMinutesPerCubicCentimeter => As(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercuryMinutesPerCubicMeter => As(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercuryMinutesPerLiter => As(FluidResistanceUnit.MillimeterMercuryMinutePerLiter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercuryMinutesPerMilliliter => As(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercurySecondsPerCubicCentimeter => As(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercurySecondsPerCubicMeter => As(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercurySecondsPerLiter => As(FluidResistanceUnit.MillimeterMercurySecondPerLiter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillimeterMercurySecondsPerMilliliter => As(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalMinutesPerCubicCentimeter => As(FluidResistanceUnit.PascalMinutePerCubicCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalMinutesPerCubicMeter => As(FluidResistanceUnit.PascalMinutePerCubicMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalMinutesPerLiter => As(FluidResistanceUnit.PascalMinutePerLiter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalMinutesPerMilliliter => As(FluidResistanceUnit.PascalMinutePerMilliliter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalSecondsPerCubicCentimeter => As(FluidResistanceUnit.PascalSecondPerCubicCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalSecondsPerCubicMeter => As(FluidResistanceUnit.PascalSecondPerCubicMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalSecondsPerLiter => As(FluidResistanceUnit.PascalSecondPerLiter); + + /// + /// Gets a value of this quantity converted into + /// + public double PascalSecondsPerMilliliter => As(FluidResistanceUnit.PascalSecondPerMilliliter); + + /// + /// Gets a value of this quantity converted into + /// + public double WoodUnits => As(FluidResistanceUnit.WoodUnit); + + #endregion + + #region Static Methods + + /// + /// Registers the default conversion functions in the given instance. + /// + /// The to register the default conversion functions in. + internal static void RegisterDefaultConversions(UnitConverter unitConverter) + { + // Register in unit converter: FluidResistanceUnit -> BaseUnit + unitConverter.SetConversionFunction(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.MegapascalSecondPerCubicMeter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.MillimeterMercuryMinutePerLiter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.MillimeterMercurySecondPerLiter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalMinutePerCubicCentimeter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalMinutePerCubicMeter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalMinutePerLiter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalMinutePerMilliliter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicCentimeter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerLiter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerMilliliter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.WoodUnit, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicMeter)); + + // Register in unit converter: BaseUnit <-> BaseUnit + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalSecondPerCubicMeter, quantity => quantity); + + // Register in unit converter: BaseUnit -> FluidResistanceUnit + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, quantity => quantity.ToUnit(FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MegapascalSecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.MegapascalSecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, quantity => quantity.ToUnit(FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercuryMinutePerLiter, quantity => quantity.ToUnit(FluidResistanceUnit.MillimeterMercuryMinutePerLiter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, quantity => quantity.ToUnit(FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, quantity => quantity.ToUnit(FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercurySecondPerLiter, quantity => quantity.ToUnit(FluidResistanceUnit.MillimeterMercurySecondPerLiter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, quantity => quantity.ToUnit(FluidResistanceUnit.MillimeterMercurySecondPerMilliliter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalMinutePerCubicCentimeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalMinutePerCubicCentimeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalMinutePerCubicMeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalMinutePerCubicMeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalMinutePerLiter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalMinutePerLiter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalMinutePerMilliliter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalMinutePerMilliliter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalSecondPerCubicCentimeter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerCubicCentimeter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalSecondPerLiter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerLiter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalSecondPerMilliliter, quantity => quantity.ToUnit(FluidResistanceUnit.PascalSecondPerMilliliter)); + unitConverter.SetConversionFunction(FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.WoodUnit, quantity => quantity.ToUnit(FluidResistanceUnit.WoodUnit)); + } + + /// + /// Get unit abbreviation string. + /// + /// Unit to get abbreviation for. + /// Unit abbreviation string. + public static string GetAbbreviation(FluidResistanceUnit unit) + { + return GetAbbreviation(unit, null); + } + + /// + /// Get unit abbreviation string. + /// + /// Unit to get abbreviation for. + /// Unit abbreviation string. + /// Format to use for localization. Defaults to if null. + public static string GetAbbreviation(FluidResistanceUnit unit, IFormatProvider? provider) + { + return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); + } + + #endregion + + #region Static Factory Methods + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromDyneSecondsPerCentimeterToTheFifth(QuantityValue dynesecondspercentimetertothefifth) + { + double value = (double) dynesecondspercentimetertothefifth; + return new FluidResistance(value, FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMegapascalSecondsPerCubicMeter(QuantityValue megapascalsecondspercubicmeter) + { + double value = (double) megapascalsecondspercubicmeter; + return new FluidResistance(value, FluidResistanceUnit.MegapascalSecondPerCubicMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercuryMinutesPerCubicCentimeter(QuantityValue millimetermercuryminutespercubiccentimeter) + { + double value = (double) millimetermercuryminutespercubiccentimeter; + return new FluidResistance(value, FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercuryMinutesPerCubicMeter(QuantityValue millimetermercuryminutespercubicmeter) + { + double value = (double) millimetermercuryminutespercubicmeter; + return new FluidResistance(value, FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercuryMinutesPerLiter(QuantityValue millimetermercuryminutesperliter) + { + double value = (double) millimetermercuryminutesperliter; + return new FluidResistance(value, FluidResistanceUnit.MillimeterMercuryMinutePerLiter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercuryMinutesPerMilliliter(QuantityValue millimetermercuryminutespermilliliter) + { + double value = (double) millimetermercuryminutespermilliliter; + return new FluidResistance(value, FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercurySecondsPerCubicCentimeter(QuantityValue millimetermercurysecondspercubiccentimeter) + { + double value = (double) millimetermercurysecondspercubiccentimeter; + return new FluidResistance(value, FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercurySecondsPerCubicMeter(QuantityValue millimetermercurysecondspercubicmeter) + { + double value = (double) millimetermercurysecondspercubicmeter; + return new FluidResistance(value, FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercurySecondsPerLiter(QuantityValue millimetermercurysecondsperliter) + { + double value = (double) millimetermercurysecondsperliter; + return new FluidResistance(value, FluidResistanceUnit.MillimeterMercurySecondPerLiter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromMillimeterMercurySecondsPerMilliliter(QuantityValue millimetermercurysecondspermilliliter) + { + double value = (double) millimetermercurysecondspermilliliter; + return new FluidResistance(value, FluidResistanceUnit.MillimeterMercurySecondPerMilliliter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalMinutesPerCubicCentimeter(QuantityValue pascalminutespercubiccentimeter) + { + double value = (double) pascalminutespercubiccentimeter; + return new FluidResistance(value, FluidResistanceUnit.PascalMinutePerCubicCentimeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalMinutesPerCubicMeter(QuantityValue pascalminutespercubicmeter) + { + double value = (double) pascalminutespercubicmeter; + return new FluidResistance(value, FluidResistanceUnit.PascalMinutePerCubicMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalMinutesPerLiter(QuantityValue pascalminutesperliter) + { + double value = (double) pascalminutesperliter; + return new FluidResistance(value, FluidResistanceUnit.PascalMinutePerLiter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalMinutesPerMilliliter(QuantityValue pascalminutespermilliliter) + { + double value = (double) pascalminutespermilliliter; + return new FluidResistance(value, FluidResistanceUnit.PascalMinutePerMilliliter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalSecondsPerCubicCentimeter(QuantityValue pascalsecondspercubiccentimeter) + { + double value = (double) pascalsecondspercubiccentimeter; + return new FluidResistance(value, FluidResistanceUnit.PascalSecondPerCubicCentimeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalSecondsPerCubicMeter(QuantityValue pascalsecondspercubicmeter) + { + double value = (double) pascalsecondspercubicmeter; + return new FluidResistance(value, FluidResistanceUnit.PascalSecondPerCubicMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalSecondsPerLiter(QuantityValue pascalsecondsperliter) + { + double value = (double) pascalsecondsperliter; + return new FluidResistance(value, FluidResistanceUnit.PascalSecondPerLiter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromPascalSecondsPerMilliliter(QuantityValue pascalsecondspermilliliter) + { + double value = (double) pascalsecondspermilliliter; + return new FluidResistance(value, FluidResistanceUnit.PascalSecondPerMilliliter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static FluidResistance FromWoodUnits(QuantityValue woodunits) + { + double value = (double) woodunits; + return new FluidResistance(value, FluidResistanceUnit.WoodUnit); + } + + /// + /// Dynamically convert from value and unit enum to . + /// + /// Value to convert from. + /// Unit to convert from. + /// FluidResistance unit value. + public static FluidResistance From(QuantityValue value, FluidResistanceUnit fromUnit) + { + return new FluidResistance((double)value, fromUnit); + } + + #endregion + + #region Static Parse Methods + + /// + /// Parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// + /// Length.Parse("5.5 m", CultureInfo.GetCultureInfo("en-US")); + /// + /// The value of 'str' cannot be null. + /// + /// Expected string to have one or two pairs of quantity and unit in the format + /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" + /// + /// + /// More than one unit is represented by the specified unit abbreviation. + /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of + /// , and . + /// + /// + /// If anything else goes wrong, typically due to a bug or unhandled case. + /// We wrap exceptions in to allow you to distinguish + /// Units.NET exceptions from other exceptions. + /// + public static FluidResistance Parse(string str) + { + return Parse(str, null); + } + + /// + /// Parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// + /// Length.Parse("5.5 m", CultureInfo.GetCultureInfo("en-US")); + /// + /// The value of 'str' cannot be null. + /// + /// Expected string to have one or two pairs of quantity and unit in the format + /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" + /// + /// + /// More than one unit is represented by the specified unit abbreviation. + /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of + /// , and . + /// + /// + /// If anything else goes wrong, typically due to a bug or unhandled case. + /// We wrap exceptions in to allow you to distinguish + /// Units.NET exceptions from other exceptions. + /// + /// Format to use when parsing number and unit. Defaults to if null. + public static FluidResistance Parse(string str, IFormatProvider? provider) + { + return QuantityParser.Default.Parse( + str, + provider, + From); + } + + /// + /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// Resulting unit quantity if successful. + /// + /// Length.Parse("5.5 m", CultureInfo.GetCultureInfo("en-US")); + /// + public static bool TryParse(string? str, out FluidResistance result) + { + return TryParse(str, null, out result); + } + + /// + /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// Resulting unit quantity if successful. + /// True if successful, otherwise false. + /// + /// Length.Parse("5.5 m", CultureInfo.GetCultureInfo("en-US")); + /// + /// Format to use when parsing number and unit. Defaults to if null. + public static bool TryParse(string? str, IFormatProvider? provider, out FluidResistance result) + { + return QuantityParser.Default.TryParse( + str, + provider, + From, + out result); + } + + /// + /// Parse a unit string. + /// + /// String to parse. Typically in the form: {number} {unit} + /// + /// Length.ParseUnit("m", CultureInfo.GetCultureInfo("en-US")); + /// + /// The value of 'str' cannot be null. + /// Error parsing string. + public static FluidResistanceUnit ParseUnit(string str) + { + return ParseUnit(str, null); + } + + /// + /// Parse a unit string. + /// + /// String to parse. Typically in the form: {number} {unit} + /// Format to use when parsing number and unit. Defaults to if null. + /// + /// Length.ParseUnit("m", CultureInfo.GetCultureInfo("en-US")); + /// + /// The value of 'str' cannot be null. + /// Error parsing string. + public static FluidResistanceUnit ParseUnit(string str, IFormatProvider? provider) + { + return UnitParser.Default.Parse(str, provider); + } + + /// + public static bool TryParseUnit(string str, out FluidResistanceUnit unit) + { + return TryParseUnit(str, null, out unit); + } + + /// + /// Parse a unit string. + /// + /// String to parse. Typically in the form: {number} {unit} + /// The parsed unit if successful. + /// True if successful, otherwise false. + /// + /// Length.TryParseUnit("m", CultureInfo.GetCultureInfo("en-US")); + /// + /// Format to use when parsing number and unit. Defaults to if null. + public static bool TryParseUnit(string str, IFormatProvider? provider, out FluidResistanceUnit unit) + { + return UnitParser.Default.TryParse(str, provider, out unit); + } + + #endregion + + #region Arithmetic Operators + + /// Negate the value. + public static FluidResistance operator -(FluidResistance right) + { + return new FluidResistance(-right.Value, right.Unit); + } + + /// Get from adding two . + public static FluidResistance operator +(FluidResistance left, FluidResistance right) + { + return new FluidResistance(left.Value + right.ToUnit(left.Unit).Value, left.Unit); + } + + /// Get from subtracting two . + public static FluidResistance operator -(FluidResistance left, FluidResistance right) + { + return new FluidResistance(left.Value - right.ToUnit(left.Unit).Value, left.Unit); + } + + /// Get from multiplying value and . + public static FluidResistance operator *(double left, FluidResistance right) + { + return new FluidResistance(left * right.Value, right.Unit); + } + + /// Get from multiplying value and . + public static FluidResistance operator *(FluidResistance left, double right) + { + return new FluidResistance(left.Value * right, left.Unit); + } + + /// Get from dividing by value. + public static FluidResistance operator /(FluidResistance left, double right) + { + return new FluidResistance(left.Value / right, left.Unit); + } + + /// Get ratio value from dividing by . + public static double operator /(FluidResistance left, FluidResistance right) + { + return left.PascalSecondsPerCubicMeter / right.PascalSecondsPerCubicMeter; + } + + #endregion + + #region Equality / IComparable + + /// Returns true if less or equal to. + public static bool operator <=(FluidResistance left, FluidResistance right) + { + return left.Value <= right.ToUnit(left.Unit).Value; + } + + /// Returns true if greater than or equal to. + public static bool operator >=(FluidResistance left, FluidResistance right) + { + return left.Value >= right.ToUnit(left.Unit).Value; + } + + /// Returns true if less than. + public static bool operator <(FluidResistance left, FluidResistance right) + { + return left.Value < right.ToUnit(left.Unit).Value; + } + + /// Returns true if greater than. + public static bool operator >(FluidResistance left, FluidResistance right) + { + return left.Value > right.ToUnit(left.Unit).Value; + } + + // We use obsolete attribute to communicate the preferred equality members to use. + // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. + #pragma warning disable CS0809 + + /// Indicates strict equality of two quantities, where both and are exactly equal. + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(FluidResistance other, FluidResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + public static bool operator ==(FluidResistance left, FluidResistance right) + { + return left.Equals(right); + } + + /// Indicates strict inequality of two quantities, where both and are exactly equal. + [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(FluidResistance other, FluidResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + public static bool operator !=(FluidResistance left, FluidResistance right) + { + return !(left == right); + } + + /// + /// Indicates strict equality of two quantities, where both and are exactly equal. + [Obsolete("Use Equals(FluidResistance other, FluidResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + public override bool Equals(object? obj) + { + if (obj is null || !(obj is FluidResistance otherQuantity)) + return false; + + return Equals(otherQuantity); + } + + /// + /// Indicates strict equality of two quantities, where both and are exactly equal. + [Obsolete("Use Equals(FluidResistance other, FluidResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + public bool Equals(FluidResistance other) + { + return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + } + + #pragma warning restore CS0809 + + /// Compares the current with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. + /// An object to compare with this instance. + /// + /// is not the same type as this instance. + /// + /// A value that indicates the relative order of the quantities being compared. The return value has these meanings: + /// + /// Value Meaning + /// Less than zero This instance precedes in the sort order. + /// Zero This instance occurs in the same position in the sort order as . + /// Greater than zero This instance follows in the sort order. + /// + /// + public int CompareTo(object? obj) + { + if (obj is null) throw new ArgumentNullException(nameof(obj)); + if (!(obj is FluidResistance otherQuantity)) throw new ArgumentException("Expected type FluidResistance.", nameof(obj)); + + return CompareTo(otherQuantity); + } + + /// Compares the current with another and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. + /// A quantity to compare with this instance. + /// A value that indicates the relative order of the quantities being compared. The return value has these meanings: + /// + /// Value Meaning + /// Less than zero This instance precedes in the sort order. + /// Zero This instance occurs in the same position in the sort order as . + /// Greater than zero This instance follows in the sort order. + /// + /// + public int CompareTo(FluidResistance other) + { + return _value.CompareTo(other.ToUnit(this.Unit).Value); + } + + /// + /// + /// Compare equality to another FluidResistance within the given absolute or relative tolerance. + /// + /// + /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and + /// as a percentage of this quantity's value. will be converted into + /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of + /// this quantity's value to be considered equal. + /// + /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). + /// + /// var a = Length.FromMeters(2.0); + /// var b = Length.FromInches(50.0); + /// a.Equals(b, 0.01, ComparisonType.Relative); + /// + /// + /// + /// + /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and + /// as a fixed number in this quantity's unit. will be converted into + /// this quantity's unit for comparison. + /// + /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). + /// + /// var a = Length.FromMeters(2.0); + /// var b = Length.FromInches(50.0); + /// a.Equals(b, 0.01, ComparisonType.Absolute); + /// + /// + /// + /// + /// Note that it is advised against specifying zero difference, due to the nature + /// of floating-point operations and using double internally. + /// + /// + /// The other quantity to compare to. + /// The absolute or relative tolerance value. Must be greater than or equal to 0. + /// The comparison type: either relative or absolute. + /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. + [Obsolete("Use Equals(FluidResistance other, FluidResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + public bool Equals(FluidResistance other, double tolerance, ComparisonType comparisonType) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); + + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance, + comparisonType: comparisonType); + } + + /// + public bool Equals(IQuantity? other, IQuantity tolerance) + { + return other is FluidResistance otherTyped + && (tolerance is FluidResistance toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'FluidResistance'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(FluidResistance other, FluidResistance tolerance) + { + return UnitsNet.Comparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: tolerance.As(this.Unit), + comparisonType: ComparisonType.Absolute); + } + + /// + /// Returns the hash code for this instance. + /// + /// A hash code for the current FluidResistance. + public override int GetHashCode() + { + return new { Info.Name, Value, Unit }.GetHashCode(); + } + + #endregion + + #region Conversion Methods + + /// + /// Convert to the unit representation . + /// + /// Value converted to the specified unit. + public double As(FluidResistanceUnit unit) + { + if (Unit == unit) + return Value; + + return ToUnit(unit).Value; + } + + /// + public double As(UnitSystem unitSystem) + { + if (unitSystem is null) + throw new ArgumentNullException(nameof(unitSystem)); + + var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); + + var firstUnitInfo = unitInfos.FirstOrDefault(); + if (firstUnitInfo == null) + throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); + + return As(firstUnitInfo.Value); + } + + /// + double IQuantity.As(Enum unit) + { + if (!(unit is FluidResistanceUnit typedUnit)) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FluidResistanceUnit)} is supported.", nameof(unit)); + + return (double)As(typedUnit); + } + + /// + double IValueQuantity.As(Enum unit) + { + if (!(unit is FluidResistanceUnit typedUnit)) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FluidResistanceUnit)} is supported.", nameof(unit)); + + return As(typedUnit); + } + + /// + /// Converts this FluidResistance to another FluidResistance with the unit representation . + /// + /// The unit to convert to. + /// A FluidResistance with the specified unit. + public FluidResistance ToUnit(FluidResistanceUnit unit) + { + return ToUnit(unit, DefaultConversionFunctions); + } + + /// + /// Converts this to another using the given with the unit representation . + /// + /// The unit to convert to. + /// The to use for the conversion. + /// A FluidResistance with the specified unit. + public FluidResistance ToUnit(FluidResistanceUnit unit, UnitConverter unitConverter) + { + if (TryToUnit(unit, out var converted)) + { + // Try to convert using the auto-generated conversion methods. + return converted!.Value; + } + else if (unitConverter.TryGetConversionFunction((typeof(FluidResistance), Unit, typeof(FluidResistance), unit), out var conversionFunction)) + { + // See if the unit converter has an extensibility conversion registered. + return (FluidResistance)conversionFunction(this); + } + else if (Unit != BaseUnit) + { + // Conversion to requested unit NOT found. Try to convert to BaseUnit, and then from BaseUnit to requested unit. + var inBaseUnits = ToUnit(BaseUnit); + return inBaseUnits.ToUnit(unit); + } + else + { + // No possible conversion + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + } + } + + /// + /// Attempts to convert this to another with the unit representation . + /// + /// The unit to convert to. + /// The converted in , if successful. + /// True if successful, otherwise false. + private bool TryToUnit(FluidResistanceUnit unit, [NotNullWhen(true)] out FluidResistance? converted) + { + if (Unit == unit) + { + converted = this; + return true; + } + + FluidResistance? convertedOrNull = (Unit, unit) switch + { + // FluidResistanceUnit -> BaseUnit + (FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 1e-5, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.MegapascalSecondPerCubicMeter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 1e6, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 7.99934208e9, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 7.99934208e3, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.MillimeterMercuryMinutePerLiter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 7.99934208e6, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 7.99934208e9, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 1.33322368e8, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 133.322368, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.MillimeterMercurySecondPerLiter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 1.33322368e5, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.MillimeterMercurySecondPerMilliliter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 1.33322368e8, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.PascalMinutePerCubicCentimeter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 6e7, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.PascalMinutePerCubicMeter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 60, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.PascalMinutePerLiter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 6e4, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.PascalMinutePerMilliliter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 6e7, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.PascalSecondPerCubicCentimeter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 1e6, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.PascalSecondPerLiter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 1e3, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.PascalSecondPerMilliliter, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 1e6, FluidResistanceUnit.PascalSecondPerCubicMeter), + (FluidResistanceUnit.WoodUnit, FluidResistanceUnit.PascalSecondPerCubicMeter) => new FluidResistance(_value * 7.99934208e6, FluidResistanceUnit.PascalSecondPerCubicMeter), + + // BaseUnit -> FluidResistanceUnit + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth) => new FluidResistance(_value / 1e-5, FluidResistanceUnit.DyneSecondPerCentimeterToTheFifth), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MegapascalSecondPerCubicMeter) => new FluidResistance(_value / 1e6, FluidResistanceUnit.MegapascalSecondPerCubicMeter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter) => new FluidResistance(_value / 7.99934208e9, FluidResistanceUnit.MillimeterMercuryMinutePerCubicCentimeter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter) => new FluidResistance(_value / 7.99934208e3, FluidResistanceUnit.MillimeterMercuryMinutePerCubicMeter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercuryMinutePerLiter) => new FluidResistance(_value / 7.99934208e6, FluidResistanceUnit.MillimeterMercuryMinutePerLiter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter) => new FluidResistance(_value / 7.99934208e9, FluidResistanceUnit.MillimeterMercuryMinutePerMilliliter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter) => new FluidResistance(_value / 1.33322368e8, FluidResistanceUnit.MillimeterMercurySecondPerCubicCentimeter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter) => new FluidResistance(_value / 133.322368, FluidResistanceUnit.MillimeterMercurySecondPerCubicMeter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercurySecondPerLiter) => new FluidResistance(_value / 1.33322368e5, FluidResistanceUnit.MillimeterMercurySecondPerLiter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.MillimeterMercurySecondPerMilliliter) => new FluidResistance(_value / 1.33322368e8, FluidResistanceUnit.MillimeterMercurySecondPerMilliliter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalMinutePerCubicCentimeter) => new FluidResistance(_value / 6e7, FluidResistanceUnit.PascalMinutePerCubicCentimeter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalMinutePerCubicMeter) => new FluidResistance(_value / 60, FluidResistanceUnit.PascalMinutePerCubicMeter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalMinutePerLiter) => new FluidResistance(_value / 6e4, FluidResistanceUnit.PascalMinutePerLiter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalMinutePerMilliliter) => new FluidResistance(_value / 6e7, FluidResistanceUnit.PascalMinutePerMilliliter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalSecondPerCubicCentimeter) => new FluidResistance(_value / 1e6, FluidResistanceUnit.PascalSecondPerCubicCentimeter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalSecondPerLiter) => new FluidResistance(_value / 1e3, FluidResistanceUnit.PascalSecondPerLiter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.PascalSecondPerMilliliter) => new FluidResistance(_value / 1e6, FluidResistanceUnit.PascalSecondPerMilliliter), + (FluidResistanceUnit.PascalSecondPerCubicMeter, FluidResistanceUnit.WoodUnit) => new FluidResistance(_value / 7.99934208e6, FluidResistanceUnit.WoodUnit), + + _ => null + }; + + if (convertedOrNull is null) + { + converted = default; + return false; + } + + converted = convertedOrNull.Value; + return true; + } + + /// + IQuantity IQuantity.ToUnit(Enum unit) + { + if (!(unit is FluidResistanceUnit typedUnit)) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FluidResistanceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit, DefaultConversionFunctions); + } + + /// + public FluidResistance ToUnit(UnitSystem unitSystem) + { + if (unitSystem is null) + throw new ArgumentNullException(nameof(unitSystem)); + + var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); + + var firstUnitInfo = unitInfos.FirstOrDefault(); + if (firstUnitInfo == null) + throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); + + return ToUnit(firstUnitInfo.Value); + } + + /// + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + + /// + IQuantity IQuantity.ToUnit(FluidResistanceUnit unit) => ToUnit(unit); + + /// + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not FluidResistanceUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FluidResistanceUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + + #endregion + + #region ToString Methods + + /// + /// Gets the default string representation of value and unit. + /// + /// String representation. + public override string ToString() + { + return ToString("g"); + } + + /// + /// Gets the default string representation of value and unit using the given format provider. + /// + /// String representation. + /// Format to use for localization and number formatting. Defaults to if null. + public string ToString(IFormatProvider? provider) + { + return ToString("g", provider); + } + + /// + /// + /// Gets the string representation of this instance in the specified format string using . + /// + /// The format string. + /// The string representation. + public string ToString(string? format) + { + return ToString(format, CultureInfo.CurrentCulture); + } + + /// + /// + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// + /// The format string. + /// Format to use for localization and number formatting. Defaults to if null. + /// The string representation. + public string ToString(string? format, IFormatProvider? provider) + { + return QuantityFormatter.Format(this, format, provider); + } + + #endregion + + #region IConvertible Methods + + TypeCode IConvertible.GetTypeCode() + { + return TypeCode.Object; + } + + bool IConvertible.ToBoolean(IFormatProvider? provider) + { + throw new InvalidCastException($"Converting {typeof(FluidResistance)} to bool is not supported."); + } + + byte IConvertible.ToByte(IFormatProvider? provider) + { + return Convert.ToByte(_value); + } + + char IConvertible.ToChar(IFormatProvider? provider) + { + throw new InvalidCastException($"Converting {typeof(FluidResistance)} to char is not supported."); + } + + DateTime IConvertible.ToDateTime(IFormatProvider? provider) + { + throw new InvalidCastException($"Converting {typeof(FluidResistance)} to DateTime is not supported."); + } + + decimal IConvertible.ToDecimal(IFormatProvider? provider) + { + return Convert.ToDecimal(_value); + } + + double IConvertible.ToDouble(IFormatProvider? provider) + { + return Convert.ToDouble(_value); + } + + short IConvertible.ToInt16(IFormatProvider? provider) + { + return Convert.ToInt16(_value); + } + + int IConvertible.ToInt32(IFormatProvider? provider) + { + return Convert.ToInt32(_value); + } + + long IConvertible.ToInt64(IFormatProvider? provider) + { + return Convert.ToInt64(_value); + } + + sbyte IConvertible.ToSByte(IFormatProvider? provider) + { + return Convert.ToSByte(_value); + } + + float IConvertible.ToSingle(IFormatProvider? provider) + { + return Convert.ToSingle(_value); + } + + string IConvertible.ToString(IFormatProvider? provider) + { + return ToString("g", provider); + } + + object IConvertible.ToType(Type conversionType, IFormatProvider? provider) + { + if (conversionType == typeof(FluidResistance)) + return this; + else if (conversionType == typeof(FluidResistanceUnit)) + return Unit; + else if (conversionType == typeof(QuantityInfo)) + return FluidResistance.Info; + else if (conversionType == typeof(BaseDimensions)) + return FluidResistance.BaseDimensions; + else + throw new InvalidCastException($"Converting {typeof(FluidResistance)} to {conversionType} is not supported."); + } + + ushort IConvertible.ToUInt16(IFormatProvider? provider) + { + return Convert.ToUInt16(_value); + } + + uint IConvertible.ToUInt32(IFormatProvider? provider) + { + return Convert.ToUInt32(_value); + } + + ulong IConvertible.ToUInt64(IFormatProvider? provider) + { + return Convert.ToUInt64(_value); + } + + #endregion + } +} diff --git a/UnitsNet/GeneratedCode/Quantity.g.cs b/UnitsNet/GeneratedCode/Quantity.g.cs index e7818004ee..fda5b07dbe 100644 --- a/UnitsNet/GeneratedCode/Quantity.g.cs +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -85,6 +85,7 @@ public partial class Quantity { "Energy", Energy.Info }, { "EnergyDensity", EnergyDensity.Info }, { "Entropy", Entropy.Info }, + { "FluidResistance", FluidResistance.Info }, { "Force", Force.Info }, { "ForceChangeRate", ForceChangeRate.Info }, { "ForcePerLength", ForcePerLength.Info }, @@ -231,6 +232,7 @@ public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValu "Energy" => Energy.From(value, Energy.BaseUnit), "EnergyDensity" => EnergyDensity.From(value, EnergyDensity.BaseUnit), "Entropy" => Entropy.From(value, Entropy.BaseUnit), + "FluidResistance" => FluidResistance.From(value, FluidResistance.BaseUnit), "Force" => Force.From(value, Force.BaseUnit), "ForceChangeRate" => ForceChangeRate.From(value, ForceChangeRate.BaseUnit), "ForcePerLength" => ForcePerLength.From(value, ForcePerLength.BaseUnit), @@ -380,6 +382,7 @@ public static bool TryFrom(QuantityValue value, Enum? unit, [NotNullWhen(true)] EnergyUnit energyUnit => Energy.From(value, energyUnit), EnergyDensityUnit energyDensityUnit => EnergyDensity.From(value, energyDensityUnit), EntropyUnit entropyUnit => Entropy.From(value, entropyUnit), + FluidResistanceUnit fluidResistanceUnit => FluidResistance.From(value, fluidResistanceUnit), ForceUnit forceUnit => Force.From(value, forceUnit), ForceChangeRateUnit forceChangeRateUnit => ForceChangeRate.From(value, forceChangeRateUnit), ForcePerLengthUnit forcePerLengthUnit => ForcePerLength.From(value, forcePerLengthUnit), @@ -539,6 +542,7 @@ public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, Type _ when quantityType == typeof(Energy) => parser.TryParse(quantityString, formatProvider, Energy.From, out quantity), Type _ when quantityType == typeof(EnergyDensity) => parser.TryParse(quantityString, formatProvider, EnergyDensity.From, out quantity), Type _ when quantityType == typeof(Entropy) => parser.TryParse(quantityString, formatProvider, Entropy.From, out quantity), + Type _ when quantityType == typeof(FluidResistance) => parser.TryParse(quantityString, formatProvider, FluidResistance.From, out quantity), Type _ when quantityType == typeof(Force) => parser.TryParse(quantityString, formatProvider, Force.From, out quantity), Type _ when quantityType == typeof(ForceChangeRate) => parser.TryParse(quantityString, formatProvider, ForceChangeRate.From, out quantity), Type _ when quantityType == typeof(ForcePerLength) => parser.TryParse(quantityString, formatProvider, ForcePerLength.From, out quantity), @@ -679,6 +683,7 @@ internal static IEnumerable GetQuantityTypes() yield return typeof(Energy); yield return typeof(EnergyDensity); yield return typeof(Entropy); + yield return typeof(FluidResistance); yield return typeof(Force); yield return typeof(ForceChangeRate); yield return typeof(ForcePerLength); diff --git a/UnitsNet/GeneratedCode/Resources/FluidResistance.restext b/UnitsNet/GeneratedCode/Resources/FluidResistance.restext new file mode 100644 index 0000000000..c5bf663897 --- /dev/null +++ b/UnitsNet/GeneratedCode/Resources/FluidResistance.restext @@ -0,0 +1,19 @@ +DyneSecondsPerCentimeterToTheFifth=dyn·s/cm⁵,dyn·s·cm⁻⁵ +MegapascalSecondsPerCubicMeter=MPa·s/m³ +MillimeterMercuryMinutesPerCubicCentimeter=mmHg·min/cm³ +MillimeterMercuryMinutesPerCubicMeter=mmHg·min/m³ +MillimeterMercuryMinutesPerLiter=mmHg·min/l +MillimeterMercuryMinutesPerMilliliter=mmHg·min/ml +MillimeterMercurySecondsPerCubicCentimeter=mmHg·s/cm³ +MillimeterMercurySecondsPerCubicMeter=mmHg·s/m³ +MillimeterMercurySecondsPerLiter=mmHg·s/l +MillimeterMercurySecondsPerMilliliter=mmHg·s/ml +PascalMinutesPerCubicCentimeter=Pa·min/cm³ +PascalMinutesPerCubicMeter=Pa·min/m³ +PascalMinutesPerLiter=Pa·min/l +PascalMinutesPerMilliliter=Pa·min/ml +PascalSecondsPerCubicCentimeter=Pa·s/cm³ +PascalSecondsPerCubicMeter=Pa·s/m³ +PascalSecondsPerLiter=Pa·s/l +PascalSecondsPerMilliliter=Pa·s/ml +WoodUnits=WU,HRU diff --git a/UnitsNet/GeneratedCode/Resources/FluidResistance.ru-RU.restext b/UnitsNet/GeneratedCode/Resources/FluidResistance.ru-RU.restext new file mode 100644 index 0000000000..4e1d1cc926 --- /dev/null +++ b/UnitsNet/GeneratedCode/Resources/FluidResistance.ru-RU.restext @@ -0,0 +1,19 @@ +DyneSecondsPerCentimeterToTheFifth=дин·с/см⁵,дин·с·см⁻⁵ +MegapascalSecondsPerCubicMeter=МПа·с/м³ +MillimeterMercuryMinutesPerCubicCentimeter=мм рт.ст·мин/см³ +MillimeterMercuryMinutesPerCubicMeter=мм рт.ст·мин/м³ +MillimeterMercuryMinutesPerLiter=мм рт.ст·мин/л +MillimeterMercuryMinutesPerMilliliter=мм рт.ст·мин/мл +MillimeterMercurySecondsPerCubicCentimeter=мм рт.ст·с/см³ +MillimeterMercurySecondsPerCubicMeter=мм рт.ст·с/м³ +MillimeterMercurySecondsPerLiter=мм рт.ст·с/л +MillimeterMercurySecondsPerMilliliter=мм рт.ст·с/мл +PascalMinutesPerCubicCentimeter=Па·мин/см³ +PascalMinutesPerCubicMeter=Па·мин/м³ +PascalMinutesPerLiter=Па·мин/л +PascalMinutesPerMilliliter=Па·мин/мл +PascalSecondsPerCubicCentimeter=Па·с/см³ +PascalSecondsPerCubicMeter=Па·с/м³ +PascalSecondsPerLiter=Па·с/л +PascalSecondsPerMilliliter=Па·с/мл +WoodUnits=ЕВ,ЕГС diff --git a/UnitsNet/GeneratedCode/Units/FluidResistanceUnit.g.cs b/UnitsNet/GeneratedCode/Units/FluidResistanceUnit.g.cs new file mode 100644 index 0000000000..a32cb873c5 --- /dev/null +++ b/UnitsNet/GeneratedCode/Units/FluidResistanceUnit.g.cs @@ -0,0 +1,53 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Units +{ + // Disable missing XML comment warnings for the generated unit enums. + #pragma warning disable 1591 + + public enum FluidResistanceUnit + { + /// https://en.wikipedia.org/wiki/Vascular_resistance + DyneSecondPerCentimeterToTheFifth = 6, + /// https://en.wikipedia.org/wiki/Vascular_resistance + MegapascalSecondPerCubicMeter = 7, + MillimeterMercuryMinutePerCubicCentimeter = 3, + MillimeterMercuryMinutePerCubicMeter = 5, + MillimeterMercuryMinutePerLiter = 2, + MillimeterMercuryMinutePerMilliliter = 9, + MillimeterMercurySecondPerCubicCentimeter = 8, + MillimeterMercurySecondPerCubicMeter = 10, + MillimeterMercurySecondPerLiter = 4, + MillimeterMercurySecondPerMilliliter = 1, + PascalMinutePerCubicCentimeter = 19, + PascalMinutePerCubicMeter = 16, + PascalMinutePerLiter = 15, + PascalMinutePerMilliliter = 12, + PascalSecondPerCubicCentimeter = 18, + PascalSecondPerCubicMeter = 13, + PascalSecondPerLiter = 11, + PascalSecondPerMilliliter = 20, + /// https://en.wikipedia.org/wiki/Vascular_resistance + WoodUnit = 17, + } + + #pragma warning restore 1591 +}