diff --git a/Common/UnitDefinitions/TorquePerLength.json b/Common/UnitDefinitions/TorquePerLength.json deleted file mode 100644 index 89728fdc7f..0000000000 --- a/Common/UnitDefinitions/TorquePerLength.json +++ /dev/null @@ -1,155 +0,0 @@ -{ - "Name": "TorquePerLength", - "BaseUnit": "NewtonMeterPerMeter", - "XmlDocSummary": "The magnitude of torque per unit length.", - "BaseDimensions": { - "L": 1, - "M": 1, - "T": -2 - }, - "Units": [ - { - "SingularName": "NewtonMillimeterPerMeter", - "PluralName": "NewtonMillimetersPerMeter", - "FromUnitToBaseFunc": "{x} * 0.001", - "FromBaseToUnitFunc": "{x} * 1000", - "Prefixes": [ "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "N·mm/m" ] - } - ] - }, - { - "SingularName": "NewtonCentimeterPerMeter", - "PluralName": "NewtonCentimetersPerMeter", - "FromUnitToBaseFunc": "{x} * 0.01", - "FromBaseToUnitFunc": "{x} * 100", - "Prefixes": [ "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "N·cm/m" ] - } - ] - }, - { - "SingularName": "NewtonMeterPerMeter", - "PluralName": "NewtonMetersPerMeter", - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", - "Prefixes": [ "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "N·m/m" ] - }, - { - "Culture": "ru-RU", - "Abbreviations": [ "Н·м/м" ] - } - ] - }, - { - "SingularName": "PoundForceInchPerFoot", - "PluralName": "PoundForceInchesPerFoot", - "FromUnitToBaseFunc": "{x} * 0.370685147638", - "FromBaseToUnitFunc": "{x} / 0.370685147638", - "Prefixes": [ "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "lbf·in/ft" ], - "AbbreviationsForPrefixes": { "Kilo": "kipf·in/ft" } - } - ] - }, - { - "SingularName": "PoundForceFootPerFoot", - "PluralName": "PoundForceFeetPerFoot", - "FromUnitToBaseFunc": "{x} * 4.44822161526", - "FromBaseToUnitFunc": "{x} / 4.44822161526", - "Prefixes": [ "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "lbf·ft/ft" ], - "AbbreviationsForPrefixes": { "Kilo": "kipf·ft/ft" } - } - ] - }, - { - "SingularName": "KilogramForceMillimeterPerMeter", - "PluralName": "KilogramForceMillimetersPerMeter", - "FromUnitToBaseFunc": "{x} * 0.00980665019960652", - "FromBaseToUnitFunc": "{x} * 101.971619222242", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "kgf·mm/m" ] - } - ] - }, - { - "SingularName": "KilogramForceCentimeterPerMeter", - "PluralName": "KilogramForceCentimetersPerMeter", - "FromUnitToBaseFunc": "{x} * 0.0980665019960652", - "FromBaseToUnitFunc": "{x} * 10.1971619222242", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "kgf·cm/m" ] - } - ] - }, - { - "SingularName": "KilogramForceMeterPerMeter", - "PluralName": "KilogramForceMetersPerMeter", - "FromUnitToBaseFunc": "{x} * 9.80665019960652", - "FromBaseToUnitFunc": "{x} * 0.101971619222242", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "kgf·m/m" ] - } - ] - }, - { - "SingularName": "TonneForceMillimeterPerMeter", - "PluralName": "TonneForceMillimetersPerMeter", - "FromUnitToBaseFunc": "{x} * 9.80665019960652", - "FromBaseToUnitFunc": "{x} * 0.101971619222242", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "tf·mm/m" ] - } - ] - }, - { - "SingularName": "TonneForceCentimeterPerMeter", - "PluralName": "TonneForceCentimetersPerMeter", - "FromUnitToBaseFunc": "{x} * 98.0665019960652", - "FromBaseToUnitFunc": "{x} * 0.0101971619222242", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "tf·cm/m" ] - } - ] - }, - { - "SingularName": "TonneForceMeterPerMeter", - "PluralName": "TonneForceMetersPerMeter", - "FromUnitToBaseFunc": "{x} * 9806.65019960653", - "FromBaseToUnitFunc": "{x} * 0.000101971619222242", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "tf·m/m" ] - } - ] - } - ] -} diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/TorquePerLength.nfproj b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/TorquePerLength.nfproj deleted file mode 100644 index 249aa5a53d..0000000000 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/TorquePerLength.nfproj +++ /dev/null @@ -1,42 +0,0 @@ - - - - $(MSBuildExtensionsPath)\nanoFramework\v1.0\ - - - - Debug - AnyCPU - {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - {c27e1919-64f1-ce81-c6d9-b46ced745a12} - Library - Properties - 512 - UnitsNet - UnitsNet.TorquePerLength - v1.0 - bin\$(Configuration)\$(AssemblyName).xml - - - - - - - - - - ..\packages\nanoFramework.CoreLibrary.1.15.5\lib\mscorlib.dll - True - True - - - - - - - - - - - - diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec deleted file mode 100644 index d98c09edab..0000000000 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec +++ /dev/null @@ -1,26 +0,0 @@ - - - - UnitsNet.nanoFramework.TorquePerLength - 6.0.0-pre012 - Units.NET TorquePerLength - nanoFramework - Andreas Gullberg Larsen,nanoframework - UnitsNet - MIT-0 - https://github.com/angularsen/UnitsNet - false - Adds TorquePerLength 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 torqueperlength unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - - - - - - - - diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/packages.config b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/packages.config deleted file mode 100644 index 313a8dccdf..0000000000 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln b/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln index d64098f57d..6317d09a09 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln +++ b/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln @@ -230,8 +230,6 @@ Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "ThermalResistance", "Therma EndProject Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "Torque", "Torque\Torque.nfproj", "{3b6bbc8a-1b22-deff-2980-53b77b6f3e5f}" EndProject -Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "TorquePerLength", "TorquePerLength\TorquePerLength.nfproj", "{c27e1919-64f1-ce81-c6d9-b46ced745a12}" -EndProject Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "Turbidity", "Turbidity\Turbidity.nfproj", "{05ac8aed-49a4-5c9f-d8c2-8d2debf64791}" EndProject Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "VitaminA", "VitaminA\VitaminA.nfproj", "{c00185af-8735-7674-5fa6-232424b04161}" @@ -940,12 +938,6 @@ Global {3b6bbc8a-1b22-deff-2980-53b77b6f3e5f}.Release|Any CPU.ActiveCfg = Release|Any CPU {3b6bbc8a-1b22-deff-2980-53b77b6f3e5f}.Release|Any CPU.Build.0 = Release|Any CPU {3b6bbc8a-1b22-deff-2980-53b77b6f3e5f}.Release|Any CPU.Deploy.0 = Release|Any CPU -{c27e1919-64f1-ce81-c6d9-b46ced745a12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU -{c27e1919-64f1-ce81-c6d9-b46ced745a12}.Debug|Any CPU.Build.0 = Debug|Any CPU -{c27e1919-64f1-ce81-c6d9-b46ced745a12}.Debug|Any CPU.Deploy.0 = Debug|Any CPU -{c27e1919-64f1-ce81-c6d9-b46ced745a12}.Release|Any CPU.ActiveCfg = Release|Any CPU -{c27e1919-64f1-ce81-c6d9-b46ced745a12}.Release|Any CPU.Build.0 = Release|Any CPU -{c27e1919-64f1-ce81-c6d9-b46ced745a12}.Release|Any CPU.Deploy.0 = Release|Any CPU {05ac8aed-49a4-5c9f-d8c2-8d2debf64791}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {05ac8aed-49a4-5c9f-d8c2-8d2debf64791}.Debug|Any CPU.Build.0 = Debug|Any CPU {05ac8aed-49a4-5c9f-d8c2-8d2debf64791}.Debug|Any CPU.Deploy.0 = Debug|Any CPU diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTorquePerLengthExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTorquePerLengthExtensionsTest.g.cs deleted file mode 100644 index a86e82f967..0000000000 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTorquePerLengthExtensionsTest.g.cs +++ /dev/null @@ -1,112 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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.NumberToTorquePerLength; -using Xunit; - -namespace UnitsNet.Tests -{ - public class NumberToTorquePerLengthExtensionsTests - { - [Fact] - public void NumberToKilogramForceCentimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromKilogramForceCentimetersPerMeter(2), 2.KilogramForceCentimetersPerMeter()); - - [Fact] - public void NumberToKilogramForceMetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromKilogramForceMetersPerMeter(2), 2.KilogramForceMetersPerMeter()); - - [Fact] - public void NumberToKilogramForceMillimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromKilogramForceMillimetersPerMeter(2), 2.KilogramForceMillimetersPerMeter()); - - [Fact] - public void NumberToKilonewtonCentimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromKilonewtonCentimetersPerMeter(2), 2.KilonewtonCentimetersPerMeter()); - - [Fact] - public void NumberToKilonewtonMetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromKilonewtonMetersPerMeter(2), 2.KilonewtonMetersPerMeter()); - - [Fact] - public void NumberToKilonewtonMillimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromKilonewtonMillimetersPerMeter(2), 2.KilonewtonMillimetersPerMeter()); - - [Fact] - public void NumberToKilopoundForceFeetPerFootTest() => - Assert.Equal(TorquePerLength.FromKilopoundForceFeetPerFoot(2), 2.KilopoundForceFeetPerFoot()); - - [Fact] - public void NumberToKilopoundForceInchesPerFootTest() => - Assert.Equal(TorquePerLength.FromKilopoundForceInchesPerFoot(2), 2.KilopoundForceInchesPerFoot()); - - [Fact] - public void NumberToMeganewtonCentimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromMeganewtonCentimetersPerMeter(2), 2.MeganewtonCentimetersPerMeter()); - - [Fact] - public void NumberToMeganewtonMetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromMeganewtonMetersPerMeter(2), 2.MeganewtonMetersPerMeter()); - - [Fact] - public void NumberToMeganewtonMillimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromMeganewtonMillimetersPerMeter(2), 2.MeganewtonMillimetersPerMeter()); - - [Fact] - public void NumberToMegapoundForceFeetPerFootTest() => - Assert.Equal(TorquePerLength.FromMegapoundForceFeetPerFoot(2), 2.MegapoundForceFeetPerFoot()); - - [Fact] - public void NumberToMegapoundForceInchesPerFootTest() => - Assert.Equal(TorquePerLength.FromMegapoundForceInchesPerFoot(2), 2.MegapoundForceInchesPerFoot()); - - [Fact] - public void NumberToNewtonCentimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromNewtonCentimetersPerMeter(2), 2.NewtonCentimetersPerMeter()); - - [Fact] - public void NumberToNewtonMetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromNewtonMetersPerMeter(2), 2.NewtonMetersPerMeter()); - - [Fact] - public void NumberToNewtonMillimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromNewtonMillimetersPerMeter(2), 2.NewtonMillimetersPerMeter()); - - [Fact] - public void NumberToPoundForceFeetPerFootTest() => - Assert.Equal(TorquePerLength.FromPoundForceFeetPerFoot(2), 2.PoundForceFeetPerFoot()); - - [Fact] - public void NumberToPoundForceInchesPerFootTest() => - Assert.Equal(TorquePerLength.FromPoundForceInchesPerFoot(2), 2.PoundForceInchesPerFoot()); - - [Fact] - public void NumberToTonneForceCentimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromTonneForceCentimetersPerMeter(2), 2.TonneForceCentimetersPerMeter()); - - [Fact] - public void NumberToTonneForceMetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromTonneForceMetersPerMeter(2), 2.TonneForceMetersPerMeter()); - - [Fact] - public void NumberToTonneForceMillimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromTonneForceMillimetersPerMeter(2), 2.TonneForceMillimetersPerMeter()); - - } -} diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorquePerLengthExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorquePerLengthExtensions.g.cs deleted file mode 100644 index c5d1cb1107..0000000000 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorquePerLengthExtensions.g.cs +++ /dev/null @@ -1,204 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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.NumberToTorquePerLength -{ - /// - /// A number to TorquePerLength Extensions - /// - public static class NumberToTorquePerLengthExtensions - { - /// - public static TorquePerLength KilogramForceCentimetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromKilogramForceCentimetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength KilogramForceMetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromKilogramForceMetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength KilogramForceMillimetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromKilogramForceMillimetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength KilonewtonCentimetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromKilonewtonCentimetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength KilonewtonMetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromKilonewtonMetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength KilonewtonMillimetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromKilonewtonMillimetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength KilopoundForceFeetPerFoot(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromKilopoundForceFeetPerFoot(Convert.ToDouble(value)); - - /// - public static TorquePerLength KilopoundForceInchesPerFoot(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromKilopoundForceInchesPerFoot(Convert.ToDouble(value)); - - /// - public static TorquePerLength MeganewtonCentimetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromMeganewtonCentimetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength MeganewtonMetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromMeganewtonMetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength MeganewtonMillimetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromMeganewtonMillimetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength MegapoundForceFeetPerFoot(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromMegapoundForceFeetPerFoot(Convert.ToDouble(value)); - - /// - public static TorquePerLength MegapoundForceInchesPerFoot(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromMegapoundForceInchesPerFoot(Convert.ToDouble(value)); - - /// - public static TorquePerLength NewtonCentimetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromNewtonCentimetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength NewtonMetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromNewtonMetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength NewtonMillimetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromNewtonMillimetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength PoundForceFeetPerFoot(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromPoundForceFeetPerFoot(Convert.ToDouble(value)); - - /// - public static TorquePerLength PoundForceInchesPerFoot(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromPoundForceInchesPerFoot(Convert.ToDouble(value)); - - /// - public static TorquePerLength TonneForceCentimetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromTonneForceCentimetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength TonneForceMetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromTonneForceMetersPerMeter(Convert.ToDouble(value)); - - /// - public static TorquePerLength TonneForceMillimetersPerMeter(this T value) - where T : notnull -#if NET7_0_OR_GREATER - , INumber -#endif - => TorquePerLength.FromTonneForceMillimetersPerMeter(Convert.ToDouble(value)); - - } -} diff --git a/UnitsNet.Tests/CustomCode/TorquePerLengthTests.cs b/UnitsNet.Tests/CustomCode/TorquePerLengthTests.cs deleted file mode 100644 index 783cd49716..0000000000 --- a/UnitsNet.Tests/CustomCode/TorquePerLengthTests.cs +++ /dev/null @@ -1,49 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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 TorquePerLengthTests : TorquePerLengthTestsBase - { - protected override bool SupportsSIUnitSystem => false; - protected override double KilogramForceCentimetersPerMeterInOneNewtonMeterPerMeter => 10.197162130; - protected override double KilogramForceMetersPerMeterInOneNewtonMeterPerMeter => 0.101971621; - protected override double KilogramForceMillimetersPerMeterInOneNewtonMeterPerMeter => 101.971621298; - protected override double KilonewtonCentimetersPerMeterInOneNewtonMeterPerMeter => 1E-1; - protected override double KilonewtonMetersPerMeterInOneNewtonMeterPerMeter => 1E-3; - protected override double KilonewtonMillimetersPerMeterInOneNewtonMeterPerMeter => 1; - protected override double KilopoundForceFeetPerFootInOneNewtonMeterPerMeter => 0.224808943099E-3; - protected override double KilopoundForceInchesPerFootInOneNewtonMeterPerMeter => 2.69770722235E-3; - protected override double MeganewtonCentimetersPerMeterInOneNewtonMeterPerMeter => 1E-4; - protected override double MeganewtonMetersPerMeterInOneNewtonMeterPerMeter => 1E-6; - protected override double MeganewtonMillimetersPerMeterInOneNewtonMeterPerMeter => 1E-3; - protected override double MegapoundForceFeetPerFootInOneNewtonMeterPerMeter => 0.224808943099E-6; - protected override double MegapoundForceInchesPerFootInOneNewtonMeterPerMeter => 2.69770722235E-6; - protected override double NewtonCentimetersPerMeterInOneNewtonMeterPerMeter => 1E2; - protected override double NewtonMetersPerMeterInOneNewtonMeterPerMeter => 1; - protected override double NewtonMillimetersPerMeterInOneNewtonMeterPerMeter => 1E3; - protected override double PoundForceFeetPerFootInOneNewtonMeterPerMeter => 0.224808943099; - protected override double PoundForceInchesPerFootInOneNewtonMeterPerMeter => 2.69770722235; - protected override double TonneForceCentimetersPerMeterInOneNewtonMeterPerMeter => 1.01971621298e-2; - protected override double TonneForceMetersPerMeterInOneNewtonMeterPerMeter => 1.01971621298e-4; - protected override double TonneForceMillimetersPerMeterInOneNewtonMeterPerMeter => 1.01971621298e-1; - } -} diff --git a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs index 4b66fd9359..a3b35208ce 100644 --- a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs +++ b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs @@ -148,7 +148,6 @@ void Assertion(int expectedValue, Enum expectedUnit, IQuantity quantity) Assertion(3, ThermalConductivityUnit.WattPerMeterKelvin, Quantity.From(3, ThermalConductivityUnit.WattPerMeterKelvin)); Assertion(3, ThermalResistanceUnit.SquareMeterKelvinPerWatt, Quantity.From(3, ThermalResistanceUnit.SquareMeterKelvinPerWatt)); Assertion(3, TorqueUnit.TonneForceMillimeter, Quantity.From(3, TorqueUnit.TonneForceMillimeter)); - Assertion(3, TorquePerLengthUnit.TonneForceMillimeterPerMeter, Quantity.From(3, TorquePerLengthUnit.TonneForceMillimeterPerMeter)); Assertion(3, TurbidityUnit.NTU, Quantity.From(3, TurbidityUnit.NTU)); Assertion(3, VitaminAUnit.InternationalUnit, Quantity.From(3, VitaminAUnit.InternationalUnit)); Assertion(3, VolumeUnit.UsTeaspoon, Quantity.From(3, VolumeUnit.UsTeaspoon)); @@ -279,7 +278,6 @@ public void QuantityInfo_IsSameAsStaticInfoProperty() Assertion(ThermalConductivity.Info, ThermalConductivity.Zero); Assertion(ThermalResistance.Info, ThermalResistance.Zero); Assertion(Torque.Info, Torque.Zero); - Assertion(TorquePerLength.Info, TorquePerLength.Zero); Assertion(Turbidity.Info, Turbidity.Zero); Assertion(VitaminA.Info, VitaminA.Zero); Assertion(Volume.Info, Volume.Zero); @@ -410,7 +408,6 @@ public void Dimensions_IsSameAsStaticBaseDimensions() Assertion(ThermalConductivity.BaseDimensions, ThermalConductivity.Zero); Assertion(ThermalResistance.BaseDimensions, ThermalResistance.Zero); Assertion(Torque.BaseDimensions, Torque.Zero); - Assertion(TorquePerLength.BaseDimensions, TorquePerLength.Zero); Assertion(Turbidity.BaseDimensions, Turbidity.Zero); Assertion(VitaminA.BaseDimensions, VitaminA.Zero); Assertion(Volume.BaseDimensions, Volume.Zero); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs deleted file mode 100644 index 1349746299..0000000000 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ /dev/null @@ -1,1455 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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 TorquePerLength. - /// -// ReSharper disable once PartialTypeWithSinglePart - public abstract partial class TorquePerLengthTestsBase : QuantityTestsBase - { - protected abstract double KilogramForceCentimetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double KilogramForceMetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double KilogramForceMillimetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double KilonewtonCentimetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double KilonewtonMetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double KilonewtonMillimetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double KilopoundForceFeetPerFootInOneNewtonMeterPerMeter { get; } - protected abstract double KilopoundForceInchesPerFootInOneNewtonMeterPerMeter { get; } - protected abstract double MeganewtonCentimetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double MeganewtonMetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double MeganewtonMillimetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double MegapoundForceFeetPerFootInOneNewtonMeterPerMeter { get; } - protected abstract double MegapoundForceInchesPerFootInOneNewtonMeterPerMeter { get; } - protected abstract double NewtonCentimetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double NewtonMetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double NewtonMillimetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double PoundForceFeetPerFootInOneNewtonMeterPerMeter { get; } - protected abstract double PoundForceInchesPerFootInOneNewtonMeterPerMeter { get; } - protected abstract double TonneForceCentimetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double TonneForceMetersPerMeterInOneNewtonMeterPerMeter { get; } - protected abstract double TonneForceMillimetersPerMeterInOneNewtonMeterPerMeter { get; } - -// ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilogramForceCentimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilogramForceMetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilogramForceMillimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonCentimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonMetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonMillimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilopoundForceFeetPerFootTolerance { get { return 1e-5; } } - protected virtual double KilopoundForceInchesPerFootTolerance { get { return 1e-5; } } - protected virtual double MeganewtonCentimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double MeganewtonMetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double MeganewtonMillimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double MegapoundForceFeetPerFootTolerance { get { return 1e-5; } } - protected virtual double MegapoundForceInchesPerFootTolerance { get { return 1e-5; } } - protected virtual double NewtonCentimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double NewtonMetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double NewtonMillimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double PoundForceFeetPerFootTolerance { get { return 1e-5; } } - protected virtual double PoundForceInchesPerFootTolerance { get { return 1e-5; } } - protected virtual double TonneForceCentimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double TonneForceMetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double TonneForceMillimetersPerMeterTolerance { get { return 1e-5; } } -// ReSharper restore VirtualMemberNeverOverriden.Global - - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TorquePerLengthUnit unit) - { - return unit switch - { - TorquePerLengthUnit.KilogramForceCentimeterPerMeter => (KilogramForceCentimetersPerMeterInOneNewtonMeterPerMeter, KilogramForceCentimetersPerMeterTolerance), - TorquePerLengthUnit.KilogramForceMeterPerMeter => (KilogramForceMetersPerMeterInOneNewtonMeterPerMeter, KilogramForceMetersPerMeterTolerance), - TorquePerLengthUnit.KilogramForceMillimeterPerMeter => (KilogramForceMillimetersPerMeterInOneNewtonMeterPerMeter, KilogramForceMillimetersPerMeterTolerance), - TorquePerLengthUnit.KilonewtonCentimeterPerMeter => (KilonewtonCentimetersPerMeterInOneNewtonMeterPerMeter, KilonewtonCentimetersPerMeterTolerance), - TorquePerLengthUnit.KilonewtonMeterPerMeter => (KilonewtonMetersPerMeterInOneNewtonMeterPerMeter, KilonewtonMetersPerMeterTolerance), - TorquePerLengthUnit.KilonewtonMillimeterPerMeter => (KilonewtonMillimetersPerMeterInOneNewtonMeterPerMeter, KilonewtonMillimetersPerMeterTolerance), - TorquePerLengthUnit.KilopoundForceFootPerFoot => (KilopoundForceFeetPerFootInOneNewtonMeterPerMeter, KilopoundForceFeetPerFootTolerance), - TorquePerLengthUnit.KilopoundForceInchPerFoot => (KilopoundForceInchesPerFootInOneNewtonMeterPerMeter, KilopoundForceInchesPerFootTolerance), - TorquePerLengthUnit.MeganewtonCentimeterPerMeter => (MeganewtonCentimetersPerMeterInOneNewtonMeterPerMeter, MeganewtonCentimetersPerMeterTolerance), - TorquePerLengthUnit.MeganewtonMeterPerMeter => (MeganewtonMetersPerMeterInOneNewtonMeterPerMeter, MeganewtonMetersPerMeterTolerance), - TorquePerLengthUnit.MeganewtonMillimeterPerMeter => (MeganewtonMillimetersPerMeterInOneNewtonMeterPerMeter, MeganewtonMillimetersPerMeterTolerance), - TorquePerLengthUnit.MegapoundForceFootPerFoot => (MegapoundForceFeetPerFootInOneNewtonMeterPerMeter, MegapoundForceFeetPerFootTolerance), - TorquePerLengthUnit.MegapoundForceInchPerFoot => (MegapoundForceInchesPerFootInOneNewtonMeterPerMeter, MegapoundForceInchesPerFootTolerance), - TorquePerLengthUnit.NewtonCentimeterPerMeter => (NewtonCentimetersPerMeterInOneNewtonMeterPerMeter, NewtonCentimetersPerMeterTolerance), - TorquePerLengthUnit.NewtonMeterPerMeter => (NewtonMetersPerMeterInOneNewtonMeterPerMeter, NewtonMetersPerMeterTolerance), - TorquePerLengthUnit.NewtonMillimeterPerMeter => (NewtonMillimetersPerMeterInOneNewtonMeterPerMeter, NewtonMillimetersPerMeterTolerance), - TorquePerLengthUnit.PoundForceFootPerFoot => (PoundForceFeetPerFootInOneNewtonMeterPerMeter, PoundForceFeetPerFootTolerance), - TorquePerLengthUnit.PoundForceInchPerFoot => (PoundForceInchesPerFootInOneNewtonMeterPerMeter, PoundForceInchesPerFootTolerance), - TorquePerLengthUnit.TonneForceCentimeterPerMeter => (TonneForceCentimetersPerMeterInOneNewtonMeterPerMeter, TonneForceCentimetersPerMeterTolerance), - TorquePerLengthUnit.TonneForceMeterPerMeter => (TonneForceMetersPerMeterInOneNewtonMeterPerMeter, TonneForceMetersPerMeterTolerance), - TorquePerLengthUnit.TonneForceMillimeterPerMeter => (TonneForceMillimetersPerMeterInOneNewtonMeterPerMeter, TonneForceMillimetersPerMeterTolerance), - _ => throw new NotSupportedException() - }; - } - - public static IEnumerable UnitTypes = new List - { - new object[] { TorquePerLengthUnit.KilogramForceCentimeterPerMeter }, - new object[] { TorquePerLengthUnit.KilogramForceMeterPerMeter }, - new object[] { TorquePerLengthUnit.KilogramForceMillimeterPerMeter }, - new object[] { TorquePerLengthUnit.KilonewtonCentimeterPerMeter }, - new object[] { TorquePerLengthUnit.KilonewtonMeterPerMeter }, - new object[] { TorquePerLengthUnit.KilonewtonMillimeterPerMeter }, - new object[] { TorquePerLengthUnit.KilopoundForceFootPerFoot }, - new object[] { TorquePerLengthUnit.KilopoundForceInchPerFoot }, - new object[] { TorquePerLengthUnit.MeganewtonCentimeterPerMeter }, - new object[] { TorquePerLengthUnit.MeganewtonMeterPerMeter }, - new object[] { TorquePerLengthUnit.MeganewtonMillimeterPerMeter }, - new object[] { TorquePerLengthUnit.MegapoundForceFootPerFoot }, - new object[] { TorquePerLengthUnit.MegapoundForceInchPerFoot }, - new object[] { TorquePerLengthUnit.NewtonCentimeterPerMeter }, - new object[] { TorquePerLengthUnit.NewtonMeterPerMeter }, - new object[] { TorquePerLengthUnit.NewtonMillimeterPerMeter }, - new object[] { TorquePerLengthUnit.PoundForceFootPerFoot }, - new object[] { TorquePerLengthUnit.PoundForceInchPerFoot }, - new object[] { TorquePerLengthUnit.TonneForceCentimeterPerMeter }, - new object[] { TorquePerLengthUnit.TonneForceMeterPerMeter }, - new object[] { TorquePerLengthUnit.TonneForceMillimeterPerMeter }, - }; - - [Fact] - public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() - { - var quantity = new TorquePerLength(); - Assert.Equal(0, quantity.Value); - Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, quantity.Unit); - } - - [Fact] - public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() - { - var exception1 = Record.Exception(() => new TorquePerLength(double.PositiveInfinity, TorquePerLengthUnit.NewtonMeterPerMeter)); - var exception2 = Record.Exception(() => new TorquePerLength(double.NegativeInfinity, TorquePerLengthUnit.NewtonMeterPerMeter)); - - Assert.Null(exception1); - Assert.Null(exception2); - } - - [Fact] - public void Ctor_WithNaNValue_DoNotThrowsArgumentException() - { - var exception = Record.Exception(() => new TorquePerLength(double.NaN, TorquePerLengthUnit.NewtonMeterPerMeter)); - - Assert.Null(exception); - } - - [Fact] - public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException() - { - Assert.Throws(() => new TorquePerLength(value: 1, unitSystem: null)); - } - - [Fact] - public void Ctor_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() - { - Func TestCode = () => new TorquePerLength(value: 1, unitSystem: UnitSystem.SI); - if (SupportsSIUnitSystem) - { - var quantity = (TorquePerLength) TestCode(); - Assert.Equal(1, quantity.Value); - } - else - { - Assert.Throws(TestCode); - } - } - - [Fact] - public void TorquePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() - { - var quantity = new TorquePerLength(1, TorquePerLengthUnit.NewtonMeterPerMeter); - - QuantityInfo quantityInfo = quantity.QuantityInfo; - - Assert.Equal(TorquePerLength.Zero, quantityInfo.Zero); - Assert.Equal("TorquePerLength", quantityInfo.Name); - - var units = EnumUtils.GetEnumValues().OrderBy(x => x.ToString()).ToArray(); - var unitNames = units.Select(x => x.ToString()); - } - - [Fact] - public void NewtonMeterPerMeterToTorquePerLengthUnits() - { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); - AssertEx.EqualTolerance(KilogramForceCentimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.KilogramForceCentimetersPerMeter, KilogramForceCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(KilogramForceMetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.KilogramForceMetersPerMeter, KilogramForceMetersPerMeterTolerance); - AssertEx.EqualTolerance(KilogramForceMillimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.KilogramForceMillimetersPerMeter, KilogramForceMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(KilonewtonCentimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.KilonewtonCentimetersPerMeter, KilonewtonCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(KilonewtonMetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.KilonewtonMetersPerMeter, KilonewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(KilonewtonMillimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.KilonewtonMillimetersPerMeter, KilonewtonMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(KilopoundForceFeetPerFootInOneNewtonMeterPerMeter, newtonmeterpermeter.KilopoundForceFeetPerFoot, KilopoundForceFeetPerFootTolerance); - AssertEx.EqualTolerance(KilopoundForceInchesPerFootInOneNewtonMeterPerMeter, newtonmeterpermeter.KilopoundForceInchesPerFoot, KilopoundForceInchesPerFootTolerance); - AssertEx.EqualTolerance(MeganewtonCentimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.MeganewtonCentimetersPerMeter, MeganewtonCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(MeganewtonMetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.MeganewtonMetersPerMeter, MeganewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(MeganewtonMillimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.MeganewtonMillimetersPerMeter, MeganewtonMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(MegapoundForceFeetPerFootInOneNewtonMeterPerMeter, newtonmeterpermeter.MegapoundForceFeetPerFoot, MegapoundForceFeetPerFootTolerance); - AssertEx.EqualTolerance(MegapoundForceInchesPerFootInOneNewtonMeterPerMeter, newtonmeterpermeter.MegapoundForceInchesPerFoot, MegapoundForceInchesPerFootTolerance); - AssertEx.EqualTolerance(NewtonCentimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.NewtonCentimetersPerMeter, NewtonCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(NewtonMetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(NewtonMillimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.NewtonMillimetersPerMeter, NewtonMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(PoundForceFeetPerFootInOneNewtonMeterPerMeter, newtonmeterpermeter.PoundForceFeetPerFoot, PoundForceFeetPerFootTolerance); - AssertEx.EqualTolerance(PoundForceInchesPerFootInOneNewtonMeterPerMeter, newtonmeterpermeter.PoundForceInchesPerFoot, PoundForceInchesPerFootTolerance); - AssertEx.EqualTolerance(TonneForceCentimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.TonneForceCentimetersPerMeter, TonneForceCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(TonneForceMetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.TonneForceMetersPerMeter, TonneForceMetersPerMeterTolerance); - AssertEx.EqualTolerance(TonneForceMillimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.TonneForceMillimetersPerMeter, TonneForceMillimetersPerMeterTolerance); - } - - [Fact] - public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() - { - var quantity00 = TorquePerLength.From(1, TorquePerLengthUnit.KilogramForceCentimeterPerMeter); - AssertEx.EqualTolerance(1, quantity00.KilogramForceCentimetersPerMeter, KilogramForceCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilogramForceCentimeterPerMeter, quantity00.Unit); - - var quantity01 = TorquePerLength.From(1, TorquePerLengthUnit.KilogramForceMeterPerMeter); - AssertEx.EqualTolerance(1, quantity01.KilogramForceMetersPerMeter, KilogramForceMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilogramForceMeterPerMeter, quantity01.Unit); - - var quantity02 = TorquePerLength.From(1, TorquePerLengthUnit.KilogramForceMillimeterPerMeter); - AssertEx.EqualTolerance(1, quantity02.KilogramForceMillimetersPerMeter, KilogramForceMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilogramForceMillimeterPerMeter, quantity02.Unit); - - var quantity03 = TorquePerLength.From(1, TorquePerLengthUnit.KilonewtonCentimeterPerMeter); - AssertEx.EqualTolerance(1, quantity03.KilonewtonCentimetersPerMeter, KilonewtonCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilonewtonCentimeterPerMeter, quantity03.Unit); - - var quantity04 = TorquePerLength.From(1, TorquePerLengthUnit.KilonewtonMeterPerMeter); - AssertEx.EqualTolerance(1, quantity04.KilonewtonMetersPerMeter, KilonewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilonewtonMeterPerMeter, quantity04.Unit); - - var quantity05 = TorquePerLength.From(1, TorquePerLengthUnit.KilonewtonMillimeterPerMeter); - AssertEx.EqualTolerance(1, quantity05.KilonewtonMillimetersPerMeter, KilonewtonMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilonewtonMillimeterPerMeter, quantity05.Unit); - - var quantity06 = TorquePerLength.From(1, TorquePerLengthUnit.KilopoundForceFootPerFoot); - AssertEx.EqualTolerance(1, quantity06.KilopoundForceFeetPerFoot, KilopoundForceFeetPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.KilopoundForceFootPerFoot, quantity06.Unit); - - var quantity07 = TorquePerLength.From(1, TorquePerLengthUnit.KilopoundForceInchPerFoot); - AssertEx.EqualTolerance(1, quantity07.KilopoundForceInchesPerFoot, KilopoundForceInchesPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.KilopoundForceInchPerFoot, quantity07.Unit); - - var quantity08 = TorquePerLength.From(1, TorquePerLengthUnit.MeganewtonCentimeterPerMeter); - AssertEx.EqualTolerance(1, quantity08.MeganewtonCentimetersPerMeter, MeganewtonCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.MeganewtonCentimeterPerMeter, quantity08.Unit); - - var quantity09 = TorquePerLength.From(1, TorquePerLengthUnit.MeganewtonMeterPerMeter); - AssertEx.EqualTolerance(1, quantity09.MeganewtonMetersPerMeter, MeganewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.MeganewtonMeterPerMeter, quantity09.Unit); - - var quantity10 = TorquePerLength.From(1, TorquePerLengthUnit.MeganewtonMillimeterPerMeter); - AssertEx.EqualTolerance(1, quantity10.MeganewtonMillimetersPerMeter, MeganewtonMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.MeganewtonMillimeterPerMeter, quantity10.Unit); - - var quantity11 = TorquePerLength.From(1, TorquePerLengthUnit.MegapoundForceFootPerFoot); - AssertEx.EqualTolerance(1, quantity11.MegapoundForceFeetPerFoot, MegapoundForceFeetPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.MegapoundForceFootPerFoot, quantity11.Unit); - - var quantity12 = TorquePerLength.From(1, TorquePerLengthUnit.MegapoundForceInchPerFoot); - AssertEx.EqualTolerance(1, quantity12.MegapoundForceInchesPerFoot, MegapoundForceInchesPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.MegapoundForceInchPerFoot, quantity12.Unit); - - var quantity13 = TorquePerLength.From(1, TorquePerLengthUnit.NewtonCentimeterPerMeter); - AssertEx.EqualTolerance(1, quantity13.NewtonCentimetersPerMeter, NewtonCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.NewtonCentimeterPerMeter, quantity13.Unit); - - var quantity14 = TorquePerLength.From(1, TorquePerLengthUnit.NewtonMeterPerMeter); - AssertEx.EqualTolerance(1, quantity14.NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, quantity14.Unit); - - var quantity15 = TorquePerLength.From(1, TorquePerLengthUnit.NewtonMillimeterPerMeter); - AssertEx.EqualTolerance(1, quantity15.NewtonMillimetersPerMeter, NewtonMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.NewtonMillimeterPerMeter, quantity15.Unit); - - var quantity16 = TorquePerLength.From(1, TorquePerLengthUnit.PoundForceFootPerFoot); - AssertEx.EqualTolerance(1, quantity16.PoundForceFeetPerFoot, PoundForceFeetPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.PoundForceFootPerFoot, quantity16.Unit); - - var quantity17 = TorquePerLength.From(1, TorquePerLengthUnit.PoundForceInchPerFoot); - AssertEx.EqualTolerance(1, quantity17.PoundForceInchesPerFoot, PoundForceInchesPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.PoundForceInchPerFoot, quantity17.Unit); - - var quantity18 = TorquePerLength.From(1, TorquePerLengthUnit.TonneForceCentimeterPerMeter); - AssertEx.EqualTolerance(1, quantity18.TonneForceCentimetersPerMeter, TonneForceCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.TonneForceCentimeterPerMeter, quantity18.Unit); - - var quantity19 = TorquePerLength.From(1, TorquePerLengthUnit.TonneForceMeterPerMeter); - AssertEx.EqualTolerance(1, quantity19.TonneForceMetersPerMeter, TonneForceMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.TonneForceMeterPerMeter, quantity19.Unit); - - var quantity20 = TorquePerLength.From(1, TorquePerLengthUnit.TonneForceMillimeterPerMeter); - AssertEx.EqualTolerance(1, quantity20.TonneForceMillimetersPerMeter, TonneForceMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.TonneForceMillimeterPerMeter, quantity20.Unit); - - } - - [Fact] - public void FromNewtonMetersPerMeter_WithInfinityValue_DoNotThrowsArgumentException() - { - var exception1 = Record.Exception(() => TorquePerLength.FromNewtonMetersPerMeter(double.PositiveInfinity)); - var exception2 = Record.Exception(() => TorquePerLength.FromNewtonMetersPerMeter(double.NegativeInfinity)); - - Assert.Null(exception1); - Assert.Null(exception2); - } - - [Fact] - public void FromNewtonMetersPerMeter_WithNanValue_DoNotThrowsArgumentException() - { - var exception = Record.Exception(() => TorquePerLength.FromNewtonMetersPerMeter(double.NaN)); - - Assert.Null(exception); - } - - [Fact] - public void As() - { - var newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); - AssertEx.EqualTolerance(KilogramForceCentimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.KilogramForceCentimeterPerMeter), KilogramForceCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(KilogramForceMetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.KilogramForceMeterPerMeter), KilogramForceMetersPerMeterTolerance); - AssertEx.EqualTolerance(KilogramForceMillimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.KilogramForceMillimeterPerMeter), KilogramForceMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(KilonewtonCentimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.KilonewtonCentimeterPerMeter), KilonewtonCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(KilonewtonMetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.KilonewtonMeterPerMeter), KilonewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(KilonewtonMillimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.KilonewtonMillimeterPerMeter), KilonewtonMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(KilopoundForceFeetPerFootInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.KilopoundForceFootPerFoot), KilopoundForceFeetPerFootTolerance); - AssertEx.EqualTolerance(KilopoundForceInchesPerFootInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.KilopoundForceInchPerFoot), KilopoundForceInchesPerFootTolerance); - AssertEx.EqualTolerance(MeganewtonCentimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.MeganewtonCentimeterPerMeter), MeganewtonCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(MeganewtonMetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.MeganewtonMeterPerMeter), MeganewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(MeganewtonMillimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.MeganewtonMillimeterPerMeter), MeganewtonMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(MegapoundForceFeetPerFootInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.MegapoundForceFootPerFoot), MegapoundForceFeetPerFootTolerance); - AssertEx.EqualTolerance(MegapoundForceInchesPerFootInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.MegapoundForceInchPerFoot), MegapoundForceInchesPerFootTolerance); - AssertEx.EqualTolerance(NewtonCentimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.NewtonCentimeterPerMeter), NewtonCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(NewtonMetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.NewtonMeterPerMeter), NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(NewtonMillimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.NewtonMillimeterPerMeter), NewtonMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(PoundForceFeetPerFootInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.PoundForceFootPerFoot), PoundForceFeetPerFootTolerance); - AssertEx.EqualTolerance(PoundForceInchesPerFootInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.PoundForceInchPerFoot), PoundForceInchesPerFootTolerance); - AssertEx.EqualTolerance(TonneForceCentimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.TonneForceCentimeterPerMeter), TonneForceCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(TonneForceMetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.TonneForceMeterPerMeter), TonneForceMetersPerMeterTolerance); - AssertEx.EqualTolerance(TonneForceMillimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.TonneForceMillimeterPerMeter), TonneForceMillimetersPerMeterTolerance); - } - - [Fact] - public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() - { - var quantity = new TorquePerLength(value: 1, unit: TorquePerLength.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 = TorquePerLength.Parse("1 kgf·cm/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.KilogramForceCentimetersPerMeter, KilogramForceCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilogramForceCentimeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 kgf·m/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.KilogramForceMetersPerMeter, KilogramForceMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilogramForceMeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 kgf·mm/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.KilogramForceMillimetersPerMeter, KilogramForceMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilogramForceMillimeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 kN·cm/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.KilonewtonCentimetersPerMeter, KilonewtonCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilonewtonCentimeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 kN·m/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.KilonewtonMetersPerMeter, KilonewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilonewtonMeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 кН·м/м", CultureInfo.GetCultureInfo("ru-RU")); - AssertEx.EqualTolerance(1, parsed.KilonewtonMetersPerMeter, KilonewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilonewtonMeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 kN·mm/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.KilonewtonMillimetersPerMeter, KilonewtonMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilonewtonMillimeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 kipf·ft/ft", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.KilopoundForceFeetPerFoot, KilopoundForceFeetPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.KilopoundForceFootPerFoot, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 kipf·in/ft", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.KilopoundForceInchesPerFoot, KilopoundForceInchesPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.KilopoundForceInchPerFoot, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 MN·cm/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.MeganewtonCentimetersPerMeter, MeganewtonCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.MeganewtonCentimeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 MN·m/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.MeganewtonMetersPerMeter, MeganewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.MeganewtonMeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 МН·м/м", CultureInfo.GetCultureInfo("ru-RU")); - AssertEx.EqualTolerance(1, parsed.MeganewtonMetersPerMeter, MeganewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.MeganewtonMeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 MN·mm/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.MeganewtonMillimetersPerMeter, MeganewtonMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.MeganewtonMillimeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 Mlbf·ft/ft", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.MegapoundForceFeetPerFoot, MegapoundForceFeetPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.MegapoundForceFootPerFoot, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 Mlbf·in/ft", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.MegapoundForceInchesPerFoot, MegapoundForceInchesPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.MegapoundForceInchPerFoot, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 N·cm/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.NewtonCentimetersPerMeter, NewtonCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.NewtonCentimeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 N·m/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 Н·м/м", CultureInfo.GetCultureInfo("ru-RU")); - AssertEx.EqualTolerance(1, parsed.NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 N·mm/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.NewtonMillimetersPerMeter, NewtonMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.NewtonMillimeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 lbf·ft/ft", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.PoundForceFeetPerFoot, PoundForceFeetPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.PoundForceFootPerFoot, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 lbf·in/ft", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.PoundForceInchesPerFoot, PoundForceInchesPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.PoundForceInchPerFoot, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 tf·cm/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.TonneForceCentimetersPerMeter, TonneForceCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.TonneForceCentimeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 tf·m/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.TonneForceMetersPerMeter, TonneForceMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.TonneForceMeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsed = TorquePerLength.Parse("1 tf·mm/m", CultureInfo.GetCultureInfo("en-US")); - AssertEx.EqualTolerance(1, parsed.TonneForceMillimetersPerMeter, TonneForceMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.TonneForceMillimeterPerMeter, parsed.Unit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - } - - [Fact] - public void TryParse() - { - { - Assert.True(TorquePerLength.TryParse("1 kgf·cm/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.KilogramForceCentimetersPerMeter, KilogramForceCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilogramForceCentimeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 kgf·m/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.KilogramForceMetersPerMeter, KilogramForceMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilogramForceMeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 kgf·mm/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.KilogramForceMillimetersPerMeter, KilogramForceMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilogramForceMillimeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 kN·cm/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.KilonewtonCentimetersPerMeter, KilonewtonCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilonewtonCentimeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 kN·m/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.KilonewtonMetersPerMeter, KilonewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilonewtonMeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 кН·м/м", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.KilonewtonMetersPerMeter, KilonewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilonewtonMeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 kN·mm/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.KilonewtonMillimetersPerMeter, KilonewtonMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.KilonewtonMillimeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 kipf·ft/ft", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.KilopoundForceFeetPerFoot, KilopoundForceFeetPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.KilopoundForceFootPerFoot, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 kipf·in/ft", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.KilopoundForceInchesPerFoot, KilopoundForceInchesPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.KilopoundForceInchPerFoot, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 MN·cm/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.MeganewtonCentimetersPerMeter, MeganewtonCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.MeganewtonCentimeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 MN·m/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.MeganewtonMetersPerMeter, MeganewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.MeganewtonMeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 МН·м/м", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.MeganewtonMetersPerMeter, MeganewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.MeganewtonMeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 MN·mm/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.MeganewtonMillimetersPerMeter, MeganewtonMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.MeganewtonMillimeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 Mlbf·ft/ft", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.MegapoundForceFeetPerFoot, MegapoundForceFeetPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.MegapoundForceFootPerFoot, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 Mlbf·in/ft", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.MegapoundForceInchesPerFoot, MegapoundForceInchesPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.MegapoundForceInchPerFoot, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 N·cm/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.NewtonCentimetersPerMeter, NewtonCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.NewtonCentimeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 N·m/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 Н·м/м", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 N·mm/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.NewtonMillimetersPerMeter, NewtonMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.NewtonMillimeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 lbf·ft/ft", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.PoundForceFeetPerFoot, PoundForceFeetPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.PoundForceFootPerFoot, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 lbf·in/ft", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.PoundForceInchesPerFoot, PoundForceInchesPerFootTolerance); - Assert.Equal(TorquePerLengthUnit.PoundForceInchPerFoot, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 tf·cm/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.TonneForceCentimetersPerMeter, TonneForceCentimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.TonneForceCentimeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 tf·m/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.TonneForceMetersPerMeter, TonneForceMetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.TonneForceMeterPerMeter, parsed.Unit); - } - - { - Assert.True(TorquePerLength.TryParse("1 tf·mm/m", CultureInfo.GetCultureInfo("en-US"), out var parsed)); - AssertEx.EqualTolerance(1, parsed.TonneForceMillimetersPerMeter, TonneForceMillimetersPerMeterTolerance); - Assert.Equal(TorquePerLengthUnit.TonneForceMillimeterPerMeter, parsed.Unit); - } - - } - - [Fact] - public void ParseUnit() - { - try - { - var parsedUnit = TorquePerLength.ParseUnit("kgf·cm/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.KilogramForceCentimeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("kgf·m/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.KilogramForceMeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("kgf·mm/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.KilogramForceMillimeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("kN·cm/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.KilonewtonCentimeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("kN·m/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.KilonewtonMeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("кН·м/м", CultureInfo.GetCultureInfo("ru-RU")); - Assert.Equal(TorquePerLengthUnit.KilonewtonMeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("kN·mm/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.KilonewtonMillimeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("kipf·ft/ft", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.KilopoundForceFootPerFoot, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("kipf·in/ft", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.KilopoundForceInchPerFoot, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("MN·cm/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.MeganewtonCentimeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("MN·m/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.MeganewtonMeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("МН·м/м", CultureInfo.GetCultureInfo("ru-RU")); - Assert.Equal(TorquePerLengthUnit.MeganewtonMeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("MN·mm/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.MeganewtonMillimeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("Mlbf·ft/ft", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.MegapoundForceFootPerFoot, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("Mlbf·in/ft", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.MegapoundForceInchPerFoot, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("N·cm/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.NewtonCentimeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("N·m/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("Н·м/м", CultureInfo.GetCultureInfo("ru-RU")); - Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("N·mm/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.NewtonMillimeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("lbf·ft/ft", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.PoundForceFootPerFoot, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("lbf·in/ft", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.PoundForceInchPerFoot, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("tf·cm/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.TonneForceCentimeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("tf·m/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.TonneForceMeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - try - { - var parsedUnit = TorquePerLength.ParseUnit("tf·mm/m", CultureInfo.GetCultureInfo("en-US")); - Assert.Equal(TorquePerLengthUnit.TonneForceMillimeterPerMeter, parsedUnit); - } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } - - } - - [Fact] - public void TryParseUnit() - { - { - Assert.True(TorquePerLength.TryParseUnit("kgf·cm/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.KilogramForceCentimeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("kgf·m/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.KilogramForceMeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("kgf·mm/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.KilogramForceMillimeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("kN·cm/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.KilonewtonCentimeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("kN·m/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.KilonewtonMeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("кН·м/м", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.KilonewtonMeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("kN·mm/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.KilonewtonMillimeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("kipf·ft/ft", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.KilopoundForceFootPerFoot, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("kipf·in/ft", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.KilopoundForceInchPerFoot, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("MN·cm/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.MeganewtonCentimeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("MN·m/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.MeganewtonMeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("МН·м/м", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.MeganewtonMeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("MN·mm/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.MeganewtonMillimeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("Mlbf·ft/ft", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.MegapoundForceFootPerFoot, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("Mlbf·in/ft", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.MegapoundForceInchPerFoot, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("N·cm/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.NewtonCentimeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("N·m/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("Н·м/м", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("N·mm/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.NewtonMillimeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("lbf·ft/ft", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.PoundForceFootPerFoot, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("lbf·in/ft", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.PoundForceInchPerFoot, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("tf·cm/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.TonneForceCentimeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("tf·m/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.TonneForceMeterPerMeter, parsedUnit); - } - - { - Assert.True(TorquePerLength.TryParseUnit("tf·mm/m", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); - Assert.Equal(TorquePerLengthUnit.TonneForceMillimeterPerMeter, parsedUnit); - } - - } - - [Theory] - [MemberData(nameof(UnitTypes))] - public void ToUnit(TorquePerLengthUnit unit) - { - var inBaseUnits = TorquePerLength.From(1.0, TorquePerLength.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(TorquePerLengthUnit unit) - { - var quantity = TorquePerLength.From(3.0, unit); - var toUnitWithSameUnit = quantity.ToUnit(unit); - Assert.Equal(quantity, toUnitWithSameUnit); - } - - [Theory] - [MemberData(nameof(UnitTypes))] - public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TorquePerLengthUnit 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 = TorquePerLength.Units.First(u => u != TorquePerLength.BaseUnit); - - var quantity = TorquePerLength.From(3.0, fromUnit); - var converted = quantity.ToUnit(unit); - Assert.Equal(converted.Unit, unit); - } - - [Theory] - [MemberData(nameof(UnitTypes))] - public virtual void ToUnit_FromDefaultQuantity_ReturnsQuantityWithGivenUnit(TorquePerLengthUnit unit) - { - var quantity = default(TorquePerLength); - var converted = quantity.ToUnit(unit); - Assert.Equal(converted.Unit, unit); - } - - [Fact] - public void ConversionRoundTrip() - { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilogramForceCentimetersPerMeter(newtonmeterpermeter.KilogramForceCentimetersPerMeter).NewtonMetersPerMeter, KilogramForceCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilogramForceMetersPerMeter(newtonmeterpermeter.KilogramForceMetersPerMeter).NewtonMetersPerMeter, KilogramForceMetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilogramForceMillimetersPerMeter(newtonmeterpermeter.KilogramForceMillimetersPerMeter).NewtonMetersPerMeter, KilogramForceMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilonewtonCentimetersPerMeter(newtonmeterpermeter.KilonewtonCentimetersPerMeter).NewtonMetersPerMeter, KilonewtonCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilonewtonMetersPerMeter(newtonmeterpermeter.KilonewtonMetersPerMeter).NewtonMetersPerMeter, KilonewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilonewtonMillimetersPerMeter(newtonmeterpermeter.KilonewtonMillimetersPerMeter).NewtonMetersPerMeter, KilonewtonMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilopoundForceFeetPerFoot(newtonmeterpermeter.KilopoundForceFeetPerFoot).NewtonMetersPerMeter, KilopoundForceFeetPerFootTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilopoundForceInchesPerFoot(newtonmeterpermeter.KilopoundForceInchesPerFoot).NewtonMetersPerMeter, KilopoundForceInchesPerFootTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromMeganewtonCentimetersPerMeter(newtonmeterpermeter.MeganewtonCentimetersPerMeter).NewtonMetersPerMeter, MeganewtonCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromMeganewtonMetersPerMeter(newtonmeterpermeter.MeganewtonMetersPerMeter).NewtonMetersPerMeter, MeganewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromMeganewtonMillimetersPerMeter(newtonmeterpermeter.MeganewtonMillimetersPerMeter).NewtonMetersPerMeter, MeganewtonMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromMegapoundForceFeetPerFoot(newtonmeterpermeter.MegapoundForceFeetPerFoot).NewtonMetersPerMeter, MegapoundForceFeetPerFootTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromMegapoundForceInchesPerFoot(newtonmeterpermeter.MegapoundForceInchesPerFoot).NewtonMetersPerMeter, MegapoundForceInchesPerFootTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromNewtonCentimetersPerMeter(newtonmeterpermeter.NewtonCentimetersPerMeter).NewtonMetersPerMeter, NewtonCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromNewtonMetersPerMeter(newtonmeterpermeter.NewtonMetersPerMeter).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromNewtonMillimetersPerMeter(newtonmeterpermeter.NewtonMillimetersPerMeter).NewtonMetersPerMeter, NewtonMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromPoundForceFeetPerFoot(newtonmeterpermeter.PoundForceFeetPerFoot).NewtonMetersPerMeter, PoundForceFeetPerFootTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromPoundForceInchesPerFoot(newtonmeterpermeter.PoundForceInchesPerFoot).NewtonMetersPerMeter, PoundForceInchesPerFootTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromTonneForceCentimetersPerMeter(newtonmeterpermeter.TonneForceCentimetersPerMeter).NewtonMetersPerMeter, TonneForceCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromTonneForceMetersPerMeter(newtonmeterpermeter.TonneForceMetersPerMeter).NewtonMetersPerMeter, TonneForceMetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromTonneForceMillimetersPerMeter(newtonmeterpermeter.TonneForceMillimetersPerMeter).NewtonMetersPerMeter, TonneForceMillimetersPerMeterTolerance); - } - - [Fact] - public void ArithmeticOperators() - { - TorquePerLength v = TorquePerLength.FromNewtonMetersPerMeter(1); - AssertEx.EqualTolerance(-1, -v.NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(2, (TorquePerLength.FromNewtonMetersPerMeter(3)-v).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(2, (v + v).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(10, (v*10).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(10, (10*v).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(2, (TorquePerLength.FromNewtonMetersPerMeter(10)/5).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(2, TorquePerLength.FromNewtonMetersPerMeter(10)/TorquePerLength.FromNewtonMetersPerMeter(5), NewtonMetersPerMeterTolerance); - } - - [Fact] - public void ComparisonOperators() - { - TorquePerLength oneNewtonMeterPerMeter = TorquePerLength.FromNewtonMetersPerMeter(1); - TorquePerLength twoNewtonMetersPerMeter = TorquePerLength.FromNewtonMetersPerMeter(2); - - Assert.True(oneNewtonMeterPerMeter < twoNewtonMetersPerMeter); - Assert.True(oneNewtonMeterPerMeter <= twoNewtonMetersPerMeter); - Assert.True(twoNewtonMetersPerMeter > oneNewtonMeterPerMeter); - Assert.True(twoNewtonMetersPerMeter >= oneNewtonMeterPerMeter); - - Assert.False(oneNewtonMeterPerMeter > twoNewtonMetersPerMeter); - Assert.False(oneNewtonMeterPerMeter >= twoNewtonMetersPerMeter); - Assert.False(twoNewtonMetersPerMeter < oneNewtonMeterPerMeter); - Assert.False(twoNewtonMetersPerMeter <= oneNewtonMeterPerMeter); - } - - [Fact] - public void CompareToIsImplemented() - { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); - Assert.Equal(0, newtonmeterpermeter.CompareTo(newtonmeterpermeter)); - Assert.True(newtonmeterpermeter.CompareTo(TorquePerLength.Zero) > 0); - Assert.True(TorquePerLength.Zero.CompareTo(newtonmeterpermeter) < 0); - } - - [Fact] - public void CompareToThrowsOnTypeMismatch() - { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); - Assert.Throws(() => newtonmeterpermeter.CompareTo(new object())); - } - - [Fact] - public void CompareToThrowsOnNull() - { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); - Assert.Throws(() => newtonmeterpermeter.CompareTo(null)); - } - - [Theory] - [InlineData(1, TorquePerLengthUnit.NewtonMeterPerMeter, 1, TorquePerLengthUnit.NewtonMeterPerMeter, true)] // Same value and unit. - [InlineData(1, TorquePerLengthUnit.NewtonMeterPerMeter, 2, TorquePerLengthUnit.NewtonMeterPerMeter, false)] // Different value. - [InlineData(2, TorquePerLengthUnit.NewtonMeterPerMeter, 1, TorquePerLengthUnit.KilogramForceCentimeterPerMeter, false)] // Different value and unit. - [InlineData(1, TorquePerLengthUnit.NewtonMeterPerMeter, 1, TorquePerLengthUnit.KilogramForceCentimeterPerMeter, false)] // Different unit. - public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, TorquePerLengthUnit unitA, double valueB, TorquePerLengthUnit unitB, bool expectEqual) - { - var a = new TorquePerLength(valueA, unitA); - var b = new TorquePerLength(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 = TorquePerLength.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 = TorquePerLength.FromNewtonMetersPerMeter(1); - Assert.True(v.Equals(TorquePerLength.FromNewtonMetersPerMeter(1), NewtonMetersPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(TorquePerLength.Zero, NewtonMetersPerMeterTolerance, ComparisonType.Relative)); - Assert.True(TorquePerLength.FromNewtonMetersPerMeter(100).Equals(TorquePerLength.FromNewtonMetersPerMeter(120), 0.3, ComparisonType.Relative)); - Assert.False(TorquePerLength.FromNewtonMetersPerMeter(100).Equals(TorquePerLength.FromNewtonMetersPerMeter(120), 0.1, ComparisonType.Relative)); - } - - [Fact] - public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() - { - var v = TorquePerLength.FromNewtonMetersPerMeter(1); - Assert.Throws(() => v.Equals(TorquePerLength.FromNewtonMetersPerMeter(1), -1, ComparisonType.Relative)); - } - - [Fact] - public void EqualsReturnsFalseOnTypeMismatch() - { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); - Assert.False(newtonmeterpermeter.Equals(new object())); - } - - [Fact] - public void EqualsReturnsFalseOnNull() - { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); - Assert.False(newtonmeterpermeter.Equals(null)); - } - - [Fact] - public void HasAtLeastOneAbbreviationSpecified() - { - var units = Enum.GetValues(typeof(TorquePerLengthUnit)).Cast(); - foreach (var unit in units) - { - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); - } - } - - [Fact] - public void BaseDimensionsShouldNeverBeNull() - { - Assert.False(TorquePerLength.BaseDimensions is null); - } - - [Fact] - public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() - { - var prevCulture = Thread.CurrentThread.CurrentCulture; - Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); - try { - Assert.Equal("1 kgf·cm/m", new TorquePerLength(1, TorquePerLengthUnit.KilogramForceCentimeterPerMeter).ToString()); - Assert.Equal("1 kgf·m/m", new TorquePerLength(1, TorquePerLengthUnit.KilogramForceMeterPerMeter).ToString()); - Assert.Equal("1 kgf·mm/m", new TorquePerLength(1, TorquePerLengthUnit.KilogramForceMillimeterPerMeter).ToString()); - Assert.Equal("1 kN·cm/m", new TorquePerLength(1, TorquePerLengthUnit.KilonewtonCentimeterPerMeter).ToString()); - Assert.Equal("1 kN·m/m", new TorquePerLength(1, TorquePerLengthUnit.KilonewtonMeterPerMeter).ToString()); - Assert.Equal("1 kN·mm/m", new TorquePerLength(1, TorquePerLengthUnit.KilonewtonMillimeterPerMeter).ToString()); - Assert.Equal("1 kipf·ft/ft", new TorquePerLength(1, TorquePerLengthUnit.KilopoundForceFootPerFoot).ToString()); - Assert.Equal("1 kipf·in/ft", new TorquePerLength(1, TorquePerLengthUnit.KilopoundForceInchPerFoot).ToString()); - Assert.Equal("1 MN·cm/m", new TorquePerLength(1, TorquePerLengthUnit.MeganewtonCentimeterPerMeter).ToString()); - Assert.Equal("1 MN·m/m", new TorquePerLength(1, TorquePerLengthUnit.MeganewtonMeterPerMeter).ToString()); - Assert.Equal("1 MN·mm/m", new TorquePerLength(1, TorquePerLengthUnit.MeganewtonMillimeterPerMeter).ToString()); - Assert.Equal("1 Mlbf·ft/ft", new TorquePerLength(1, TorquePerLengthUnit.MegapoundForceFootPerFoot).ToString()); - Assert.Equal("1 Mlbf·in/ft", new TorquePerLength(1, TorquePerLengthUnit.MegapoundForceInchPerFoot).ToString()); - Assert.Equal("1 N·cm/m", new TorquePerLength(1, TorquePerLengthUnit.NewtonCentimeterPerMeter).ToString()); - Assert.Equal("1 N·m/m", new TorquePerLength(1, TorquePerLengthUnit.NewtonMeterPerMeter).ToString()); - Assert.Equal("1 N·mm/m", new TorquePerLength(1, TorquePerLengthUnit.NewtonMillimeterPerMeter).ToString()); - Assert.Equal("1 lbf·ft/ft", new TorquePerLength(1, TorquePerLengthUnit.PoundForceFootPerFoot).ToString()); - Assert.Equal("1 lbf·in/ft", new TorquePerLength(1, TorquePerLengthUnit.PoundForceInchPerFoot).ToString()); - Assert.Equal("1 tf·cm/m", new TorquePerLength(1, TorquePerLengthUnit.TonneForceCentimeterPerMeter).ToString()); - Assert.Equal("1 tf·m/m", new TorquePerLength(1, TorquePerLengthUnit.TonneForceMeterPerMeter).ToString()); - Assert.Equal("1 tf·mm/m", new TorquePerLength(1, TorquePerLengthUnit.TonneForceMillimeterPerMeter).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 kgf·cm/m", new TorquePerLength(1, TorquePerLengthUnit.KilogramForceCentimeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 kgf·m/m", new TorquePerLength(1, TorquePerLengthUnit.KilogramForceMeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 kgf·mm/m", new TorquePerLength(1, TorquePerLengthUnit.KilogramForceMillimeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 kN·cm/m", new TorquePerLength(1, TorquePerLengthUnit.KilonewtonCentimeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 kN·m/m", new TorquePerLength(1, TorquePerLengthUnit.KilonewtonMeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 kN·mm/m", new TorquePerLength(1, TorquePerLengthUnit.KilonewtonMillimeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 kipf·ft/ft", new TorquePerLength(1, TorquePerLengthUnit.KilopoundForceFootPerFoot).ToString(swedishCulture)); - Assert.Equal("1 kipf·in/ft", new TorquePerLength(1, TorquePerLengthUnit.KilopoundForceInchPerFoot).ToString(swedishCulture)); - Assert.Equal("1 MN·cm/m", new TorquePerLength(1, TorquePerLengthUnit.MeganewtonCentimeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 MN·m/m", new TorquePerLength(1, TorquePerLengthUnit.MeganewtonMeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 MN·mm/m", new TorquePerLength(1, TorquePerLengthUnit.MeganewtonMillimeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 Mlbf·ft/ft", new TorquePerLength(1, TorquePerLengthUnit.MegapoundForceFootPerFoot).ToString(swedishCulture)); - Assert.Equal("1 Mlbf·in/ft", new TorquePerLength(1, TorquePerLengthUnit.MegapoundForceInchPerFoot).ToString(swedishCulture)); - Assert.Equal("1 N·cm/m", new TorquePerLength(1, TorquePerLengthUnit.NewtonCentimeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 N·m/m", new TorquePerLength(1, TorquePerLengthUnit.NewtonMeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 N·mm/m", new TorquePerLength(1, TorquePerLengthUnit.NewtonMillimeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 lbf·ft/ft", new TorquePerLength(1, TorquePerLengthUnit.PoundForceFootPerFoot).ToString(swedishCulture)); - Assert.Equal("1 lbf·in/ft", new TorquePerLength(1, TorquePerLengthUnit.PoundForceInchPerFoot).ToString(swedishCulture)); - Assert.Equal("1 tf·cm/m", new TorquePerLength(1, TorquePerLengthUnit.TonneForceCentimeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 tf·m/m", new TorquePerLength(1, TorquePerLengthUnit.TonneForceMeterPerMeter).ToString(swedishCulture)); - Assert.Equal("1 tf·mm/m", new TorquePerLength(1, TorquePerLengthUnit.TonneForceMillimeterPerMeter).ToString(swedishCulture)); - } - - [Fact] - public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() - { - var oldCulture = CultureInfo.CurrentCulture; - try - { - CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; - Assert.Equal("0.1 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s1")); - Assert.Equal("0.12 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s2")); - Assert.Equal("0.123 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s3")); - Assert.Equal("0.1235 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s4")); - } - finally - { - CultureInfo.CurrentCulture = oldCulture; - } - } - - [Fact] - public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixForGivenCulture() - { - var culture = CultureInfo.InvariantCulture; - Assert.Equal("0.1 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s1", culture)); - Assert.Equal("0.12 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s2", culture)); - Assert.Equal("0.123 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s3", culture)); - Assert.Equal("0.1235 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s4", culture)); - } - - [Theory] - [InlineData(null)] - [InlineData("en-US")] - public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(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 = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); - } - - [Fact] - public void Convert_ToBool_ThrowsInvalidCastException() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Throws(() => Convert.ToBoolean(quantity)); - } - - [Fact] - public void Convert_ToByte_EqualsValueAsSameType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); - } - - [Fact] - public void Convert_ToChar_ThrowsInvalidCastException() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Throws(() => Convert.ToChar(quantity)); - } - - [Fact] - public void Convert_ToDateTime_ThrowsInvalidCastException() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Throws(() => Convert.ToDateTime(quantity)); - } - - [Fact] - public void Convert_ToDecimal_EqualsValueAsSameType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); - } - - [Fact] - public void Convert_ToDouble_EqualsValueAsSameType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((double)quantity.Value, Convert.ToDouble(quantity)); - } - - [Fact] - public void Convert_ToInt16_EqualsValueAsSameType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); - } - - [Fact] - public void Convert_ToInt32_EqualsValueAsSameType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); - } - - [Fact] - public void Convert_ToInt64_EqualsValueAsSameType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); - } - - [Fact] - public void Convert_ToSByte_EqualsValueAsSameType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); - } - - [Fact] - public void Convert_ToSingle_EqualsValueAsSameType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); - } - - [Fact] - public void Convert_ToString_EqualsToString() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); - } - - [Fact] - public void Convert_ToUInt16_EqualsValueAsSameType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); - } - - [Fact] - public void Convert_ToUInt32_EqualsValueAsSameType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); - } - - [Fact] - public void Convert_ToUInt64_EqualsValueAsSameType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); - } - - [Fact] - public void Convert_ChangeType_SelfType_EqualsSelf() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(TorquePerLength))); - } - - [Fact] - public void Convert_ChangeType_UnitType_EqualsUnit() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TorquePerLengthUnit))); - } - - [Fact] - public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(TorquePerLength.Info, Convert.ChangeType(quantity, typeof(QuantityInfo))); - } - - [Fact] - public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(TorquePerLength.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); - } - - [Fact] - public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Throws(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); - } - - [Fact] - public void GetHashCode_Equals() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(new {TorquePerLength.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 = TorquePerLength.FromNewtonMetersPerMeter(value); - Assert.Equal(TorquePerLength.FromNewtonMetersPerMeter(-value), -quantity); - } - } -} diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs deleted file mode 100644 index 63818dea2b..0000000000 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ /dev/null @@ -1,1268 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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 -{ - /// - /// - /// The magnitude of torque per unit length. - /// - [DataContract] - [DebuggerTypeProxy(typeof(QuantityDisplay))] - public readonly partial struct TorquePerLength : - 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 TorquePerLengthUnit? _unit; - - static TorquePerLength() - { - BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); - BaseUnit = TorquePerLengthUnit.NewtonMeterPerMeter; - Units = Enum.GetValues(typeof(TorquePerLengthUnit)).Cast().ToArray(); - Zero = new TorquePerLength(0, BaseUnit); - Info = new QuantityInfo("TorquePerLength", - new UnitInfo[] - { - new UnitInfo(TorquePerLengthUnit.KilogramForceCentimeterPerMeter, "KilogramForceCentimetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.KilogramForceMeterPerMeter, "KilogramForceMetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.KilogramForceMillimeterPerMeter, "KilogramForceMillimetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.KilonewtonCentimeterPerMeter, "KilonewtonCentimetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.KilonewtonMeterPerMeter, "KilonewtonMetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.KilonewtonMillimeterPerMeter, "KilonewtonMillimetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.KilopoundForceFootPerFoot, "KilopoundForceFeetPerFoot", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.KilopoundForceInchPerFoot, "KilopoundForceInchesPerFoot", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.MeganewtonCentimeterPerMeter, "MeganewtonCentimetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.MeganewtonMeterPerMeter, "MeganewtonMetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.MeganewtonMillimeterPerMeter, "MeganewtonMillimetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.MegapoundForceFootPerFoot, "MegapoundForceFeetPerFoot", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.MegapoundForceInchPerFoot, "MegapoundForceInchesPerFoot", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.NewtonCentimeterPerMeter, "NewtonCentimetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.NewtonMeterPerMeter, "NewtonMetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.NewtonMillimeterPerMeter, "NewtonMillimetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.PoundForceFootPerFoot, "PoundForceFeetPerFoot", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.PoundForceInchPerFoot, "PoundForceInchesPerFoot", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.TonneForceCentimeterPerMeter, "TonneForceCentimetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.TonneForceMeterPerMeter, "TonneForceMetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - new UnitInfo(TorquePerLengthUnit.TonneForceMillimeterPerMeter, "TonneForceMillimetersPerMeter", BaseUnits.Undefined, "TorquePerLength"), - }, - 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. - public TorquePerLength(double value, TorquePerLengthUnit unit) - { - _value = 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 TorquePerLength(double value, UnitSystem unitSystem) - { - if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); - - var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); - var firstUnitInfo = unitInfos.FirstOrDefault(); - - _value = 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 TorquePerLength, which is NewtonMeterPerMeter. All conversions go via this value. - /// - public static TorquePerLengthUnit BaseUnit { get; } - - /// - /// All units of measurement for the TorquePerLength quantity. - /// - public static TorquePerLengthUnit[] Units { get; } - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerMeter. - /// - public static TorquePerLength Zero { get; } - - /// - public static TorquePerLength AdditiveIdentity => Zero; - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => _value; - - /// - double IQuantity.Value => _value; - - Enum IQuantity.Unit => Unit; - - /// - public TorquePerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - /// - public QuantityInfo QuantityInfo => Info; - - /// - QuantityInfo IQuantity.QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => TorquePerLength.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Gets a value of this quantity converted into - /// - public double KilogramForceCentimetersPerMeter => As(TorquePerLengthUnit.KilogramForceCentimeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double KilogramForceMetersPerMeter => As(TorquePerLengthUnit.KilogramForceMeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double KilogramForceMillimetersPerMeter => As(TorquePerLengthUnit.KilogramForceMillimeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double KilonewtonCentimetersPerMeter => As(TorquePerLengthUnit.KilonewtonCentimeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double KilonewtonMetersPerMeter => As(TorquePerLengthUnit.KilonewtonMeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double KilonewtonMillimetersPerMeter => As(TorquePerLengthUnit.KilonewtonMillimeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double KilopoundForceFeetPerFoot => As(TorquePerLengthUnit.KilopoundForceFootPerFoot); - - /// - /// Gets a value of this quantity converted into - /// - public double KilopoundForceInchesPerFoot => As(TorquePerLengthUnit.KilopoundForceInchPerFoot); - - /// - /// Gets a value of this quantity converted into - /// - public double MeganewtonCentimetersPerMeter => As(TorquePerLengthUnit.MeganewtonCentimeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double MeganewtonMetersPerMeter => As(TorquePerLengthUnit.MeganewtonMeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double MeganewtonMillimetersPerMeter => As(TorquePerLengthUnit.MeganewtonMillimeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double MegapoundForceFeetPerFoot => As(TorquePerLengthUnit.MegapoundForceFootPerFoot); - - /// - /// Gets a value of this quantity converted into - /// - public double MegapoundForceInchesPerFoot => As(TorquePerLengthUnit.MegapoundForceInchPerFoot); - - /// - /// Gets a value of this quantity converted into - /// - public double NewtonCentimetersPerMeter => As(TorquePerLengthUnit.NewtonCentimeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double NewtonMetersPerMeter => As(TorquePerLengthUnit.NewtonMeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double NewtonMillimetersPerMeter => As(TorquePerLengthUnit.NewtonMillimeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double PoundForceFeetPerFoot => As(TorquePerLengthUnit.PoundForceFootPerFoot); - - /// - /// Gets a value of this quantity converted into - /// - public double PoundForceInchesPerFoot => As(TorquePerLengthUnit.PoundForceInchPerFoot); - - /// - /// Gets a value of this quantity converted into - /// - public double TonneForceCentimetersPerMeter => As(TorquePerLengthUnit.TonneForceCentimeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double TonneForceMetersPerMeter => As(TorquePerLengthUnit.TonneForceMeterPerMeter); - - /// - /// Gets a value of this quantity converted into - /// - public double TonneForceMillimetersPerMeter => As(TorquePerLengthUnit.TonneForceMillimeterPerMeter); - - #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: TorquePerLengthUnit -> BaseUnit - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilogramForceCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilogramForceMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilogramForceMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilonewtonCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilonewtonMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilonewtonMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilopoundForceFootPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilopoundForceInchPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MeganewtonCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MeganewtonMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MeganewtonMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MegapoundForceFootPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MegapoundForceInchPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.PoundForceFootPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.PoundForceInchPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.TonneForceCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.TonneForceMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.TonneForceMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMeterPerMeter)); - - // Register in unit converter: BaseUnit <-> BaseUnit - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity); - - // Register in unit converter: BaseUnit -> TorquePerLengthUnit - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilogramForceCentimeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.KilogramForceCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilogramForceMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.KilogramForceMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilogramForceMillimeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.KilogramForceMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilonewtonCentimeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.KilonewtonCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilonewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.KilonewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilonewtonMillimeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.KilonewtonMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilopoundForceFootPerFoot, quantity => quantity.ToUnit(TorquePerLengthUnit.KilopoundForceFootPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilopoundForceInchPerFoot, quantity => quantity.ToUnit(TorquePerLengthUnit.KilopoundForceInchPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MeganewtonCentimeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.MeganewtonCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MeganewtonMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.MeganewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MeganewtonMillimeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.MeganewtonMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MegapoundForceFootPerFoot, quantity => quantity.ToUnit(TorquePerLengthUnit.MegapoundForceFootPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MegapoundForceInchPerFoot, quantity => quantity.ToUnit(TorquePerLengthUnit.MegapoundForceInchPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.NewtonCentimeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.NewtonMillimeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.NewtonMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.PoundForceFootPerFoot, quantity => quantity.ToUnit(TorquePerLengthUnit.PoundForceFootPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.PoundForceInchPerFoot, quantity => quantity.ToUnit(TorquePerLengthUnit.PoundForceInchPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceCentimeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.TonneForceCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceMeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.TonneForceMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceMillimeterPerMeter, quantity => quantity.ToUnit(TorquePerLengthUnit.TonneForceMillimeterPerMeter)); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(TorquePerLengthUnit 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(TorquePerLengthUnit unit, IFormatProvider? provider) - { - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Creates a from . - /// - public static TorquePerLength FromKilogramForceCentimetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceCentimeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromKilogramForceMetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceMeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromKilogramForceMillimetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceMillimeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromKilonewtonCentimetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonCentimeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromKilonewtonMetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonMeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromKilonewtonMillimetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonMillimeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromKilopoundForceFeetPerFoot(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.KilopoundForceFootPerFoot); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromKilopoundForceInchesPerFoot(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.KilopoundForceInchPerFoot); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromMeganewtonCentimetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonCentimeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromMeganewtonMetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonMeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromMeganewtonMillimetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonMillimeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromMegapoundForceFeetPerFoot(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.MegapoundForceFootPerFoot); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromMegapoundForceInchesPerFoot(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.MegapoundForceInchPerFoot); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromNewtonCentimetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.NewtonCentimeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromNewtonMetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.NewtonMeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromNewtonMillimetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.NewtonMillimeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromPoundForceFeetPerFoot(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.PoundForceFootPerFoot); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromPoundForceInchesPerFoot(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.PoundForceInchPerFoot); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromTonneForceCentimetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.TonneForceCentimeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromTonneForceMetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.TonneForceMeterPerMeter); - } - - /// - /// Creates a from . - /// - public static TorquePerLength FromTonneForceMillimetersPerMeter(double value) - { - return new TorquePerLength(value, TorquePerLengthUnit.TonneForceMillimeterPerMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// TorquePerLength unit value. - public static TorquePerLength From(double value, TorquePerLengthUnit fromUnit) - { - return new TorquePerLength(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 TorquePerLength 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 TorquePerLength 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([NotNullWhen(true)]string? str, out TorquePerLength 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([NotNullWhen(true)]string? str, IFormatProvider? provider, out TorquePerLength 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 TorquePerLengthUnit 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 TorquePerLengthUnit ParseUnit(string str, IFormatProvider? provider) - { - return UnitParser.Default.Parse(str, provider); - } - - /// - public static bool TryParseUnit([NotNullWhen(true)]string? str, out TorquePerLengthUnit 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([NotNullWhen(true)]string? str, IFormatProvider? provider, out TorquePerLengthUnit unit) - { - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Arithmetic Operators - - /// Negate the value. - public static TorquePerLength operator -(TorquePerLength right) - { - return new TorquePerLength(-right.Value, right.Unit); - } - - /// Get from adding two . - public static TorquePerLength operator +(TorquePerLength left, TorquePerLength right) - { - return new TorquePerLength(left.Value + right.ToUnit(left.Unit).Value, left.Unit); - } - - /// Get from subtracting two . - public static TorquePerLength operator -(TorquePerLength left, TorquePerLength right) - { - return new TorquePerLength(left.Value - right.ToUnit(left.Unit).Value, left.Unit); - } - - /// Get from multiplying value and . - public static TorquePerLength operator *(double left, TorquePerLength right) - { - return new TorquePerLength(left * right.Value, right.Unit); - } - - /// Get from multiplying value and . - public static TorquePerLength operator *(TorquePerLength left, double right) - { - return new TorquePerLength(left.Value * right, left.Unit); - } - - /// Get from dividing by value. - public static TorquePerLength operator /(TorquePerLength left, double right) - { - return new TorquePerLength(left.Value / right, left.Unit); - } - - /// Get ratio value from dividing by . - public static double operator /(TorquePerLength left, TorquePerLength right) - { - return left.NewtonMetersPerMeter / right.NewtonMetersPerMeter; - } - - #endregion - - #region Equality / IComparable - - /// Returns true if less or equal to. - public static bool operator <=(TorquePerLength left, TorquePerLength right) - { - return left.Value <= right.ToUnit(left.Unit).Value; - } - - /// Returns true if greater than or equal to. - public static bool operator >=(TorquePerLength left, TorquePerLength right) - { - return left.Value >= right.ToUnit(left.Unit).Value; - } - - /// Returns true if less than. - public static bool operator <(TorquePerLength left, TorquePerLength right) - { - return left.Value < right.ToUnit(left.Unit).Value; - } - - /// Returns true if greater than. - public static bool operator >(TorquePerLength left, TorquePerLength 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(TorquePerLength other, TorquePerLength 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 ==(TorquePerLength left, TorquePerLength 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(TorquePerLength other, TorquePerLength 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 !=(TorquePerLength left, TorquePerLength right) - { - return !(left == right); - } - - /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(TorquePerLength other, TorquePerLength 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 TorquePerLength otherQuantity)) - return false; - - return Equals(otherQuantity); - } - - /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(TorquePerLength other, TorquePerLength 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(TorquePerLength 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 TorquePerLength otherQuantity)) throw new ArgumentException("Expected type TorquePerLength.", 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(TorquePerLength other) - { - return _value.CompareTo(other.ToUnit(this.Unit).Value); - } - - /// - /// - /// Compare equality to another TorquePerLength 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(TorquePerLength other, TorquePerLength 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(TorquePerLength 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 TorquePerLength otherTyped - && (tolerance is TorquePerLength toleranceTyped - ? true - : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'TorquePerLength'.", nameof(tolerance))) - && Equals(otherTyped, toleranceTyped); - } - - /// - public bool Equals(TorquePerLength other, TorquePerLength 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 TorquePerLength. - 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(TorquePerLengthUnit 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 TorquePerLengthUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); - - return As(typedUnit); - } - - /// - /// Converts this TorquePerLength to another TorquePerLength with the unit representation . - /// - /// The unit to convert to. - /// A TorquePerLength with the specified unit. - public TorquePerLength ToUnit(TorquePerLengthUnit 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 TorquePerLength with the specified unit. - public TorquePerLength ToUnit(TorquePerLengthUnit 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(TorquePerLength), Unit, typeof(TorquePerLength), unit), out var conversionFunction)) - { - // See if the unit converter has an extensibility conversion registered. - return (TorquePerLength)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(TorquePerLengthUnit unit, [NotNullWhen(true)] out TorquePerLength? converted) - { - if (Unit == unit) - { - converted = this; - return true; - } - - TorquePerLength? convertedOrNull = (Unit, unit) switch - { - // TorquePerLengthUnit -> BaseUnit - (TorquePerLengthUnit.KilogramForceCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 0.0980665019960652, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilogramForceMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 9.80665019960652, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilogramForceMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 0.00980665019960652, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilonewtonCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 0.01) * 1e3d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilonewtonMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value) * 1e3d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilonewtonMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 0.001) * 1e3d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilopoundForceFootPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 4.44822161526) * 1e3d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilopoundForceInchPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 0.370685147638) * 1e3d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.MeganewtonCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 0.01) * 1e6d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.MeganewtonMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value) * 1e6d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.MeganewtonMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 0.001) * 1e6d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.MegapoundForceFootPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 4.44822161526) * 1e6d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.MegapoundForceInchPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 0.370685147638) * 1e6d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.NewtonCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 0.01, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.NewtonMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 0.001, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.PoundForceFootPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 4.44822161526, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.PoundForceInchPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 0.370685147638, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.TonneForceCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 98.0665019960652, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.TonneForceMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 9806.65019960653, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.TonneForceMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 9.80665019960652, TorquePerLengthUnit.NewtonMeterPerMeter), - - // BaseUnit -> TorquePerLengthUnit - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilogramForceCentimeterPerMeter) => new TorquePerLength(_value * 10.1971619222242, TorquePerLengthUnit.KilogramForceCentimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilogramForceMeterPerMeter) => new TorquePerLength(_value * 0.101971619222242, TorquePerLengthUnit.KilogramForceMeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilogramForceMillimeterPerMeter) => new TorquePerLength(_value * 101.971619222242, TorquePerLengthUnit.KilogramForceMillimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilonewtonCentimeterPerMeter) => new TorquePerLength((_value * 100) / 1e3d, TorquePerLengthUnit.KilonewtonCentimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilonewtonMeterPerMeter) => new TorquePerLength((_value) / 1e3d, TorquePerLengthUnit.KilonewtonMeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilonewtonMillimeterPerMeter) => new TorquePerLength((_value * 1000) / 1e3d, TorquePerLengthUnit.KilonewtonMillimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilopoundForceFootPerFoot) => new TorquePerLength((_value / 4.44822161526) / 1e3d, TorquePerLengthUnit.KilopoundForceFootPerFoot), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilopoundForceInchPerFoot) => new TorquePerLength((_value / 0.370685147638) / 1e3d, TorquePerLengthUnit.KilopoundForceInchPerFoot), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MeganewtonCentimeterPerMeter) => new TorquePerLength((_value * 100) / 1e6d, TorquePerLengthUnit.MeganewtonCentimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MeganewtonMeterPerMeter) => new TorquePerLength((_value) / 1e6d, TorquePerLengthUnit.MeganewtonMeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MeganewtonMillimeterPerMeter) => new TorquePerLength((_value * 1000) / 1e6d, TorquePerLengthUnit.MeganewtonMillimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MegapoundForceFootPerFoot) => new TorquePerLength((_value / 4.44822161526) / 1e6d, TorquePerLengthUnit.MegapoundForceFootPerFoot), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MegapoundForceInchPerFoot) => new TorquePerLength((_value / 0.370685147638) / 1e6d, TorquePerLengthUnit.MegapoundForceInchPerFoot), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.NewtonCentimeterPerMeter) => new TorquePerLength(_value * 100, TorquePerLengthUnit.NewtonCentimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.NewtonMillimeterPerMeter) => new TorquePerLength(_value * 1000, TorquePerLengthUnit.NewtonMillimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.PoundForceFootPerFoot) => new TorquePerLength(_value / 4.44822161526, TorquePerLengthUnit.PoundForceFootPerFoot), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.PoundForceInchPerFoot) => new TorquePerLength(_value / 0.370685147638, TorquePerLengthUnit.PoundForceInchPerFoot), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceCentimeterPerMeter) => new TorquePerLength(_value * 0.0101971619222242, TorquePerLengthUnit.TonneForceCentimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceMeterPerMeter) => new TorquePerLength(_value * 0.000101971619222242, TorquePerLengthUnit.TonneForceMeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceMillimeterPerMeter) => new TorquePerLength(_value * 0.101971619222242, TorquePerLengthUnit.TonneForceMillimeterPerMeter), - - _ => null - }; - - if (convertedOrNull is null) - { - converted = default; - return false; - } - - converted = convertedOrNull.Value; - return true; - } - - /// - IQuantity IQuantity.ToUnit(Enum unit) - { - if (!(unit is TorquePerLengthUnit typedUnit)) - throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); - - return ToUnit(typedUnit, DefaultConversionFunctions); - } - - /// - public TorquePerLength 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(TorquePerLengthUnit unit) => ToUnit(unit); - - /// - IQuantity IQuantity.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(null, null); - } - - /// - /// 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(null, 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, null); - } - - /// - /// - /// 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(TorquePerLength)} to bool is not supported."); - } - - byte IConvertible.ToByte(IFormatProvider? provider) - { - return Convert.ToByte(_value); - } - - char IConvertible.ToChar(IFormatProvider? provider) - { - throw new InvalidCastException($"Converting {typeof(TorquePerLength)} to char is not supported."); - } - - DateTime IConvertible.ToDateTime(IFormatProvider? provider) - { - throw new InvalidCastException($"Converting {typeof(TorquePerLength)} 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(null, provider); - } - - object IConvertible.ToType(Type conversionType, IFormatProvider? provider) - { - if (conversionType == typeof(TorquePerLength)) - return this; - else if (conversionType == typeof(TorquePerLengthUnit)) - return Unit; - else if (conversionType == typeof(QuantityInfo)) - return TorquePerLength.Info; - else if (conversionType == typeof(BaseDimensions)) - return TorquePerLength.BaseDimensions; - else - throw new InvalidCastException($"Converting {typeof(TorquePerLength)} 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 bacb9642b0..9a2dcffd52 100644 --- a/UnitsNet/GeneratedCode/Quantity.g.cs +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by \generate-code.bat. // @@ -152,7 +152,6 @@ public partial class Quantity { "ThermalConductivity", ThermalConductivity.Info }, { "ThermalResistance", ThermalResistance.Info }, { "Torque", Torque.Info }, - { "TorquePerLength", TorquePerLength.Info }, { "Turbidity", Turbidity.Info }, { "VitaminA", VitaminA.Info }, { "Volume", Volume.Info }, @@ -288,7 +287,6 @@ public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, double value "ThermalConductivity" => ThermalConductivity.From(value, ThermalConductivity.BaseUnit), "ThermalResistance" => ThermalResistance.From(value, ThermalResistance.BaseUnit), "Torque" => Torque.From(value, Torque.BaseUnit), - "TorquePerLength" => TorquePerLength.From(value, TorquePerLength.BaseUnit), "Turbidity" => Turbidity.From(value, Turbidity.BaseUnit), "VitaminA" => VitaminA.From(value, VitaminA.BaseUnit), "Volume" => Volume.From(value, Volume.BaseUnit), @@ -427,7 +425,6 @@ public static bool TryFrom(double value, Enum? unit, [NotNullWhen(true)] out IQu ThermalConductivityUnit thermalConductivityUnit => ThermalConductivity.From(value, thermalConductivityUnit), ThermalResistanceUnit thermalResistanceUnit => ThermalResistance.From(value, thermalResistanceUnit), TorqueUnit torqueUnit => Torque.From(value, torqueUnit), - TorquePerLengthUnit torquePerLengthUnit => TorquePerLength.From(value, torquePerLengthUnit), TurbidityUnit turbidityUnit => Turbidity.From(value, turbidityUnit), VitaminAUnit vitaminAUnit => VitaminA.From(value, vitaminAUnit), VolumeUnit volumeUnit => Volume.From(value, volumeUnit), @@ -576,7 +573,6 @@ public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, Type _ when quantityType == typeof(ThermalConductivity) => parser.TryParse(quantityString, formatProvider, ThermalConductivity.From, out quantity), Type _ when quantityType == typeof(ThermalResistance) => parser.TryParse(quantityString, formatProvider, ThermalResistance.From, out quantity), Type _ when quantityType == typeof(Torque) => parser.TryParse(quantityString, formatProvider, Torque.From, out quantity), - Type _ when quantityType == typeof(TorquePerLength) => parser.TryParse(quantityString, formatProvider, TorquePerLength.From, out quantity), Type _ when quantityType == typeof(Turbidity) => parser.TryParse(quantityString, formatProvider, Turbidity.From, out quantity), Type _ when quantityType == typeof(VitaminA) => parser.TryParse(quantityString, formatProvider, VitaminA.From, out quantity), Type _ when quantityType == typeof(Volume) => parser.TryParse(quantityString, formatProvider, Volume.From, out quantity), @@ -706,7 +702,6 @@ internal static IEnumerable GetQuantityTypes() yield return typeof(ThermalConductivity); yield return typeof(ThermalResistance); yield return typeof(Torque); - yield return typeof(TorquePerLength); yield return typeof(Turbidity); yield return typeof(VitaminA); yield return typeof(Volume); diff --git a/UnitsNet/GeneratedCode/Resources/TorquePerLength.restext b/UnitsNet/GeneratedCode/Resources/TorquePerLength.restext deleted file mode 100644 index c3f4ff7f53..0000000000 --- a/UnitsNet/GeneratedCode/Resources/TorquePerLength.restext +++ /dev/null @@ -1,21 +0,0 @@ -KilogramForceCentimetersPerMeter=kgf·cm/m -KilogramForceMetersPerMeter=kgf·m/m -KilogramForceMillimetersPerMeter=kgf·mm/m -KilonewtonCentimetersPerMeter=kN·cm/m -KilonewtonMetersPerMeter=kN·m/m -KilonewtonMillimetersPerMeter=kN·mm/m -KilopoundForceFeetPerFoot=kipf·ft/ft -KilopoundForceInchesPerFoot=kipf·in/ft -MeganewtonCentimetersPerMeter=MN·cm/m -MeganewtonMetersPerMeter=MN·m/m -MeganewtonMillimetersPerMeter=MN·mm/m -MegapoundForceFeetPerFoot=Mlbf·ft/ft -MegapoundForceInchesPerFoot=Mlbf·in/ft -NewtonCentimetersPerMeter=N·cm/m -NewtonMetersPerMeter=N·m/m -NewtonMillimetersPerMeter=N·mm/m -PoundForceFeetPerFoot=lbf·ft/ft -PoundForceInchesPerFoot=lbf·in/ft -TonneForceCentimetersPerMeter=tf·cm/m -TonneForceMetersPerMeter=tf·m/m -TonneForceMillimetersPerMeter=tf·mm/m diff --git a/UnitsNet/GeneratedCode/Resources/TorquePerLength.ru-RU.restext b/UnitsNet/GeneratedCode/Resources/TorquePerLength.ru-RU.restext deleted file mode 100644 index d138f411e5..0000000000 --- a/UnitsNet/GeneratedCode/Resources/TorquePerLength.ru-RU.restext +++ /dev/null @@ -1,3 +0,0 @@ -KilonewtonMetersPerMeter=кН·м/м -MeganewtonMetersPerMeter=МН·м/м -NewtonMetersPerMeter=Н·м/м diff --git a/UnitsNet/GeneratedCode/Units/TorquePerLengthUnit.g.cs b/UnitsNet/GeneratedCode/Units/TorquePerLengthUnit.g.cs deleted file mode 100644 index 4145084d80..0000000000 --- a/UnitsNet/GeneratedCode/Units/TorquePerLengthUnit.g.cs +++ /dev/null @@ -1,52 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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 TorquePerLengthUnit - { - KilogramForceCentimeterPerMeter = 1, - KilogramForceMeterPerMeter = 2, - KilogramForceMillimeterPerMeter = 3, - KilonewtonCentimeterPerMeter = 4, - KilonewtonMeterPerMeter = 5, - KilonewtonMillimeterPerMeter = 6, - KilopoundForceFootPerFoot = 7, - KilopoundForceInchPerFoot = 8, - MeganewtonCentimeterPerMeter = 9, - MeganewtonMeterPerMeter = 10, - MeganewtonMillimeterPerMeter = 11, - MegapoundForceFootPerFoot = 12, - MegapoundForceInchPerFoot = 13, - NewtonCentimeterPerMeter = 14, - NewtonMeterPerMeter = 15, - NewtonMillimeterPerMeter = 16, - PoundForceFootPerFoot = 17, - PoundForceInchPerFoot = 18, - TonneForceCentimeterPerMeter = 19, - TonneForceMeterPerMeter = 20, - TonneForceMillimeterPerMeter = 21, - } - - #pragma warning restore 1591 -}