diff --git a/Common/UnitDefinitions/Molality.json b/Common/UnitDefinitions/Molality.json
new file mode 100644
index 0000000000..d28ac2c9c5
--- /dev/null
+++ b/Common/UnitDefinitions/Molality.json
@@ -0,0 +1,44 @@
+{
+ "Name": "Molality",
+ "BaseUnit": "MolePerKilogram",
+ "XmlDocSummary": "Molality is a measure of the amount of solute in a solution relative to a given mass of solvent.",
+ "XmlDocRemarks": "https://en.wikipedia.org/wiki/Molality",
+ "BaseDimensions": {
+ "N": 1,
+ "M": -1
+ },
+ "Units": [
+ {
+ "SingularName": "MolePerKilogram",
+ "PluralName": "MolesPerKilogram",
+ "BaseUnits": {
+ "N": "Mole",
+ "M": "Kilogram"
+ },
+ "FromUnitToBaseFunc": "{x}",
+ "FromBaseToUnitFunc": "{x}",
+ "Localization": [
+ {
+ "Culture": "en-US",
+ "Abbreviations": [ "mol/kg" ]
+ }
+ ]
+ },
+ {
+ "SingularName": "MolePerGram",
+ "PluralName": "MolesPerGram",
+ "BaseUnits": {
+ "N": "Mole",
+ "M": "Gram"
+ },
+ "FromUnitToBaseFunc": "{x} / 1e-3",
+ "FromBaseToUnitFunc": "{x} * 1e-3",
+ "Localization": [
+ {
+ "Culture": "en-US",
+ "Abbreviations": [ "mol/g" ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/Common/UnitEnumValues.g.json b/Common/UnitEnumValues.g.json
index 13e827c58c..bb6b5d565a 100644
--- a/Common/UnitEnumValues.g.json
+++ b/Common/UnitEnumValues.g.json
@@ -1790,5 +1790,9 @@
"Picogray": 11,
"Rad": 17,
"Teragray": 14
+ },
+ "Molality": {
+ "MolePerGram": 4,
+ "MolePerKilogram": 1
}
}
diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molality/Molality.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Molality/Molality.nfproj
new file mode 100644
index 0000000000..0a503cfec7
--- /dev/null
+++ b/UnitsNet.NanoFramework/GeneratedCode/Molality/Molality.nfproj
@@ -0,0 +1,42 @@
+
+
+
+ $(MSBuildExtensionsPath)\nanoFramework\v1.0\
+
+
+
+ Debug
+ AnyCPU
+ {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ {589b202c-e638-5c93-fefe-e1e3bab4a493}
+ Library
+ Properties
+ 512
+ UnitsNet
+ UnitsNet.Molality
+ v1.0
+ bin\$(Configuration)\$(AssemblyName).xml
+
+
+
+
+
+
+
+
+
+ ..\packages\nanoFramework.CoreLibrary.1.15.5\lib\mscorlib.dll
+ True
+ True
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molality/UnitsNet.NanoFramework.Molality.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Molality/UnitsNet.NanoFramework.Molality.nuspec
new file mode 100644
index 0000000000..4cbc203ae2
--- /dev/null
+++ b/UnitsNet.NanoFramework/GeneratedCode/Molality/UnitsNet.NanoFramework.Molality.nuspec
@@ -0,0 +1,26 @@
+
+
+
+ UnitsNet.nanoFramework.Molality
+ 5.39.0
+ Units.NET Molality - nanoFramework
+ Andreas Gullberg Larsen,nanoframework
+ UnitsNet
+ MIT
+ https://github.com/angularsen/UnitsNet
+ false
+ Adds Molality 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 molality unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable
+
+
+
+
+
+
+
+
diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molality/packages.config b/UnitsNet.NanoFramework/GeneratedCode/Molality/packages.config
new file mode 100644
index 0000000000..313a8dccdf
--- /dev/null
+++ b/UnitsNet.NanoFramework/GeneratedCode/Molality/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molality.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molality.g.cs
new file mode 100644
index 0000000000..60a5ac28d2
--- /dev/null
+++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molality.g.cs
@@ -0,0 +1,175 @@
+//------------------------------------------------------------------------------
+//
+// 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
+{
+ ///
+ ///
+ /// Molality is a measure of the amount of solute in a solution relative to a given mass of solvent.
+ ///
+ ///
+ /// https://en.wikipedia.org/wiki/Molality
+ ///
+ public struct Molality
+ {
+ ///
+ /// The numeric value this quantity was constructed with.
+ ///
+ private readonly double _value;
+
+ ///
+ /// The unit this quantity was constructed with.
+ ///
+ private readonly MolalityUnit _unit;
+
+ ///
+ /// The numeric value this quantity was constructed with.
+ ///
+ public double Value => _value;
+
+ ///
+ public MolalityUnit 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 Molality(double value, MolalityUnit unit)
+ {
+ _value = value;
+ _unit = unit;
+ }
+
+ ///
+ /// The base unit of Duration, which is Second. All conversions go via this value.
+ ///
+ public static MolalityUnit BaseUnit { get; } = MolalityUnit.MolePerKilogram;
+
+ ///
+ /// Represents the largest possible value of Duration
+ ///
+ public static Molality MaxValue { get; } = new Molality(double.MaxValue, BaseUnit);
+
+ ///
+ /// Represents the smallest possible value of Duration
+ ///
+ public static Molality MinValue { get; } = new Molality(double.MinValue, BaseUnit);
+
+ ///
+ /// Gets an instance of this quantity with a value of 0 in the base unit Second.
+ ///
+ public static Molality Zero { get; } = new Molality(0, BaseUnit);
+ #region Conversion Properties
+
+ ///
+ /// Gets a value of this quantity converted into
+ ///
+ public double MolesPerGram => As(MolalityUnit.MolePerGram);
+
+ ///
+ /// Gets a value of this quantity converted into
+ ///
+ public double MolesPerKilogram => As(MolalityUnit.MolePerKilogram);
+
+ #endregion
+
+ #region Static Factory Methods
+
+ ///
+ /// Creates a from .
+ ///
+ /// If value is NaN or Infinity.
+ public static Molality FromMolesPerGram(double molespergram) => new Molality(molespergram, MolalityUnit.MolePerGram);
+
+ ///
+ /// Creates a from .
+ ///
+ /// If value is NaN or Infinity.
+ public static Molality FromMolesPerKilogram(double molesperkilogram) => new Molality(molesperkilogram, MolalityUnit.MolePerKilogram);
+
+ ///
+ /// Dynamically convert from value and unit enum to .
+ ///
+ /// Value to convert from.
+ /// Unit to convert from.
+ /// Molality unit value.
+ public static Molality From(double value, MolalityUnit fromUnit)
+ {
+ return new Molality(value, fromUnit);
+ }
+
+ #endregion
+
+ #region Conversion Methods
+
+ ///
+ /// Convert to the unit representation .
+ ///
+ /// Value converted to the specified unit.
+ public double As(MolalityUnit unit) => GetValueAs(unit);
+
+ ///
+ /// Converts this Duration to another Duration with the unit representation .
+ ///
+ /// A Duration with the specified unit.
+ public Molality ToUnit(MolalityUnit unit)
+ {
+ var convertedValue = GetValueAs(unit);
+ return new Molality(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
+ {
+ MolalityUnit.MolePerGram => _value / 1e-3,
+ MolalityUnit.MolePerKilogram => _value,
+ _ => throw new NotImplementedException($"Can not convert {Unit} to base units.")
+ };
+ }
+
+ private double GetValueAs(MolalityUnit unit)
+ {
+ if (Unit == unit)
+ return _value;
+
+ var baseUnitValue = GetValueInBaseUnit();
+
+ return unit switch
+ {
+ MolalityUnit.MolePerGram => baseUnitValue * 1e-3,
+ MolalityUnit.MolePerKilogram => baseUnitValue,
+ _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.")
+ };
+ }
+
+ #endregion
+ }
+}
+
diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MolalityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MolalityUnit.g.cs
new file mode 100644
index 0000000000..e3644e273d
--- /dev/null
+++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MolalityUnit.g.cs
@@ -0,0 +1,33 @@
+//------------------------------------------------------------------------------
+//
+// 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 MolalityUnit
+ {
+ MolePerGram = 4,
+ MolePerKilogram = 1,
+ }
+
+ #pragma warning restore 1591
+}
diff --git a/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln b/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln
index f89c957a9e..a69d7513b2 100644
--- a/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln
+++ b/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln
@@ -142,6 +142,8 @@ Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "MassFraction", "MassFractio
EndProject
Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "MassMomentOfInertia", "MassMomentOfInertia\MassMomentOfInertia.nfproj", "{6218c061-3905-79b2-d3bc-bb7b8fc77a69}"
EndProject
+Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "Molality", "Molality\Molality.nfproj", "{589b202c-e638-5c93-fefe-e1e3bab4a493}"
+EndProject
Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "MolarEnergy", "MolarEnergy\MolarEnergy.nfproj", "{9b77d4e0-863d-4a74-c30a-56f7b2bb7cb7}"
EndProject
Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "MolarEntropy", "MolarEntropy\MolarEntropy.nfproj", "{2053731b-90f5-5141-d15e-8d7be8c2662f}"
@@ -668,6 +670,12 @@ Global
{6218c061-3905-79b2-d3bc-bb7b8fc77a69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6218c061-3905-79b2-d3bc-bb7b8fc77a69}.Release|Any CPU.Build.0 = Release|Any CPU
{6218c061-3905-79b2-d3bc-bb7b8fc77a69}.Release|Any CPU.Deploy.0 = Release|Any CPU
+{589b202c-e638-5c93-fefe-e1e3bab4a493}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+{589b202c-e638-5c93-fefe-e1e3bab4a493}.Debug|Any CPU.Build.0 = Debug|Any CPU
+{589b202c-e638-5c93-fefe-e1e3bab4a493}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+{589b202c-e638-5c93-fefe-e1e3bab4a493}.Release|Any CPU.ActiveCfg = Release|Any CPU
+{589b202c-e638-5c93-fefe-e1e3bab4a493}.Release|Any CPU.Build.0 = Release|Any CPU
+{589b202c-e638-5c93-fefe-e1e3bab4a493}.Release|Any CPU.Deploy.0 = Release|Any CPU
{9b77d4e0-863d-4a74-c30a-56f7b2bb7cb7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9b77d4e0-863d-4a74-c30a-56f7b2bb7cb7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9b77d4e0-863d-4a74-c30a-56f7b2bb7cb7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolalityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolalityExtensionsTest.g.cs
new file mode 100644
index 0000000000..ed269bda36
--- /dev/null
+++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolalityExtensionsTest.g.cs
@@ -0,0 +1,36 @@
+//------------------------------------------------------------------------------
+//
+// 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.NumberToMolality;
+using Xunit;
+
+namespace UnitsNet.Tests
+{
+ public class NumberToMolalityExtensionsTests
+ {
+ [Fact]
+ public void NumberToMolesPerGramTest() =>
+ Assert.Equal(Molality.FromMolesPerGram(2), 2.MolesPerGram());
+
+ [Fact]
+ public void NumberToMolesPerKilogramTest() =>
+ Assert.Equal(Molality.FromMolesPerKilogram(2), 2.MolesPerKilogram());
+
+ }
+}
diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolalityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolalityExtensions.g.cs
new file mode 100644
index 0000000000..5082f28861
--- /dev/null
+++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolalityExtensions.g.cs
@@ -0,0 +1,52 @@
+//------------------------------------------------------------------------------
+//
+// 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.NumberToMolality
+{
+ ///
+ /// A number to Molality Extensions
+ ///
+ public static class NumberToMolalityExtensions
+ {
+ ///
+ public static Molality MolesPerGram(this T value)
+ where T : notnull
+#if NET7_0_OR_GREATER
+ , INumber
+#endif
+ => Molality.FromMolesPerGram(Convert.ToDouble(value));
+
+ ///
+ public static Molality MolesPerKilogram(this T value)
+ where T : notnull
+#if NET7_0_OR_GREATER
+ , INumber
+#endif
+ => Molality.FromMolesPerKilogram(Convert.ToDouble(value));
+
+ }
+}
diff --git a/UnitsNet.Tests/CustomCode/MolalityTests.cs b/UnitsNet.Tests/CustomCode/MolalityTests.cs
new file mode 100644
index 0000000000..2817ef19e3
--- /dev/null
+++ b/UnitsNet.Tests/CustomCode/MolalityTests.cs
@@ -0,0 +1,15 @@
+// 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 MolalityTests : MolalityTestsBase
+ {
+ protected override bool SupportsSIUnitSystem => true;
+
+ protected override double MolesPerKilogramInOneMolePerKilogram => 1;
+ protected override double MolesPerGramInOneMolePerKilogram => 1e-3;
+ }
+}
diff --git a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs
index 50b1767879..c1a2c2e2d2 100644
--- a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs
@@ -104,6 +104,7 @@ void Assertion(int expectedValue, Enum expectedUnit, IQuantity quantity)
Assertion(3, MassFluxUnit.KilogramPerSecondPerSquareMillimeter, Quantity.From(3, MassFluxUnit.KilogramPerSecondPerSquareMillimeter));
Assertion(3, MassFractionUnit.Percent, Quantity.From(3, MassFractionUnit.Percent));
Assertion(3, MassMomentOfInertiaUnit.TonneSquareMilimeter, Quantity.From(3, MassMomentOfInertiaUnit.TonneSquareMilimeter));
+ Assertion(3, MolalityUnit.MolePerKilogram, Quantity.From(3, MolalityUnit.MolePerKilogram));
Assertion(3, MolarEnergyUnit.MegajoulePerMole, Quantity.From(3, MolarEnergyUnit.MegajoulePerMole));
Assertion(3, MolarEntropyUnit.MegajoulePerMoleKelvin, Quantity.From(3, MolarEntropyUnit.MegajoulePerMoleKelvin));
Assertion(3, MolarFlowUnit.PoundMolePerSecond, Quantity.From(3, MolarFlowUnit.PoundMolePerSecond));
@@ -231,6 +232,7 @@ public void QuantityInfo_IsSameAsStaticInfoProperty()
Assertion(MassFlux.Info, MassFlux.Zero);
Assertion(MassFraction.Info, MassFraction.Zero);
Assertion(MassMomentOfInertia.Info, MassMomentOfInertia.Zero);
+ Assertion(Molality.Info, Molality.Zero);
Assertion(MolarEnergy.Info, MolarEnergy.Zero);
Assertion(MolarEntropy.Info, MolarEntropy.Zero);
Assertion(MolarFlow.Info, MolarFlow.Zero);
@@ -358,6 +360,7 @@ public void Dimensions_IsSameAsStaticBaseDimensions()
Assertion(MassFlux.BaseDimensions, MassFlux.Zero);
Assertion(MassFraction.BaseDimensions, MassFraction.Zero);
Assertion(MassMomentOfInertia.BaseDimensions, MassMomentOfInertia.Zero);
+ Assertion(Molality.BaseDimensions, Molality.Zero);
Assertion(MolarEnergy.BaseDimensions, MolarEnergy.Zero);
Assertion(MolarEntropy.BaseDimensions, MolarEntropy.Zero);
Assertion(MolarFlow.BaseDimensions, MolarFlow.Zero);
diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs
new file mode 100644
index 0000000000..d8dec9a2d0
--- /dev/null
+++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs
@@ -0,0 +1,668 @@
+//------------------------------------------------------------------------------
+//
+// 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 Molality.
+ ///
+// ReSharper disable once PartialTypeWithSinglePart
+ public abstract partial class MolalityTestsBase : QuantityTestsBase
+ {
+ protected abstract double MolesPerGramInOneMolePerKilogram { get; }
+ protected abstract double MolesPerKilogramInOneMolePerKilogram { get; }
+
+// ReSharper disable VirtualMemberNeverOverriden.Global
+ protected virtual double MolesPerGramTolerance { get { return 1e-5; } }
+ protected virtual double MolesPerKilogramTolerance { get { return 1e-5; } }
+// ReSharper restore VirtualMemberNeverOverriden.Global
+
+ protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MolalityUnit unit)
+ {
+ return unit switch
+ {
+ MolalityUnit.MolePerGram => (MolesPerGramInOneMolePerKilogram, MolesPerGramTolerance),
+ MolalityUnit.MolePerKilogram => (MolesPerKilogramInOneMolePerKilogram, MolesPerKilogramTolerance),
+ _ => throw new NotSupportedException()
+ };
+ }
+
+ public static IEnumerable