From 5fc96573dca8d7ae764eb118d2d9f2deb346baa0 Mon Sep 17 00:00:00 2001 From: Burak Can Date: Thu, 20 Jun 2024 11:57:37 -0400 Subject: [PATCH 1/6] Add JSON file for ElectricConductancePerArea quantity --- .../ElectricConductancePerArea.json | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 Common/UnitDefinitions/ElectricConductancePerArea.json diff --git a/Common/UnitDefinitions/ElectricConductancePerArea.json b/Common/UnitDefinitions/ElectricConductancePerArea.json new file mode 100644 index 0000000000..3bee336ee2 --- /dev/null +++ b/Common/UnitDefinitions/ElectricConductancePerArea.json @@ -0,0 +1,131 @@ +{ + "Name": "ElectricConductancePerArea", + "BaseUnit": "SiemensPerSquareMeter", + "XmlDocSummary": "The electrical conductance per area of an electrical conductor is a measure of the easeness to pass an electric current through that conductor per unit area.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance", + "BaseDimensions": { + "L": -4, + "M": -1, + "T": 3, + "I": 2 + }, + "Units": [ + { + "SingularName": "SiemensPerSquareMeter", + "PluralName": "SiemensPerSquareMeter", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "I": "Ampere" + }, + "FromUnitToBaseFunc": "{x}", + "FromBaseToUnitFunc": "{x}", + "Prefixes": [ "Femto", "Pico","Nano", "Micro", "Milli", "Kilo", "Mega" ], + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "S/m²" ] + } + ] + }, + { + "SingularName": "SiemensPerSquareDecimeter", + "PluralName": "SiemensPerSquareDecimeters", + "FromUnitToBaseFunc": "{x} / 1e-2", + "FromBaseToUnitFunc": "{x} * 1e-2", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "S/dm²" ] + } + ] + }, + { + "SingularName": "SiemensPerSquareCentimeter", + "PluralName": "SiemensPerSquareCentimeters", + "FromUnitToBaseFunc": "{x} / 1e-4", + "FromBaseToUnitFunc": "{x} * 1e-4", + "Prefixes": ["Micro", "Milli"], + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "S/cm²" ] + } + ] + }, + { + "SingularName": "SiemensPerSquareMillimeter", + "PluralName": "SiemensPerSquareMillimeters", + "FromUnitToBaseFunc": "{x} / 1e-6", + "FromBaseToUnitFunc": "{x} * 1e-6", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "S/mm²" ] + } + ] + }, + { + "SingularName": "SiemensPerSquareMile", + "PluralName": "SiemensPerSquareMiles", + "FromUnitToBaseFunc": "{x} / 2.59e6", + "FromBaseToUnitFunc": "{x} * 2.59e6", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "S/mi²" ] + } + ] + }, + { + "SingularName": "SiemensPerSquareYard", + "PluralName": "SiemensPerSquareYards", + "FromUnitToBaseFunc": "{x} / 0.836127", + "FromBaseToUnitFunc": "{x} * 0.836127", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "S/yd²" ] + } + ] + }, + { + "SingularName": "SiemensPerSquareFoot", + "PluralName": "SiemensPerSquareFeet", + "FromUnitToBaseFunc": "{x} / 0.092903", + "FromBaseToUnitFunc": "{x} * 0.092903", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "S/ft²" ] + } + ] + }, + { + "SingularName": "SiemensPerUsSurveySquareFoot", + "PluralName": "SiemensPerUsSurveySquareFeet", + "FromUnitToBaseFunc": "{x} / 0.09290341161", + "FromBaseToUnitFunc": "{x} * 0.09290341161", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "S/ft² (US)" ] + } + ] + }, + { + "SingularName": "SiemensPerSquareInch", + "PluralName": "SiemensPerSquareInches", + "FromUnitToBaseFunc": "{x} / 0.00064516", + "FromBaseToUnitFunc": "{x} * 0.00064516", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "S/in²" ] + } + ] + } + ] + } + \ No newline at end of file From edf71aca0515a256a5d0b77e2328c09c380bd619 Mon Sep 17 00:00:00 2001 From: Burak Can Date: Thu, 20 Jun 2024 11:59:55 -0400 Subject: [PATCH 2/6] Add generated code for ElectricConductancePerArea quantity. --- Common/UnitEnumValues.g.json | 20 + .../ElectricConductancePerArea.nfproj | 42 + ...ramework.ElectricConductancePerArea.nuspec | 26 + .../packages.config | 4 + .../ElectricConductancePerArea.g.cs | 383 +++++ .../Units/ElectricConductancePerAreaUnit.g.cs | 49 + .../GeneratedCode/UnitsNet.nanoFramework.sln | 8 + ...ctricConductancePerAreaExtensionsTest.g.cs | 100 ++ ...oElectricConductancePerAreaExtensions.g.cs | 180 +++ .../ElectricConductancePerAreaTests.cs | 46 + .../GeneratedCode/IQuantityTests.g.cs | 3 + .../ElectricConductancePerAreaTestsBase.g.cs | 1240 ++++++++++++++++ .../ElectricConductancePerArea.g.cs | 1275 +++++++++++++++++ UnitsNet/GeneratedCode/Quantity.g.cs | 5 + .../ElectricConductancePerArea.restext | 18 + .../Units/ElectricConductancePerAreaUnit.g.cs | 49 + 16 files changed, 3448 insertions(+) create mode 100644 UnitsNet.NanoFramework/GeneratedCode/ElectricConductancePerArea/ElectricConductancePerArea.nfproj create mode 100644 UnitsNet.NanoFramework/GeneratedCode/ElectricConductancePerArea/UnitsNet.NanoFramework.ElectricConductancePerArea.nuspec create mode 100644 UnitsNet.NanoFramework/GeneratedCode/ElectricConductancePerArea/packages.config create mode 100644 UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductancePerArea.g.cs create mode 100644 UnitsNet.NanoFramework/GeneratedCode/Units/ElectricConductancePerAreaUnit.g.cs create mode 100644 UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricConductancePerAreaExtensionsTest.g.cs create mode 100644 UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductancePerAreaExtensions.g.cs create mode 100644 UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs create mode 100644 UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductancePerAreaTestsBase.g.cs create mode 100644 UnitsNet/GeneratedCode/Quantities/ElectricConductancePerArea.g.cs create mode 100644 UnitsNet/GeneratedCode/Resources/ElectricConductancePerArea.restext create mode 100644 UnitsNet/GeneratedCode/Units/ElectricConductancePerAreaUnit.g.cs diff --git a/Common/UnitEnumValues.g.json b/Common/UnitEnumValues.g.json index 73ba872afa..8d981d7df5 100644 --- a/Common/UnitEnumValues.g.json +++ b/Common/UnitEnumValues.g.json @@ -1855,5 +1855,25 @@ "Sievert": 9, "Kilosievert": 3, "Megasievert": 6 + }, + "ElectricConductancePerArea": { + "FemtosiemensPerSquareMeter": 9, + "KilosiemensPerSquareMeter": 5, + "MegasiemensPerSquareMeter": 1, + "MicrosiemensPerSquareCentimeter": 8, + "MicrosiemensPerSquareMeter": 6, + "MillisiemensPerSquareCentimeter": 4, + "MillisiemensPerSquareMeter": 7, + "NanosiemensPerSquareMeter": 2, + "PicosiemensPerSquareMeter": 10, + "SiemensPerSquareCentimeter": 3, + "SiemensPerSquareDecimeter": 14, + "SiemensPerSquareFoot": 15, + "SiemensPerSquareInch": 19, + "SiemensPerSquareMeter": 17, + "SiemensPerSquareMile": 12, + "SiemensPerSquareMillimeter": 20, + "SiemensPerSquareYard": 18, + "SiemensPerUsSurveySquareFoot": 16 } } diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductancePerArea/ElectricConductancePerArea.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductancePerArea/ElectricConductancePerArea.nfproj new file mode 100644 index 0000000000..50a5925694 --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductancePerArea/ElectricConductancePerArea.nfproj @@ -0,0 +1,42 @@ + + + + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {554f9914-133f-0a1d-e5e0-17c3879852be} + Library + Properties + 512 + UnitsNet + UnitsNet.ElectricConductancePerArea + v1.0 + bin\$(Configuration)\$(AssemblyName).xml + + + + + + + + + + ..\packages\nanoFramework.CoreLibrary.1.15.5\lib\mscorlib.dll + True + True + + + + + + + + + + + + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductancePerArea/UnitsNet.NanoFramework.ElectricConductancePerArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductancePerArea/UnitsNet.NanoFramework.ElectricConductancePerArea.nuspec new file mode 100644 index 0000000000..7876d35519 --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductancePerArea/UnitsNet.NanoFramework.ElectricConductancePerArea.nuspec @@ -0,0 +1,26 @@ + + + + UnitsNet.nanoFramework.ElectricConductancePerArea + 5.52.0 + Units.NET ElectricConductancePerArea - nanoFramework + Andreas Gullberg Larsen,nanoframework + UnitsNet + MIT-0 + https://github.com/angularsen/UnitsNet + false + Adds ElectricConductancePerArea 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 electricconductanceperarea unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable + + + + + + + + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductancePerArea/packages.config b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductancePerArea/packages.config new file mode 100644 index 0000000000..313a8dccdf --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductancePerArea/packages.config @@ -0,0 +1,4 @@ + + + + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductancePerArea.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductancePerArea.g.cs new file mode 100644 index 0000000000..bb44e72300 --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductancePerArea.g.cs @@ -0,0 +1,383 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using UnitsNet.Units; + +namespace UnitsNet +{ + /// + /// + /// The electrical conductance per area of an electrical conductor is a measure of the easeness to pass an electric current through that conductor per unit area. + /// + /// + /// https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance + /// + public struct ElectricConductancePerArea + { + /// + /// The numeric value this quantity was constructed with. + /// + private readonly double _value; + + /// + /// The unit this quantity was constructed with. + /// + private readonly ElectricConductancePerAreaUnit _unit; + + /// + /// The numeric value this quantity was constructed with. + /// + public double Value => _value; + + /// + public ElectricConductancePerAreaUnit Unit => _unit; + + /// + /// Creates the quantity with the given numeric value and unit. + /// + /// The numeric value to construct this quantity with. + /// The unit representation to construct this quantity with. + /// If value is NaN or Infinity. + public ElectricConductancePerArea(double value, ElectricConductancePerAreaUnit unit) + { + _value = value; + _unit = unit; + } + + /// + /// The base unit of ElectricConductancePerArea, which is Second. All conversions go via this value. + /// + public static ElectricConductancePerAreaUnit BaseUnit { get; } = ElectricConductancePerAreaUnit.SiemensPerSquareMeter; + + /// + /// Represents the largest possible value of ElectricConductancePerArea. + /// + public static ElectricConductancePerArea MaxValue { get; } = new ElectricConductancePerArea(double.MaxValue, BaseUnit); + + /// + /// Represents the smallest possible value of ElectricConductancePerArea. + /// + public static ElectricConductancePerArea MinValue { get; } = new ElectricConductancePerArea(double.MinValue, BaseUnit); + + /// + /// Gets an instance of this quantity with a value of 0 in the base unit Second. + /// + public static ElectricConductancePerArea Zero { get; } = new ElectricConductancePerArea(0, BaseUnit); + #region Conversion Properties + + /// + /// Gets a value of this quantity converted into + /// + public double FemtosiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double KilosiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MegasiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MicrosiemensPerSquareCentimeters => As(ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MicrosiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillisiemensPerSquareCentimeters => As(ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillisiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double NanosiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double PicosiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareCentimeters => As(ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareDecimeters => As(ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareFeet => As(ElectricConductancePerAreaUnit.SiemensPerSquareFoot); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareInches => As(ElectricConductancePerAreaUnit.SiemensPerSquareInch); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.SiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareMiles => As(ElectricConductancePerAreaUnit.SiemensPerSquareMile); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareMillimeters => As(ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareYards => As(ElectricConductancePerAreaUnit.SiemensPerSquareYard); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerUsSurveySquareFeet => As(ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot); + + #endregion + + #region Static Factory Methods + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromFemtosiemensPerSquareMeter(double femtosiemenspersquaremeter) => new ElectricConductancePerArea(femtosiemenspersquaremeter, ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromKilosiemensPerSquareMeter(double kilosiemenspersquaremeter) => new ElectricConductancePerArea(kilosiemenspersquaremeter, ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromMegasiemensPerSquareMeter(double megasiemenspersquaremeter) => new ElectricConductancePerArea(megasiemenspersquaremeter, ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromMicrosiemensPerSquareCentimeters(double microsiemenspersquarecentimeters) => new ElectricConductancePerArea(microsiemenspersquarecentimeters, ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromMicrosiemensPerSquareMeter(double microsiemenspersquaremeter) => new ElectricConductancePerArea(microsiemenspersquaremeter, ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromMillisiemensPerSquareCentimeters(double millisiemenspersquarecentimeters) => new ElectricConductancePerArea(millisiemenspersquarecentimeters, ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromMillisiemensPerSquareMeter(double millisiemenspersquaremeter) => new ElectricConductancePerArea(millisiemenspersquaremeter, ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromNanosiemensPerSquareMeter(double nanosiemenspersquaremeter) => new ElectricConductancePerArea(nanosiemenspersquaremeter, ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromPicosiemensPerSquareMeter(double picosiemenspersquaremeter) => new ElectricConductancePerArea(picosiemenspersquaremeter, ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareCentimeters(double siemenspersquarecentimeters) => new ElectricConductancePerArea(siemenspersquarecentimeters, ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareDecimeters(double siemenspersquaredecimeters) => new ElectricConductancePerArea(siemenspersquaredecimeters, ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareFeet(double siemenspersquarefeet) => new ElectricConductancePerArea(siemenspersquarefeet, ElectricConductancePerAreaUnit.SiemensPerSquareFoot); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareInches(double siemenspersquareinches) => new ElectricConductancePerArea(siemenspersquareinches, ElectricConductancePerAreaUnit.SiemensPerSquareInch); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareMeter(double siemenspersquaremeter) => new ElectricConductancePerArea(siemenspersquaremeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareMiles(double siemenspersquaremiles) => new ElectricConductancePerArea(siemenspersquaremiles, ElectricConductancePerAreaUnit.SiemensPerSquareMile); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareMillimeters(double siemenspersquaremillimeters) => new ElectricConductancePerArea(siemenspersquaremillimeters, ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareYards(double siemenspersquareyards) => new ElectricConductancePerArea(siemenspersquareyards, ElectricConductancePerAreaUnit.SiemensPerSquareYard); + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerUsSurveySquareFeet(double siemensperussurveysquarefeet) => new ElectricConductancePerArea(siemensperussurveysquarefeet, ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot); + + /// + /// Dynamically convert from value and unit enum to . + /// + /// Value to convert from. + /// Unit to convert from. + /// ElectricConductancePerArea unit value. + public static ElectricConductancePerArea From(double value, ElectricConductancePerAreaUnit fromUnit) + { + return new ElectricConductancePerArea(value, fromUnit); + } + + #endregion + + #region Conversion Methods + + /// + /// Convert to the unit representation . + /// + /// Value converted to the specified unit. + public double As(ElectricConductancePerAreaUnit unit) => GetValueAs(unit); + + /// + /// Converts this ElectricConductancePerArea to another ElectricConductancePerArea with the unit representation . + /// + /// A ElectricConductancePerArea with the specified unit. + public ElectricConductancePerArea ToUnit(ElectricConductancePerAreaUnit unit) + { + var convertedValue = GetValueAs(unit); + return new ElectricConductancePerArea(convertedValue, unit); + } + + /// + /// Converts the current value + unit to the base unit. + /// This is typically the first step in converting from one unit to another. + /// + /// The value in the base unit representation. + private double GetValueInBaseUnit() + { + return Unit switch + { + ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter => (_value) * 1e-15d, + ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter => (_value) * 1e3d, + ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter => (_value) * 1e6d, + ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter => (_value / 1e-4) * 1e-6d, + ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter => (_value) * 1e-6d, + ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter => (_value / 1e-4) * 1e-3d, + ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter => (_value) * 1e-3d, + ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter => (_value) * 1e-9d, + ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter => (_value) * 1e-12d, + ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter => _value / 1e-4, + ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter => _value / 1e-2, + ElectricConductancePerAreaUnit.SiemensPerSquareFoot => _value / 0.092903, + ElectricConductancePerAreaUnit.SiemensPerSquareInch => _value / 0.00064516, + ElectricConductancePerAreaUnit.SiemensPerSquareMeter => _value, + ElectricConductancePerAreaUnit.SiemensPerSquareMile => _value / 2.59e6, + ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter => _value / 1e-6, + ElectricConductancePerAreaUnit.SiemensPerSquareYard => _value / 0.836127, + ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot => _value / 0.09290341161, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; + } + + private double GetValueAs(ElectricConductancePerAreaUnit unit) + { + if (Unit == unit) + return _value; + + var baseUnitValue = GetValueInBaseUnit(); + + return unit switch + { + ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter => (baseUnitValue) / 1e-15d, + ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter => (baseUnitValue) / 1e3d, + ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter => (baseUnitValue) / 1e6d, + ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter => (baseUnitValue * 1e-4) / 1e-6d, + ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter => (baseUnitValue) / 1e-6d, + ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter => (baseUnitValue * 1e-4) / 1e-3d, + ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter => (baseUnitValue) / 1e-3d, + ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter => (baseUnitValue) / 1e-9d, + ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter => (baseUnitValue) / 1e-12d, + ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter => baseUnitValue * 1e-4, + ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter => baseUnitValue * 1e-2, + ElectricConductancePerAreaUnit.SiemensPerSquareFoot => baseUnitValue * 0.092903, + ElectricConductancePerAreaUnit.SiemensPerSquareInch => baseUnitValue * 0.00064516, + ElectricConductancePerAreaUnit.SiemensPerSquareMeter => baseUnitValue, + ElectricConductancePerAreaUnit.SiemensPerSquareMile => baseUnitValue * 2.59e6, + ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter => baseUnitValue * 1e-6, + ElectricConductancePerAreaUnit.SiemensPerSquareYard => baseUnitValue * 0.836127, + ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot => baseUnitValue * 0.09290341161, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; + } + + #endregion + } +} + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricConductancePerAreaUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricConductancePerAreaUnit.g.cs new file mode 100644 index 0000000000..ac600360de --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricConductancePerAreaUnit.g.cs @@ -0,0 +1,49 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Units +{ + // Disable missing XML comment warnings for the generated unit enums. + #pragma warning disable 1591 + + public enum ElectricConductancePerAreaUnit + { + FemtosiemensPerSquareMeter = 9, + KilosiemensPerSquareMeter = 5, + MegasiemensPerSquareMeter = 1, + MicrosiemensPerSquareCentimeter = 8, + MicrosiemensPerSquareMeter = 6, + MillisiemensPerSquareCentimeter = 4, + MillisiemensPerSquareMeter = 7, + NanosiemensPerSquareMeter = 2, + PicosiemensPerSquareMeter = 10, + SiemensPerSquareCentimeter = 3, + SiemensPerSquareDecimeter = 14, + SiemensPerSquareFoot = 15, + SiemensPerSquareInch = 19, + SiemensPerSquareMeter = 17, + SiemensPerSquareMile = 12, + SiemensPerSquareMillimeter = 20, + SiemensPerSquareYard = 18, + SiemensPerUsSurveySquareFoot = 16, + } + + #pragma warning restore 1591 +} diff --git a/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln b/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln index d64098f57d..dd833416d7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln +++ b/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln @@ -46,6 +46,8 @@ Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "ElectricChargeDensity", "El EndProject Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "ElectricConductance", "ElectricConductance\ElectricConductance.nfproj", "{fcd3dfb2-9ee2-ad22-0e1f-4cddd575792a}" EndProject +Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "ElectricConductancePerArea", "ElectricConductancePerArea\ElectricConductancePerArea.nfproj", "{554f9914-133f-0a1d-e5e0-17c3879852be}" +EndProject Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "ElectricConductivity", "ElectricConductivity\ElectricConductivity.nfproj", "{f420eccc-b12d-72e4-2ad2-f93054eeec30}" EndProject Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "ElectricCurrent", "ElectricCurrent\ElectricCurrent.nfproj", "{55160a70-69b2-4144-b974-b64d78bd50e0}" @@ -388,6 +390,12 @@ Global {fcd3dfb2-9ee2-ad22-0e1f-4cddd575792a}.Release|Any CPU.ActiveCfg = Release|Any CPU {fcd3dfb2-9ee2-ad22-0e1f-4cddd575792a}.Release|Any CPU.Build.0 = Release|Any CPU {fcd3dfb2-9ee2-ad22-0e1f-4cddd575792a}.Release|Any CPU.Deploy.0 = Release|Any CPU +{554f9914-133f-0a1d-e5e0-17c3879852be}.Debug|Any CPU.ActiveCfg = Debug|Any CPU +{554f9914-133f-0a1d-e5e0-17c3879852be}.Debug|Any CPU.Build.0 = Debug|Any CPU +{554f9914-133f-0a1d-e5e0-17c3879852be}.Debug|Any CPU.Deploy.0 = Debug|Any CPU +{554f9914-133f-0a1d-e5e0-17c3879852be}.Release|Any CPU.ActiveCfg = Release|Any CPU +{554f9914-133f-0a1d-e5e0-17c3879852be}.Release|Any CPU.Build.0 = Release|Any CPU +{554f9914-133f-0a1d-e5e0-17c3879852be}.Release|Any CPU.Deploy.0 = Release|Any CPU {f420eccc-b12d-72e4-2ad2-f93054eeec30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {f420eccc-b12d-72e4-2ad2-f93054eeec30}.Debug|Any CPU.Build.0 = Debug|Any CPU {f420eccc-b12d-72e4-2ad2-f93054eeec30}.Debug|Any CPU.Deploy.0 = Debug|Any CPU diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricConductancePerAreaExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricConductancePerAreaExtensionsTest.g.cs new file mode 100644 index 0000000000..2bd2f9f750 --- /dev/null +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricConductancePerAreaExtensionsTest.g.cs @@ -0,0 +1,100 @@ +//------------------------------------------------------------------------------ +// +// 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.NumberToElectricConductancePerArea; +using Xunit; + +namespace UnitsNet.Tests +{ + public class NumberToElectricConductancePerAreaExtensionsTests + { + [Fact] + public void NumberToFemtosiemensPerSquareMeterTest() => + Assert.Equal(ElectricConductancePerArea.FromFemtosiemensPerSquareMeter(2), 2.FemtosiemensPerSquareMeter()); + + [Fact] + public void NumberToKilosiemensPerSquareMeterTest() => + Assert.Equal(ElectricConductancePerArea.FromKilosiemensPerSquareMeter(2), 2.KilosiemensPerSquareMeter()); + + [Fact] + public void NumberToMegasiemensPerSquareMeterTest() => + Assert.Equal(ElectricConductancePerArea.FromMegasiemensPerSquareMeter(2), 2.MegasiemensPerSquareMeter()); + + [Fact] + public void NumberToMicrosiemensPerSquareCentimetersTest() => + Assert.Equal(ElectricConductancePerArea.FromMicrosiemensPerSquareCentimeters(2), 2.MicrosiemensPerSquareCentimeters()); + + [Fact] + public void NumberToMicrosiemensPerSquareMeterTest() => + Assert.Equal(ElectricConductancePerArea.FromMicrosiemensPerSquareMeter(2), 2.MicrosiemensPerSquareMeter()); + + [Fact] + public void NumberToMillisiemensPerSquareCentimetersTest() => + Assert.Equal(ElectricConductancePerArea.FromMillisiemensPerSquareCentimeters(2), 2.MillisiemensPerSquareCentimeters()); + + [Fact] + public void NumberToMillisiemensPerSquareMeterTest() => + Assert.Equal(ElectricConductancePerArea.FromMillisiemensPerSquareMeter(2), 2.MillisiemensPerSquareMeter()); + + [Fact] + public void NumberToNanosiemensPerSquareMeterTest() => + Assert.Equal(ElectricConductancePerArea.FromNanosiemensPerSquareMeter(2), 2.NanosiemensPerSquareMeter()); + + [Fact] + public void NumberToPicosiemensPerSquareMeterTest() => + Assert.Equal(ElectricConductancePerArea.FromPicosiemensPerSquareMeter(2), 2.PicosiemensPerSquareMeter()); + + [Fact] + public void NumberToSiemensPerSquareCentimetersTest() => + Assert.Equal(ElectricConductancePerArea.FromSiemensPerSquareCentimeters(2), 2.SiemensPerSquareCentimeters()); + + [Fact] + public void NumberToSiemensPerSquareDecimetersTest() => + Assert.Equal(ElectricConductancePerArea.FromSiemensPerSquareDecimeters(2), 2.SiemensPerSquareDecimeters()); + + [Fact] + public void NumberToSiemensPerSquareFeetTest() => + Assert.Equal(ElectricConductancePerArea.FromSiemensPerSquareFeet(2), 2.SiemensPerSquareFeet()); + + [Fact] + public void NumberToSiemensPerSquareInchesTest() => + Assert.Equal(ElectricConductancePerArea.FromSiemensPerSquareInches(2), 2.SiemensPerSquareInches()); + + [Fact] + public void NumberToSiemensPerSquareMeterTest() => + Assert.Equal(ElectricConductancePerArea.FromSiemensPerSquareMeter(2), 2.SiemensPerSquareMeter()); + + [Fact] + public void NumberToSiemensPerSquareMilesTest() => + Assert.Equal(ElectricConductancePerArea.FromSiemensPerSquareMiles(2), 2.SiemensPerSquareMiles()); + + [Fact] + public void NumberToSiemensPerSquareMillimetersTest() => + Assert.Equal(ElectricConductancePerArea.FromSiemensPerSquareMillimeters(2), 2.SiemensPerSquareMillimeters()); + + [Fact] + public void NumberToSiemensPerSquareYardsTest() => + Assert.Equal(ElectricConductancePerArea.FromSiemensPerSquareYards(2), 2.SiemensPerSquareYards()); + + [Fact] + public void NumberToSiemensPerUsSurveySquareFeetTest() => + Assert.Equal(ElectricConductancePerArea.FromSiemensPerUsSurveySquareFeet(2), 2.SiemensPerUsSurveySquareFeet()); + + } +} diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductancePerAreaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductancePerAreaExtensions.g.cs new file mode 100644 index 0000000000..e5c0fd6e60 --- /dev/null +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductancePerAreaExtensions.g.cs @@ -0,0 +1,180 @@ +//------------------------------------------------------------------------------ +// +// 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.NumberToElectricConductancePerArea +{ + /// + /// A number to ElectricConductancePerArea Extensions + /// + public static class NumberToElectricConductancePerAreaExtensions + { + /// + public static ElectricConductancePerArea FemtosiemensPerSquareMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromFemtosiemensPerSquareMeter(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea KilosiemensPerSquareMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromKilosiemensPerSquareMeter(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea MegasiemensPerSquareMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromMegasiemensPerSquareMeter(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea MicrosiemensPerSquareCentimeters(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromMicrosiemensPerSquareCentimeters(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea MicrosiemensPerSquareMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromMicrosiemensPerSquareMeter(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea MillisiemensPerSquareCentimeters(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromMillisiemensPerSquareCentimeters(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea MillisiemensPerSquareMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromMillisiemensPerSquareMeter(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea NanosiemensPerSquareMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromNanosiemensPerSquareMeter(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea PicosiemensPerSquareMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromPicosiemensPerSquareMeter(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea SiemensPerSquareCentimeters(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromSiemensPerSquareCentimeters(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea SiemensPerSquareDecimeters(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromSiemensPerSquareDecimeters(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea SiemensPerSquareFeet(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromSiemensPerSquareFeet(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea SiemensPerSquareInches(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromSiemensPerSquareInches(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea SiemensPerSquareMeter(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromSiemensPerSquareMeter(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea SiemensPerSquareMiles(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromSiemensPerSquareMiles(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea SiemensPerSquareMillimeters(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromSiemensPerSquareMillimeters(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea SiemensPerSquareYards(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromSiemensPerSquareYards(Convert.ToDouble(value)); + + /// + public static ElectricConductancePerArea SiemensPerUsSurveySquareFeet(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => ElectricConductancePerArea.FromSiemensPerUsSurveySquareFeet(Convert.ToDouble(value)); + + } +} diff --git a/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs b/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs new file mode 100644 index 0000000000..dbd8b8de45 --- /dev/null +++ b/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs @@ -0,0 +1,46 @@ +//------------------------------------------------------------------------------ +// +// 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 ElectricConductancePerAreaTests : ElectricConductancePerAreaTestsBase + { + protected override bool SupportsSIUnitSystem => true; + protected override double FemtosiemensPerSquareMeterInOneSiemensPerSquareMeter => 1E+15; + protected override double KilosiemensPerSquareMeterInOneSiemensPerSquareMeter => 1E-3; + protected override double MegasiemensPerSquareMeterInOneSiemensPerSquareMeter => 1E-06; + protected override double MicrosiemensPerSquareCentimetersInOneSiemensPerSquareMeter => 1E2; + protected override double MicrosiemensPerSquareMeterInOneSiemensPerSquareMeter => 1E6; + protected override double MillisiemensPerSquareCentimetersInOneSiemensPerSquareMeter => 1E-1; + protected override double MillisiemensPerSquareMeterInOneSiemensPerSquareMeter => 1E3; + protected override double NanosiemensPerSquareMeterInOneSiemensPerSquareMeter => 1E9; + protected override double PicosiemensPerSquareMeterInOneSiemensPerSquareMeter => 1E+12; + protected override double SiemensPerSquareCentimetersInOneSiemensPerSquareMeter => 1E-4; + protected override double SiemensPerSquareDecimetersInOneSiemensPerSquareMeter => 1E-2; + protected override double SiemensPerSquareFeetInOneSiemensPerSquareMeter => 0.092903; + protected override double SiemensPerSquareInchesInOneSiemensPerSquareMeter => 0.00064516; + protected override double SiemensPerSquareMeterInOneSiemensPerSquareMeter => 1; + protected override double SiemensPerSquareMilesInOneSiemensPerSquareMeter => 2.59E6; + protected override double SiemensPerSquareMillimetersInOneSiemensPerSquareMeter => 1E-6; + protected override double SiemensPerSquareYardsInOneSiemensPerSquareMeter => 0.836127; + protected override double SiemensPerUsSurveySquareFeetInOneSiemensPerSquareMeter => 0.09290341161; + } +} diff --git a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs index 7dc41682e2..5ef1d4d34b 100644 --- a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs +++ b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs @@ -56,6 +56,7 @@ void Assertion(int expectedValue, Enum expectedUnit, IQuantity quantity) Assertion(3, ElectricChargeUnit.Picocoulomb, Quantity.From(3, ElectricChargeUnit.Picocoulomb)); Assertion(3, ElectricChargeDensityUnit.CoulombPerCubicMeter, Quantity.From(3, ElectricChargeDensityUnit.CoulombPerCubicMeter)); Assertion(3, ElectricConductanceUnit.Siemens, Quantity.From(3, ElectricConductanceUnit.Siemens)); + Assertion(3, ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot, Quantity.From(3, ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot)); Assertion(3, ElectricConductivityUnit.SiemensPerMeter, Quantity.From(3, ElectricConductivityUnit.SiemensPerMeter)); Assertion(3, ElectricCurrentUnit.Picoampere, Quantity.From(3, ElectricCurrentUnit.Picoampere)); Assertion(3, ElectricCurrentDensityUnit.AmperePerSquareMeter, Quantity.From(3, ElectricCurrentDensityUnit.AmperePerSquareMeter)); @@ -187,6 +188,7 @@ public void QuantityInfo_IsSameAsStaticInfoProperty() Assertion(ElectricCharge.Info, ElectricCharge.Zero); Assertion(ElectricChargeDensity.Info, ElectricChargeDensity.Zero); Assertion(ElectricConductance.Info, ElectricConductance.Zero); + Assertion(ElectricConductancePerArea.Info, ElectricConductancePerArea.Zero); Assertion(ElectricConductivity.Info, ElectricConductivity.Zero); Assertion(ElectricCurrent.Info, ElectricCurrent.Zero); Assertion(ElectricCurrentDensity.Info, ElectricCurrentDensity.Zero); @@ -318,6 +320,7 @@ public void Dimensions_IsSameAsStaticBaseDimensions() Assertion(ElectricCharge.BaseDimensions, ElectricCharge.Zero); Assertion(ElectricChargeDensity.BaseDimensions, ElectricChargeDensity.Zero); Assertion(ElectricConductance.BaseDimensions, ElectricConductance.Zero); + Assertion(ElectricConductancePerArea.BaseDimensions, ElectricConductancePerArea.Zero); Assertion(ElectricConductivity.BaseDimensions, ElectricConductivity.Zero); Assertion(ElectricCurrent.BaseDimensions, ElectricCurrent.Zero); Assertion(ElectricCurrentDensity.BaseDimensions, ElectricCurrentDensity.Zero); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductancePerAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductancePerAreaTestsBase.g.cs new file mode 100644 index 0000000000..5000a62239 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductancePerAreaTestsBase.g.cs @@ -0,0 +1,1240 @@ +//------------------------------------------------------------------------------ +// +// 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 ElectricConductancePerArea. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricConductancePerAreaTestsBase : QuantityTestsBase + { + protected abstract double FemtosiemensPerSquareMeterInOneSiemensPerSquareMeter { get; } + protected abstract double KilosiemensPerSquareMeterInOneSiemensPerSquareMeter { get; } + protected abstract double MegasiemensPerSquareMeterInOneSiemensPerSquareMeter { get; } + protected abstract double MicrosiemensPerSquareCentimetersInOneSiemensPerSquareMeter { get; } + protected abstract double MicrosiemensPerSquareMeterInOneSiemensPerSquareMeter { get; } + protected abstract double MillisiemensPerSquareCentimetersInOneSiemensPerSquareMeter { get; } + protected abstract double MillisiemensPerSquareMeterInOneSiemensPerSquareMeter { get; } + protected abstract double NanosiemensPerSquareMeterInOneSiemensPerSquareMeter { get; } + protected abstract double PicosiemensPerSquareMeterInOneSiemensPerSquareMeter { get; } + protected abstract double SiemensPerSquareCentimetersInOneSiemensPerSquareMeter { get; } + protected abstract double SiemensPerSquareDecimetersInOneSiemensPerSquareMeter { get; } + protected abstract double SiemensPerSquareFeetInOneSiemensPerSquareMeter { get; } + protected abstract double SiemensPerSquareInchesInOneSiemensPerSquareMeter { get; } + protected abstract double SiemensPerSquareMeterInOneSiemensPerSquareMeter { get; } + protected abstract double SiemensPerSquareMilesInOneSiemensPerSquareMeter { get; } + protected abstract double SiemensPerSquareMillimetersInOneSiemensPerSquareMeter { get; } + protected abstract double SiemensPerSquareYardsInOneSiemensPerSquareMeter { get; } + protected abstract double SiemensPerUsSurveySquareFeetInOneSiemensPerSquareMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double FemtosiemensPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double KilosiemensPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double MegasiemensPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double MicrosiemensPerSquareCentimetersTolerance { get { return 1e-5; } } + protected virtual double MicrosiemensPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double MillisiemensPerSquareCentimetersTolerance { get { return 1e-5; } } + protected virtual double MillisiemensPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double NanosiemensPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double PicosiemensPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double SiemensPerSquareCentimetersTolerance { get { return 1e-5; } } + protected virtual double SiemensPerSquareDecimetersTolerance { get { return 1e-5; } } + protected virtual double SiemensPerSquareFeetTolerance { get { return 1e-5; } } + protected virtual double SiemensPerSquareInchesTolerance { get { return 1e-5; } } + protected virtual double SiemensPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double SiemensPerSquareMilesTolerance { get { return 1e-5; } } + protected virtual double SiemensPerSquareMillimetersTolerance { get { return 1e-5; } } + protected virtual double SiemensPerSquareYardsTolerance { get { return 1e-5; } } + protected virtual double SiemensPerUsSurveySquareFeetTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricConductancePerAreaUnit unit) + { + return unit switch + { + ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter => (FemtosiemensPerSquareMeterInOneSiemensPerSquareMeter, FemtosiemensPerSquareMeterTolerance), + ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter => (KilosiemensPerSquareMeterInOneSiemensPerSquareMeter, KilosiemensPerSquareMeterTolerance), + ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter => (MegasiemensPerSquareMeterInOneSiemensPerSquareMeter, MegasiemensPerSquareMeterTolerance), + ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter => (MicrosiemensPerSquareCentimetersInOneSiemensPerSquareMeter, MicrosiemensPerSquareCentimetersTolerance), + ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter => (MicrosiemensPerSquareMeterInOneSiemensPerSquareMeter, MicrosiemensPerSquareMeterTolerance), + ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter => (MillisiemensPerSquareCentimetersInOneSiemensPerSquareMeter, MillisiemensPerSquareCentimetersTolerance), + ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter => (MillisiemensPerSquareMeterInOneSiemensPerSquareMeter, MillisiemensPerSquareMeterTolerance), + ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter => (NanosiemensPerSquareMeterInOneSiemensPerSquareMeter, NanosiemensPerSquareMeterTolerance), + ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter => (PicosiemensPerSquareMeterInOneSiemensPerSquareMeter, PicosiemensPerSquareMeterTolerance), + ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter => (SiemensPerSquareCentimetersInOneSiemensPerSquareMeter, SiemensPerSquareCentimetersTolerance), + ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter => (SiemensPerSquareDecimetersInOneSiemensPerSquareMeter, SiemensPerSquareDecimetersTolerance), + ElectricConductancePerAreaUnit.SiemensPerSquareFoot => (SiemensPerSquareFeetInOneSiemensPerSquareMeter, SiemensPerSquareFeetTolerance), + ElectricConductancePerAreaUnit.SiemensPerSquareInch => (SiemensPerSquareInchesInOneSiemensPerSquareMeter, SiemensPerSquareInchesTolerance), + ElectricConductancePerAreaUnit.SiemensPerSquareMeter => (SiemensPerSquareMeterInOneSiemensPerSquareMeter, SiemensPerSquareMeterTolerance), + ElectricConductancePerAreaUnit.SiemensPerSquareMile => (SiemensPerSquareMilesInOneSiemensPerSquareMeter, SiemensPerSquareMilesTolerance), + ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter => (SiemensPerSquareMillimetersInOneSiemensPerSquareMeter, SiemensPerSquareMillimetersTolerance), + ElectricConductancePerAreaUnit.SiemensPerSquareYard => (SiemensPerSquareYardsInOneSiemensPerSquareMeter, SiemensPerSquareYardsTolerance), + ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot => (SiemensPerUsSurveySquareFeetInOneSiemensPerSquareMeter, SiemensPerUsSurveySquareFeetTolerance), + _ => throw new NotSupportedException() + }; + } + + public static IEnumerable UnitTypes = new List + { + new object[] { ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter }, + new object[] { ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter }, + new object[] { ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter }, + new object[] { ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter }, + new object[] { ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter }, + new object[] { ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter }, + new object[] { ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter }, + new object[] { ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter }, + new object[] { ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter }, + new object[] { ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter }, + new object[] { ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter }, + new object[] { ElectricConductancePerAreaUnit.SiemensPerSquareFoot }, + new object[] { ElectricConductancePerAreaUnit.SiemensPerSquareInch }, + new object[] { ElectricConductancePerAreaUnit.SiemensPerSquareMeter }, + new object[] { ElectricConductancePerAreaUnit.SiemensPerSquareMile }, + new object[] { ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter }, + new object[] { ElectricConductancePerAreaUnit.SiemensPerSquareYard }, + new object[] { ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot }, + }; + + [Fact] + public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() + { + var quantity = new ElectricConductancePerArea(); + Assert.Equal(0, quantity.Value); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity.Unit); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricConductancePerArea(double.PositiveInfinity, ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + Assert.Throws(() => new ElectricConductancePerArea(double.NegativeInfinity, ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricConductancePerArea(double.NaN, ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + } + + [Fact] + public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException() + { + Assert.Throws(() => new ElectricConductancePerArea(value: 1, unitSystem: null)); + } + + [Fact] + public void Ctor_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + Func TestCode = () => new ElectricConductancePerArea(value: 1, unitSystem: UnitSystem.SI); + if (SupportsSIUnitSystem) + { + var quantity = (ElectricConductancePerArea) TestCode(); + Assert.Equal(1, quantity.Value); + } + else + { + Assert.Throws(TestCode); + } + } + + [Fact] + public void ElectricConductancePerArea_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() + { + var quantity = new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareMeter); + + QuantityInfo quantityInfo = quantity.QuantityInfo; + + Assert.Equal(ElectricConductancePerArea.Zero, quantityInfo.Zero); + Assert.Equal("ElectricConductancePerArea", quantityInfo.Name); + + var units = EnumUtils.GetEnumValues().OrderBy(x => x.ToString()).ToArray(); + var unitNames = units.Select(x => x.ToString()); + } + + [Fact] + public void SiemensPerSquareMeterToElectricConductancePerAreaUnits() + { + ElectricConductancePerArea siemenspersquaremeter = ElectricConductancePerArea.FromSiemensPerSquareMeter(1); + AssertEx.EqualTolerance(FemtosiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.FemtosiemensPerSquareMeter, FemtosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(KilosiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.KilosiemensPerSquareMeter, KilosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(MegasiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.MegasiemensPerSquareMeter, MegasiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(MicrosiemensPerSquareCentimetersInOneSiemensPerSquareMeter, siemenspersquaremeter.MicrosiemensPerSquareCentimeters, MicrosiemensPerSquareCentimetersTolerance); + AssertEx.EqualTolerance(MicrosiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.MicrosiemensPerSquareMeter, MicrosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(MillisiemensPerSquareCentimetersInOneSiemensPerSquareMeter, siemenspersquaremeter.MillisiemensPerSquareCentimeters, MillisiemensPerSquareCentimetersTolerance); + AssertEx.EqualTolerance(MillisiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.MillisiemensPerSquareMeter, MillisiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(NanosiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.NanosiemensPerSquareMeter, NanosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(PicosiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.PicosiemensPerSquareMeter, PicosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(SiemensPerSquareCentimetersInOneSiemensPerSquareMeter, siemenspersquaremeter.SiemensPerSquareCentimeters, SiemensPerSquareCentimetersTolerance); + AssertEx.EqualTolerance(SiemensPerSquareDecimetersInOneSiemensPerSquareMeter, siemenspersquaremeter.SiemensPerSquareDecimeters, SiemensPerSquareDecimetersTolerance); + AssertEx.EqualTolerance(SiemensPerSquareFeetInOneSiemensPerSquareMeter, siemenspersquaremeter.SiemensPerSquareFeet, SiemensPerSquareFeetTolerance); + AssertEx.EqualTolerance(SiemensPerSquareInchesInOneSiemensPerSquareMeter, siemenspersquaremeter.SiemensPerSquareInches, SiemensPerSquareInchesTolerance); + AssertEx.EqualTolerance(SiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.SiemensPerSquareMeter, SiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(SiemensPerSquareMilesInOneSiemensPerSquareMeter, siemenspersquaremeter.SiemensPerSquareMiles, SiemensPerSquareMilesTolerance); + AssertEx.EqualTolerance(SiemensPerSquareMillimetersInOneSiemensPerSquareMeter, siemenspersquaremeter.SiemensPerSquareMillimeters, SiemensPerSquareMillimetersTolerance); + AssertEx.EqualTolerance(SiemensPerSquareYardsInOneSiemensPerSquareMeter, siemenspersquaremeter.SiemensPerSquareYards, SiemensPerSquareYardsTolerance); + AssertEx.EqualTolerance(SiemensPerUsSurveySquareFeetInOneSiemensPerSquareMeter, siemenspersquaremeter.SiemensPerUsSurveySquareFeet, SiemensPerUsSurveySquareFeetTolerance); + } + + [Fact] + public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() + { + var quantity00 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter); + AssertEx.EqualTolerance(1, quantity00.FemtosiemensPerSquareMeter, FemtosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter, quantity00.Unit); + + var quantity01 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter); + AssertEx.EqualTolerance(1, quantity01.KilosiemensPerSquareMeter, KilosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter, quantity01.Unit); + + var quantity02 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter); + AssertEx.EqualTolerance(1, quantity02.MegasiemensPerSquareMeter, MegasiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter, quantity02.Unit); + + var quantity03 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter); + AssertEx.EqualTolerance(1, quantity03.MicrosiemensPerSquareCentimeters, MicrosiemensPerSquareCentimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter, quantity03.Unit); + + var quantity04 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter); + AssertEx.EqualTolerance(1, quantity04.MicrosiemensPerSquareMeter, MicrosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter, quantity04.Unit); + + var quantity05 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter); + AssertEx.EqualTolerance(1, quantity05.MillisiemensPerSquareCentimeters, MillisiemensPerSquareCentimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter, quantity05.Unit); + + var quantity06 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter); + AssertEx.EqualTolerance(1, quantity06.MillisiemensPerSquareMeter, MillisiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter, quantity06.Unit); + + var quantity07 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter); + AssertEx.EqualTolerance(1, quantity07.NanosiemensPerSquareMeter, NanosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter, quantity07.Unit); + + var quantity08 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter); + AssertEx.EqualTolerance(1, quantity08.PicosiemensPerSquareMeter, PicosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter, quantity08.Unit); + + var quantity09 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter); + AssertEx.EqualTolerance(1, quantity09.SiemensPerSquareCentimeters, SiemensPerSquareCentimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter, quantity09.Unit); + + var quantity10 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter); + AssertEx.EqualTolerance(1, quantity10.SiemensPerSquareDecimeters, SiemensPerSquareDecimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter, quantity10.Unit); + + var quantity11 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.SiemensPerSquareFoot); + AssertEx.EqualTolerance(1, quantity11.SiemensPerSquareFeet, SiemensPerSquareFeetTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareFoot, quantity11.Unit); + + var quantity12 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.SiemensPerSquareInch); + AssertEx.EqualTolerance(1, quantity12.SiemensPerSquareInches, SiemensPerSquareInchesTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareInch, quantity12.Unit); + + var quantity13 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.SiemensPerSquareMeter); + AssertEx.EqualTolerance(1, quantity13.SiemensPerSquareMeter, SiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity13.Unit); + + var quantity14 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.SiemensPerSquareMile); + AssertEx.EqualTolerance(1, quantity14.SiemensPerSquareMiles, SiemensPerSquareMilesTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMile, quantity14.Unit); + + var quantity15 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter); + AssertEx.EqualTolerance(1, quantity15.SiemensPerSquareMillimeters, SiemensPerSquareMillimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter, quantity15.Unit); + + var quantity16 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.SiemensPerSquareYard); + AssertEx.EqualTolerance(1, quantity16.SiemensPerSquareYards, SiemensPerSquareYardsTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareYard, quantity16.Unit); + + var quantity17 = ElectricConductancePerArea.From(1, ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot); + AssertEx.EqualTolerance(1, quantity17.SiemensPerUsSurveySquareFeet, SiemensPerUsSurveySquareFeetTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot, quantity17.Unit); + + } + + [Fact] + public void FromSiemensPerSquareMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricConductancePerArea.FromSiemensPerSquareMeter(double.PositiveInfinity)); + Assert.Throws(() => ElectricConductancePerArea.FromSiemensPerSquareMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromSiemensPerSquareMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricConductancePerArea.FromSiemensPerSquareMeter(double.NaN)); + } + + [Fact] + public void As() + { + var siemenspersquaremeter = ElectricConductancePerArea.FromSiemensPerSquareMeter(1); + AssertEx.EqualTolerance(FemtosiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter), FemtosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(KilosiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter), KilosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(MegasiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter), MegasiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(MicrosiemensPerSquareCentimetersInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter), MicrosiemensPerSquareCentimetersTolerance); + AssertEx.EqualTolerance(MicrosiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter), MicrosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(MillisiemensPerSquareCentimetersInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter), MillisiemensPerSquareCentimetersTolerance); + AssertEx.EqualTolerance(MillisiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter), MillisiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(NanosiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter), NanosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(PicosiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter), PicosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(SiemensPerSquareCentimetersInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter), SiemensPerSquareCentimetersTolerance); + AssertEx.EqualTolerance(SiemensPerSquareDecimetersInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter), SiemensPerSquareDecimetersTolerance); + AssertEx.EqualTolerance(SiemensPerSquareFeetInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.SiemensPerSquareFoot), SiemensPerSquareFeetTolerance); + AssertEx.EqualTolerance(SiemensPerSquareInchesInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.SiemensPerSquareInch), SiemensPerSquareInchesTolerance); + AssertEx.EqualTolerance(SiemensPerSquareMeterInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.SiemensPerSquareMeter), SiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(SiemensPerSquareMilesInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.SiemensPerSquareMile), SiemensPerSquareMilesTolerance); + AssertEx.EqualTolerance(SiemensPerSquareMillimetersInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter), SiemensPerSquareMillimetersTolerance); + AssertEx.EqualTolerance(SiemensPerSquareYardsInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.SiemensPerSquareYard), SiemensPerSquareYardsTolerance); + AssertEx.EqualTolerance(SiemensPerUsSurveySquareFeetInOneSiemensPerSquareMeter, siemenspersquaremeter.As(ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot), SiemensPerUsSurveySquareFeetTolerance); + } + + [Fact] + public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var quantity = new ElectricConductancePerArea(value: 1, unit: ElectricConductancePerArea.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 = ElectricConductancePerArea.Parse("1 fS/m²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.FemtosiemensPerSquareMeter, FemtosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 kS/m²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.KilosiemensPerSquareMeter, KilosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 MS/m²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MegasiemensPerSquareMeter, MegasiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 µS/cm²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MicrosiemensPerSquareCentimeters, MicrosiemensPerSquareCentimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 µS/m²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MicrosiemensPerSquareMeter, MicrosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 mS/cm²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MillisiemensPerSquareCentimeters, MillisiemensPerSquareCentimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 mS/m²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MillisiemensPerSquareMeter, MillisiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 nS/m²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.NanosiemensPerSquareMeter, NanosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 pS/m²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.PicosiemensPerSquareMeter, PicosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 S/cm²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareCentimeters, SiemensPerSquareCentimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 S/dm²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareDecimeters, SiemensPerSquareDecimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 S/ft²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareFeet, SiemensPerSquareFeetTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareFoot, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 S/in²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareInches, SiemensPerSquareInchesTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareInch, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 S/m²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareMeter, SiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 S/mi²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareMiles, SiemensPerSquareMilesTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMile, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 S/mm²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareMillimeters, SiemensPerSquareMillimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 S/yd²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareYards, SiemensPerSquareYardsTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareYard, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = ElectricConductancePerArea.Parse("1 S/ft² (US)", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.SiemensPerUsSurveySquareFeet, SiemensPerUsSurveySquareFeetTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + } + + [Fact] + public void TryParse() + { + { + Assert.True(ElectricConductancePerArea.TryParse("1 fS/m²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.FemtosiemensPerSquareMeter, FemtosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 kS/m²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.KilosiemensPerSquareMeter, KilosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 µS/cm²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MicrosiemensPerSquareCentimeters, MicrosiemensPerSquareCentimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 µS/m²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MicrosiemensPerSquareMeter, MicrosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 mS/cm²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillisiemensPerSquareCentimeters, MillisiemensPerSquareCentimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 nS/m²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.NanosiemensPerSquareMeter, NanosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 pS/m²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.PicosiemensPerSquareMeter, PicosiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 S/cm²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareCentimeters, SiemensPerSquareCentimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 S/dm²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareDecimeters, SiemensPerSquareDecimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 S/ft²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareFeet, SiemensPerSquareFeetTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareFoot, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 S/in²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareInches, SiemensPerSquareInchesTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareInch, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 S/m²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareMeter, SiemensPerSquareMeterTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 S/mi²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareMiles, SiemensPerSquareMilesTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMile, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 S/mm²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareMillimeters, SiemensPerSquareMillimetersTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 S/yd²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.SiemensPerSquareYards, SiemensPerSquareYardsTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareYard, parsed.Unit); + } + + { + Assert.True(ElectricConductancePerArea.TryParse("1 S/ft² (US)", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.SiemensPerUsSurveySquareFeet, SiemensPerUsSurveySquareFeetTolerance); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot, parsed.Unit); + } + + } + + [Fact] + public void ParseUnit() + { + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("fS/m²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("kS/m²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("MS/m²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("µS/cm²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("µS/m²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("mS/cm²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("mS/m²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("nS/m²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("pS/m²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("S/cm²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("S/dm²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("S/ft²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareFoot, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("S/in²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareInch, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("S/m²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("S/mi²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMile, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("S/mm²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("S/yd²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareYard, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = ElectricConductancePerArea.ParseUnit("S/ft² (US)", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + } + + [Fact] + public void TryParseUnit() + { + { + Assert.True(ElectricConductancePerArea.TryParseUnit("fS/m²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("kS/m²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("µS/cm²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("µS/m²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("mS/cm²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("nS/m²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("pS/m²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("S/cm²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("S/dm²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("S/ft²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareFoot, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("S/in²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareInch, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("S/m²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("S/mi²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMile, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("S/mm²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("S/yd²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerSquareYard, parsedUnit); + } + + { + Assert.True(ElectricConductancePerArea.TryParseUnit("S/ft² (US)", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot, parsedUnit); + } + + } + + [Theory] + [MemberData(nameof(UnitTypes))] + public void ToUnit(ElectricConductancePerAreaUnit unit) + { + var inBaseUnits = ElectricConductancePerArea.From(1.0, ElectricConductancePerArea.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(ElectricConductancePerAreaUnit unit) + { + var quantity = ElectricConductancePerArea.From(3.0, unit); + var toUnitWithSameUnit = quantity.ToUnit(unit); + Assert.Equal(quantity, toUnitWithSameUnit); + } + + [Theory] + [MemberData(nameof(UnitTypes))] + public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricConductancePerAreaUnit 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 = ElectricConductancePerArea.Units.First(u => u != ElectricConductancePerArea.BaseUnit); + + var quantity = ElectricConductancePerArea.From(3.0, fromUnit); + var converted = quantity.ToUnit(unit); + Assert.Equal(converted.Unit, unit); + } + + [Theory] + [MemberData(nameof(UnitTypes))] + public virtual void ToUnit_FromDefaultQuantity_ReturnsQuantityWithGivenUnit(ElectricConductancePerAreaUnit unit) + { + var quantity = default(ElectricConductancePerArea); + var converted = quantity.ToUnit(unit); + Assert.Equal(converted.Unit, unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricConductancePerArea siemenspersquaremeter = ElectricConductancePerArea.FromSiemensPerSquareMeter(1); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromFemtosiemensPerSquareMeter(siemenspersquaremeter.FemtosiemensPerSquareMeter).SiemensPerSquareMeter, FemtosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromKilosiemensPerSquareMeter(siemenspersquaremeter.KilosiemensPerSquareMeter).SiemensPerSquareMeter, KilosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromMegasiemensPerSquareMeter(siemenspersquaremeter.MegasiemensPerSquareMeter).SiemensPerSquareMeter, MegasiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromMicrosiemensPerSquareCentimeters(siemenspersquaremeter.MicrosiemensPerSquareCentimeters).SiemensPerSquareMeter, MicrosiemensPerSquareCentimetersTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromMicrosiemensPerSquareMeter(siemenspersquaremeter.MicrosiemensPerSquareMeter).SiemensPerSquareMeter, MicrosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromMillisiemensPerSquareCentimeters(siemenspersquaremeter.MillisiemensPerSquareCentimeters).SiemensPerSquareMeter, MillisiemensPerSquareCentimetersTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromMillisiemensPerSquareMeter(siemenspersquaremeter.MillisiemensPerSquareMeter).SiemensPerSquareMeter, MillisiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromNanosiemensPerSquareMeter(siemenspersquaremeter.NanosiemensPerSquareMeter).SiemensPerSquareMeter, NanosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromPicosiemensPerSquareMeter(siemenspersquaremeter.PicosiemensPerSquareMeter).SiemensPerSquareMeter, PicosiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromSiemensPerSquareCentimeters(siemenspersquaremeter.SiemensPerSquareCentimeters).SiemensPerSquareMeter, SiemensPerSquareCentimetersTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromSiemensPerSquareDecimeters(siemenspersquaremeter.SiemensPerSquareDecimeters).SiemensPerSquareMeter, SiemensPerSquareDecimetersTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromSiemensPerSquareFeet(siemenspersquaremeter.SiemensPerSquareFeet).SiemensPerSquareMeter, SiemensPerSquareFeetTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromSiemensPerSquareInches(siemenspersquaremeter.SiemensPerSquareInches).SiemensPerSquareMeter, SiemensPerSquareInchesTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromSiemensPerSquareMeter(siemenspersquaremeter.SiemensPerSquareMeter).SiemensPerSquareMeter, SiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromSiemensPerSquareMiles(siemenspersquaremeter.SiemensPerSquareMiles).SiemensPerSquareMeter, SiemensPerSquareMilesTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromSiemensPerSquareMillimeters(siemenspersquaremeter.SiemensPerSquareMillimeters).SiemensPerSquareMeter, SiemensPerSquareMillimetersTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromSiemensPerSquareYards(siemenspersquaremeter.SiemensPerSquareYards).SiemensPerSquareMeter, SiemensPerSquareYardsTolerance); + AssertEx.EqualTolerance(1, ElectricConductancePerArea.FromSiemensPerUsSurveySquareFeet(siemenspersquaremeter.SiemensPerUsSurveySquareFeet).SiemensPerSquareMeter, SiemensPerUsSurveySquareFeetTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricConductancePerArea v = ElectricConductancePerArea.FromSiemensPerSquareMeter(1); + AssertEx.EqualTolerance(-1, -v.SiemensPerSquareMeter, SiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricConductancePerArea.FromSiemensPerSquareMeter(3)-v).SiemensPerSquareMeter, SiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).SiemensPerSquareMeter, SiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).SiemensPerSquareMeter, SiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).SiemensPerSquareMeter, SiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricConductancePerArea.FromSiemensPerSquareMeter(10)/5).SiemensPerSquareMeter, SiemensPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, ElectricConductancePerArea.FromSiemensPerSquareMeter(10)/ElectricConductancePerArea.FromSiemensPerSquareMeter(5), SiemensPerSquareMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricConductancePerArea oneSiemensPerSquareMeter = ElectricConductancePerArea.FromSiemensPerSquareMeter(1); + ElectricConductancePerArea twoSiemensPerSquareMeter = ElectricConductancePerArea.FromSiemensPerSquareMeter(2); + + Assert.True(oneSiemensPerSquareMeter < twoSiemensPerSquareMeter); + Assert.True(oneSiemensPerSquareMeter <= twoSiemensPerSquareMeter); + Assert.True(twoSiemensPerSquareMeter > oneSiemensPerSquareMeter); + Assert.True(twoSiemensPerSquareMeter >= oneSiemensPerSquareMeter); + + Assert.False(oneSiemensPerSquareMeter > twoSiemensPerSquareMeter); + Assert.False(oneSiemensPerSquareMeter >= twoSiemensPerSquareMeter); + Assert.False(twoSiemensPerSquareMeter < oneSiemensPerSquareMeter); + Assert.False(twoSiemensPerSquareMeter <= oneSiemensPerSquareMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricConductancePerArea siemenspersquaremeter = ElectricConductancePerArea.FromSiemensPerSquareMeter(1); + Assert.Equal(0, siemenspersquaremeter.CompareTo(siemenspersquaremeter)); + Assert.True(siemenspersquaremeter.CompareTo(ElectricConductancePerArea.Zero) > 0); + Assert.True(ElectricConductancePerArea.Zero.CompareTo(siemenspersquaremeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricConductancePerArea siemenspersquaremeter = ElectricConductancePerArea.FromSiemensPerSquareMeter(1); + Assert.Throws(() => siemenspersquaremeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricConductancePerArea siemenspersquaremeter = ElectricConductancePerArea.FromSiemensPerSquareMeter(1); + Assert.Throws(() => siemenspersquaremeter.CompareTo(null)); + } + + [Theory] + [InlineData(1, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, 1, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, true)] // Same value and unit. + [InlineData(1, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, 2, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, false)] // Different value. + [InlineData(2, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, 1, ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter, false)] // Different value and unit. + [InlineData(1, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, 1, ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter, false)] // Different unit. + public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricConductancePerAreaUnit unitA, double valueB, ElectricConductancePerAreaUnit unitB, bool expectEqual) + { + var a = new ElectricConductancePerArea(valueA, unitA); + var b = new ElectricConductancePerArea(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 = ElectricConductancePerArea.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 = ElectricConductancePerArea.FromSiemensPerSquareMeter(1); + Assert.True(v.Equals(ElectricConductancePerArea.FromSiemensPerSquareMeter(1), SiemensPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricConductancePerArea.Zero, SiemensPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.True(ElectricConductancePerArea.FromSiemensPerSquareMeter(100).Equals(ElectricConductancePerArea.FromSiemensPerSquareMeter(120), (double)0.3m, ComparisonType.Relative)); + Assert.False(ElectricConductancePerArea.FromSiemensPerSquareMeter(100).Equals(ElectricConductancePerArea.FromSiemensPerSquareMeter(120), (double)0.1m, ComparisonType.Relative)); + } + + [Fact] + public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + { + var v = ElectricConductancePerArea.FromSiemensPerSquareMeter(1); + Assert.Throws(() => v.Equals(ElectricConductancePerArea.FromSiemensPerSquareMeter(1), -1, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricConductancePerArea siemenspersquaremeter = ElectricConductancePerArea.FromSiemensPerSquareMeter(1); + Assert.False(siemenspersquaremeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricConductancePerArea siemenspersquaremeter = ElectricConductancePerArea.FromSiemensPerSquareMeter(1); + Assert.False(siemenspersquaremeter.Equals(null)); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricConductancePerAreaUnit)).Cast(); + foreach (var unit in units) + { + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricConductancePerArea.BaseDimensions is null); + } + + [Fact] + public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() + { + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); + try { + Assert.Equal("1 fS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter).ToString()); + Assert.Equal("1 kS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter).ToString()); + Assert.Equal("1 MS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter).ToString()); + Assert.Equal("1 µS/cm²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter).ToString()); + Assert.Equal("1 µS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter).ToString()); + Assert.Equal("1 mS/cm²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter).ToString()); + Assert.Equal("1 mS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter).ToString()); + Assert.Equal("1 nS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter).ToString()); + Assert.Equal("1 pS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter).ToString()); + Assert.Equal("1 S/cm²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter).ToString()); + Assert.Equal("1 S/dm²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter).ToString()); + Assert.Equal("1 S/ft²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareFoot).ToString()); + Assert.Equal("1 S/in²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareInch).ToString()); + Assert.Equal("1 S/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareMeter).ToString()); + Assert.Equal("1 S/mi²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareMile).ToString()); + Assert.Equal("1 S/mm²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter).ToString()); + Assert.Equal("1 S/yd²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareYard).ToString()); + Assert.Equal("1 S/ft² (US)", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot).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 fS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter).ToString(swedishCulture)); + Assert.Equal("1 kS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter).ToString(swedishCulture)); + Assert.Equal("1 MS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter).ToString(swedishCulture)); + Assert.Equal("1 µS/cm²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter).ToString(swedishCulture)); + Assert.Equal("1 µS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter).ToString(swedishCulture)); + Assert.Equal("1 mS/cm²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter).ToString(swedishCulture)); + Assert.Equal("1 mS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter).ToString(swedishCulture)); + Assert.Equal("1 nS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter).ToString(swedishCulture)); + Assert.Equal("1 pS/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter).ToString(swedishCulture)); + Assert.Equal("1 S/cm²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter).ToString(swedishCulture)); + Assert.Equal("1 S/dm²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter).ToString(swedishCulture)); + Assert.Equal("1 S/ft²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareFoot).ToString(swedishCulture)); + Assert.Equal("1 S/in²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareInch).ToString(swedishCulture)); + Assert.Equal("1 S/m²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareMeter).ToString(swedishCulture)); + Assert.Equal("1 S/mi²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareMile).ToString(swedishCulture)); + Assert.Equal("1 S/mm²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter).ToString(swedishCulture)); + Assert.Equal("1 S/yd²", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerSquareYard).ToString(swedishCulture)); + Assert.Equal("1 S/ft² (US)", new ElectricConductancePerArea(1, ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot).ToString(swedishCulture)); + } + + [Fact] + public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() + { + var oldCulture = CultureInfo.CurrentCulture; + try + { + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; + Assert.Equal("0.1 S/m²", new ElectricConductancePerArea(0.123456, ElectricConductancePerAreaUnit.SiemensPerSquareMeter).ToString("s1")); + Assert.Equal("0.12 S/m²", new ElectricConductancePerArea(0.123456, ElectricConductancePerAreaUnit.SiemensPerSquareMeter).ToString("s2")); + Assert.Equal("0.123 S/m²", new ElectricConductancePerArea(0.123456, ElectricConductancePerAreaUnit.SiemensPerSquareMeter).ToString("s3")); + Assert.Equal("0.1235 S/m²", new ElectricConductancePerArea(0.123456, ElectricConductancePerAreaUnit.SiemensPerSquareMeter).ToString("s4")); + } + finally + { + CultureInfo.CurrentCulture = oldCulture; + } + } + + [Fact] + public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixForGivenCulture() + { + var culture = CultureInfo.InvariantCulture; + Assert.Equal("0.1 S/m²", new ElectricConductancePerArea(0.123456, ElectricConductancePerAreaUnit.SiemensPerSquareMeter).ToString("s1", culture)); + Assert.Equal("0.12 S/m²", new ElectricConductancePerArea(0.123456, ElectricConductancePerAreaUnit.SiemensPerSquareMeter).ToString("s2", culture)); + Assert.Equal("0.123 S/m²", new ElectricConductancePerArea(0.123456, ElectricConductancePerAreaUnit.SiemensPerSquareMeter).ToString("s3", culture)); + Assert.Equal("0.1235 S/m²", new ElectricConductancePerArea(0.123456, ElectricConductancePerAreaUnit.SiemensPerSquareMeter).ToString("s4", culture)); + } + + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(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 = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); + } + + [Fact] + public void Convert_ToBool_ThrowsInvalidCastException() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Throws(() => Convert.ToBoolean(quantity)); + } + + [Fact] + public void Convert_ToByte_EqualsValueAsSameType() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + } + + [Fact] + public void Convert_ToChar_ThrowsInvalidCastException() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Throws(() => Convert.ToChar(quantity)); + } + + [Fact] + public void Convert_ToDateTime_ThrowsInvalidCastException() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Throws(() => Convert.ToDateTime(quantity)); + } + + [Fact] + public void Convert_ToDecimal_EqualsValueAsSameType() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); + } + + [Fact] + public void Convert_ToDouble_EqualsValueAsSameType() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal((double)quantity.Value, Convert.ToDouble(quantity)); + } + + [Fact] + public void Convert_ToInt16_EqualsValueAsSameType() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + } + + [Fact] + public void Convert_ToInt32_EqualsValueAsSameType() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + } + + [Fact] + public void Convert_ToInt64_EqualsValueAsSameType() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + } + + [Fact] + public void Convert_ToSByte_EqualsValueAsSameType() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + } + + [Fact] + public void Convert_ToSingle_EqualsValueAsSameType() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + } + + [Fact] + public void Convert_ToString_EqualsToString() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); + } + + [Fact] + public void Convert_ToUInt16_EqualsValueAsSameType() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + } + + [Fact] + public void Convert_ToUInt32_EqualsValueAsSameType() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + } + + [Fact] + public void Convert_ToUInt64_EqualsValueAsSameType() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + } + + [Fact] + public void Convert_ChangeType_SelfType_EqualsSelf() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(ElectricConductancePerArea))); + } + + [Fact] + public void Convert_ChangeType_UnitType_EqualsUnit() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricConductancePerAreaUnit))); + } + + [Fact] + public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal(ElectricConductancePerArea.Info, Convert.ChangeType(quantity, typeof(QuantityInfo))); + } + + [Fact] + public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal(ElectricConductancePerArea.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); + } + + [Fact] + public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Throws(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); + } + + [Fact] + public void GetHashCode_Equals() + { + var quantity = ElectricConductancePerArea.FromSiemensPerSquareMeter(1.0); + Assert.Equal(new {ElectricConductancePerArea.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 = ElectricConductancePerArea.FromSiemensPerSquareMeter(value); + Assert.Equal(ElectricConductancePerArea.FromSiemensPerSquareMeter(-value), -quantity); + } + } +} diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductancePerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductancePerArea.g.cs new file mode 100644 index 0000000000..1736512299 --- /dev/null +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductancePerArea.g.cs @@ -0,0 +1,1275 @@ +//------------------------------------------------------------------------------ +// +// 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 electrical conductance per area of an electrical conductor is a measure of the easeness to pass an electric current through that conductor per unit area. + /// + /// + /// https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance + /// + [DataContract] + [DebuggerTypeProxy(typeof(QuantityDisplay))] + public readonly partial struct ElectricConductancePerArea : + 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 ElectricConductancePerAreaUnit? _unit; + + static ElectricConductancePerArea() + { + BaseDimensions = new BaseDimensions(-4, -1, 3, 2, 0, 0, 0); + BaseUnit = ElectricConductancePerAreaUnit.SiemensPerSquareMeter; + Units = Enum.GetValues(typeof(ElectricConductancePerAreaUnit)).Cast().ToArray(); + Zero = new ElectricConductancePerArea(0, BaseUnit); + Info = new QuantityInfo("ElectricConductancePerArea", + new UnitInfo[] + { + new UnitInfo(ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter, "FemtosiemensPerSquareMeter", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter, "KilosiemensPerSquareMeter", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter, "MegasiemensPerSquareMeter", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter, "MicrosiemensPerSquareCentimeters", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter, "MicrosiemensPerSquareMeter", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter, "MillisiemensPerSquareCentimeters", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter, "MillisiemensPerSquareMeter", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter, "NanosiemensPerSquareMeter", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter, "PicosiemensPerSquareMeter", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter, "SiemensPerSquareCentimeters", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter, "SiemensPerSquareDecimeters", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.SiemensPerSquareFoot, "SiemensPerSquareFeet", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.SiemensPerSquareInch, "SiemensPerSquareInches", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, "SiemensPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere), "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.SiemensPerSquareMile, "SiemensPerSquareMiles", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter, "SiemensPerSquareMillimeters", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.SiemensPerSquareYard, "SiemensPerSquareYards", BaseUnits.Undefined, "ElectricConductancePerArea"), + new UnitInfo(ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot, "SiemensPerUsSurveySquareFeet", BaseUnits.Undefined, "ElectricConductancePerArea"), + }, + BaseUnit, Zero, BaseDimensions); + + DefaultConversionFunctions = new UnitConverter(); + RegisterDefaultConversions(DefaultConversionFunctions); + } + + /// + /// Creates the quantity with the given numeric value and unit. + /// + /// The numeric value to construct this quantity with. + /// The unit representation to construct this quantity with. + /// If value is NaN or Infinity. + public ElectricConductancePerArea(double value, ElectricConductancePerAreaUnit unit) + { + _value = Guard.EnsureValidNumber(value, nameof(value)); + _unit = unit; + } + + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// If multiple compatible units were found, the first match is used. + /// + /// The numeric value to construct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + public ElectricConductancePerArea(double value, UnitSystem unitSystem) + { + if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); + + var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); + var firstUnitInfo = unitInfos.FirstOrDefault(); + + _value = Guard.EnsureValidNumber(value, nameof(value)); + _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); + } + + #region Static Properties + + /// + /// The containing the default generated conversion functions for instances. + /// + public static UnitConverter DefaultConversionFunctions { get; } + + /// + public static QuantityInfo Info { get; } + + /// + /// The of this quantity. + /// + public static BaseDimensions BaseDimensions { get; } + + /// + /// The base unit of ElectricConductancePerArea, which is SiemensPerSquareMeter. All conversions go via this value. + /// + public static ElectricConductancePerAreaUnit BaseUnit { get; } + + /// + /// All units of measurement for the ElectricConductancePerArea quantity. + /// + public static ElectricConductancePerAreaUnit[] Units { get; } + + /// + /// Gets an instance of this quantity with a value of 0 in the base unit SiemensPerSquareMeter. + /// + public static ElectricConductancePerArea Zero { get; } + + /// + public static ElectricConductancePerArea AdditiveIdentity => Zero; + + #endregion + + #region Properties + + /// + /// The numeric value this quantity was constructed with. + /// + public double Value => _value; + + /// + QuantityValue IQuantity.Value => _value; + + Enum IQuantity.Unit => Unit; + + /// + public ElectricConductancePerAreaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + + /// + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + + /// + /// The of this quantity. + /// + public BaseDimensions Dimensions => ElectricConductancePerArea.BaseDimensions; + + #endregion + + #region Conversion Properties + + /// + /// Gets a value of this quantity converted into + /// + public double FemtosiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double KilosiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MegasiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MicrosiemensPerSquareCentimeters => As(ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MicrosiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillisiemensPerSquareCentimeters => As(ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double MillisiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double NanosiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double PicosiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareCentimeters => As(ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareDecimeters => As(ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareFeet => As(ElectricConductancePerAreaUnit.SiemensPerSquareFoot); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareInches => As(ElectricConductancePerAreaUnit.SiemensPerSquareInch); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareMeter => As(ElectricConductancePerAreaUnit.SiemensPerSquareMeter); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareMiles => As(ElectricConductancePerAreaUnit.SiemensPerSquareMile); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareMillimeters => As(ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerSquareYards => As(ElectricConductancePerAreaUnit.SiemensPerSquareYard); + + /// + /// Gets a value of this quantity converted into + /// + public double SiemensPerUsSurveySquareFeet => As(ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot); + + #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: ElectricConductancePerAreaUnit -> BaseUnit + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareFoot, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareInch, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMile, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareYard, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMeter)); + + // Register in unit converter: BaseUnit <-> BaseUnit + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter, quantity => quantity); + + // Register in unit converter: BaseUnit -> ElectricConductancePerAreaUnit + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareFoot, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareFoot)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareInch, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareInch)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMile, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMile)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareYard, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerSquareYard)); + unitConverter.SetConversionFunction(ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot, quantity => quantity.ToUnit(ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot)); + } + + /// + /// Get unit abbreviation string. + /// + /// Unit to get abbreviation for. + /// Unit abbreviation string. + public static string GetAbbreviation(ElectricConductancePerAreaUnit 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(ElectricConductancePerAreaUnit unit, IFormatProvider? provider) + { + return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); + } + + #endregion + + #region Static Factory Methods + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromFemtosiemensPerSquareMeter(QuantityValue femtosiemenspersquaremeter) + { + double value = (double) femtosiemenspersquaremeter; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromKilosiemensPerSquareMeter(QuantityValue kilosiemenspersquaremeter) + { + double value = (double) kilosiemenspersquaremeter; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromMegasiemensPerSquareMeter(QuantityValue megasiemenspersquaremeter) + { + double value = (double) megasiemenspersquaremeter; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromMicrosiemensPerSquareCentimeters(QuantityValue microsiemenspersquarecentimeters) + { + double value = (double) microsiemenspersquarecentimeters; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromMicrosiemensPerSquareMeter(QuantityValue microsiemenspersquaremeter) + { + double value = (double) microsiemenspersquaremeter; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromMillisiemensPerSquareCentimeters(QuantityValue millisiemenspersquarecentimeters) + { + double value = (double) millisiemenspersquarecentimeters; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromMillisiemensPerSquareMeter(QuantityValue millisiemenspersquaremeter) + { + double value = (double) millisiemenspersquaremeter; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromNanosiemensPerSquareMeter(QuantityValue nanosiemenspersquaremeter) + { + double value = (double) nanosiemenspersquaremeter; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromPicosiemensPerSquareMeter(QuantityValue picosiemenspersquaremeter) + { + double value = (double) picosiemenspersquaremeter; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareCentimeters(QuantityValue siemenspersquarecentimeters) + { + double value = (double) siemenspersquarecentimeters; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareDecimeters(QuantityValue siemenspersquaredecimeters) + { + double value = (double) siemenspersquaredecimeters; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareFeet(QuantityValue siemenspersquarefeet) + { + double value = (double) siemenspersquarefeet; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.SiemensPerSquareFoot); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareInches(QuantityValue siemenspersquareinches) + { + double value = (double) siemenspersquareinches; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.SiemensPerSquareInch); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareMeter(QuantityValue siemenspersquaremeter) + { + double value = (double) siemenspersquaremeter; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.SiemensPerSquareMeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareMiles(QuantityValue siemenspersquaremiles) + { + double value = (double) siemenspersquaremiles; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.SiemensPerSquareMile); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareMillimeters(QuantityValue siemenspersquaremillimeters) + { + double value = (double) siemenspersquaremillimeters; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerSquareYards(QuantityValue siemenspersquareyards) + { + double value = (double) siemenspersquareyards; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.SiemensPerSquareYard); + } + + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static ElectricConductancePerArea FromSiemensPerUsSurveySquareFeet(QuantityValue siemensperussurveysquarefeet) + { + double value = (double) siemensperussurveysquarefeet; + return new ElectricConductancePerArea(value, ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot); + } + + /// + /// Dynamically convert from value and unit enum to . + /// + /// Value to convert from. + /// Unit to convert from. + /// ElectricConductancePerArea unit value. + public static ElectricConductancePerArea From(QuantityValue value, ElectricConductancePerAreaUnit fromUnit) + { + return new ElectricConductancePerArea((double)value, fromUnit); + } + + #endregion + + #region Static Parse Methods + + /// + /// Parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// + /// Length.Parse("5.5 m", CultureInfo.GetCultureInfo("en-US")); + /// + /// The value of 'str' cannot be null. + /// + /// Expected string to have one or two pairs of quantity and unit in the format + /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" + /// + /// + /// More than one unit is represented by the specified unit abbreviation. + /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of + /// , and . + /// + /// + /// If anything else goes wrong, typically due to a bug or unhandled case. + /// We wrap exceptions in to allow you to distinguish + /// Units.NET exceptions from other exceptions. + /// + public static ElectricConductancePerArea 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 ElectricConductancePerArea Parse(string str, IFormatProvider? provider) + { + return QuantityParser.Default.Parse( + str, + provider, + From); + } + + /// + /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// Resulting unit quantity if successful. + /// + /// Length.Parse("5.5 m", CultureInfo.GetCultureInfo("en-US")); + /// + public static bool TryParse(string? str, out ElectricConductancePerArea result) + { + return TryParse(str, null, out result); + } + + /// + /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// Resulting unit quantity if successful. + /// True if successful, otherwise false. + /// + /// Length.Parse("5.5 m", CultureInfo.GetCultureInfo("en-US")); + /// + /// Format to use when parsing number and unit. Defaults to if null. + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricConductancePerArea 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 ElectricConductancePerAreaUnit 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 ElectricConductancePerAreaUnit ParseUnit(string str, IFormatProvider? provider) + { + return UnitParser.Default.Parse(str, provider); + } + + /// + public static bool TryParseUnit(string str, out ElectricConductancePerAreaUnit unit) + { + return TryParseUnit(str, null, out unit); + } + + /// + /// Parse a unit string. + /// + /// String to parse. Typically in the form: {number} {unit} + /// The parsed unit if successful. + /// True if successful, otherwise false. + /// + /// Length.TryParseUnit("m", CultureInfo.GetCultureInfo("en-US")); + /// + /// Format to use when parsing number and unit. Defaults to if null. + public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricConductancePerAreaUnit unit) + { + return UnitParser.Default.TryParse(str, provider, out unit); + } + + #endregion + + #region Arithmetic Operators + + /// Negate the value. + public static ElectricConductancePerArea operator -(ElectricConductancePerArea right) + { + return new ElectricConductancePerArea(-right.Value, right.Unit); + } + + /// Get from adding two . + public static ElectricConductancePerArea operator +(ElectricConductancePerArea left, ElectricConductancePerArea right) + { + return new ElectricConductancePerArea(left.Value + right.ToUnit(left.Unit).Value, left.Unit); + } + + /// Get from subtracting two . + public static ElectricConductancePerArea operator -(ElectricConductancePerArea left, ElectricConductancePerArea right) + { + return new ElectricConductancePerArea(left.Value - right.ToUnit(left.Unit).Value, left.Unit); + } + + /// Get from multiplying value and . + public static ElectricConductancePerArea operator *(double left, ElectricConductancePerArea right) + { + return new ElectricConductancePerArea(left * right.Value, right.Unit); + } + + /// Get from multiplying value and . + public static ElectricConductancePerArea operator *(ElectricConductancePerArea left, double right) + { + return new ElectricConductancePerArea(left.Value * right, left.Unit); + } + + /// Get from dividing by value. + public static ElectricConductancePerArea operator /(ElectricConductancePerArea left, double right) + { + return new ElectricConductancePerArea(left.Value / right, left.Unit); + } + + /// Get ratio value from dividing by . + public static double operator /(ElectricConductancePerArea left, ElectricConductancePerArea right) + { + return left.SiemensPerSquareMeter / right.SiemensPerSquareMeter; + } + + #endregion + + #region Equality / IComparable + + /// Returns true if less or equal to. + public static bool operator <=(ElectricConductancePerArea left, ElectricConductancePerArea right) + { + return left.Value <= right.ToUnit(left.Unit).Value; + } + + /// Returns true if greater than or equal to. + public static bool operator >=(ElectricConductancePerArea left, ElectricConductancePerArea right) + { + return left.Value >= right.ToUnit(left.Unit).Value; + } + + /// Returns true if less than. + public static bool operator <(ElectricConductancePerArea left, ElectricConductancePerArea right) + { + return left.Value < right.ToUnit(left.Unit).Value; + } + + /// Returns true if greater than. + public static bool operator >(ElectricConductancePerArea left, ElectricConductancePerArea 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(ElectricConductancePerArea other, ElectricConductancePerArea 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 ==(ElectricConductancePerArea left, ElectricConductancePerArea 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(ElectricConductancePerArea other, ElectricConductancePerArea 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 !=(ElectricConductancePerArea left, ElectricConductancePerArea right) + { + return !(left == right); + } + + /// + /// Indicates strict equality of two quantities, where both and are exactly equal. + [Obsolete("Use Equals(ElectricConductancePerArea other, ElectricConductancePerArea 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 ElectricConductancePerArea otherQuantity)) + return false; + + return Equals(otherQuantity); + } + + /// + /// Indicates strict equality of two quantities, where both and are exactly equal. + [Obsolete("Use Equals(ElectricConductancePerArea other, ElectricConductancePerArea 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(ElectricConductancePerArea 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 ElectricConductancePerArea otherQuantity)) throw new ArgumentException("Expected type ElectricConductancePerArea.", 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(ElectricConductancePerArea other) + { + return _value.CompareTo(other.ToUnit(this.Unit).Value); + } + + /// + /// + /// Compare equality to another ElectricConductancePerArea 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(ElectricConductancePerArea other, ElectricConductancePerArea 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(ElectricConductancePerArea 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 ElectricConductancePerArea otherTyped + && (tolerance is ElectricConductancePerArea toleranceTyped + ? true + : throw new ArgumentException($"Tolerance quantity ({tolerance.QuantityInfo.Name}) did not match the other quantities of type 'ElectricConductancePerArea'.", nameof(tolerance))) + && Equals(otherTyped, toleranceTyped); + } + + /// + public bool Equals(ElectricConductancePerArea other, ElectricConductancePerArea 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 ElectricConductancePerArea. + 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(ElectricConductancePerAreaUnit 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 ElectricConductancePerAreaUnit typedUnit)) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductancePerAreaUnit)} is supported.", nameof(unit)); + + return (double)As(typedUnit); + } + + /// + double IValueQuantity.As(Enum unit) + { + if (!(unit is ElectricConductancePerAreaUnit typedUnit)) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductancePerAreaUnit)} is supported.", nameof(unit)); + + return As(typedUnit); + } + + /// + /// Converts this ElectricConductancePerArea to another ElectricConductancePerArea with the unit representation . + /// + /// The unit to convert to. + /// A ElectricConductancePerArea with the specified unit. + public ElectricConductancePerArea ToUnit(ElectricConductancePerAreaUnit 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 ElectricConductancePerArea with the specified unit. + public ElectricConductancePerArea ToUnit(ElectricConductancePerAreaUnit 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(ElectricConductancePerArea), Unit, typeof(ElectricConductancePerArea), unit), out var conversionFunction)) + { + // See if the unit converter has an extensibility conversion registered. + return (ElectricConductancePerArea)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(ElectricConductancePerAreaUnit unit, [NotNullWhen(true)] out ElectricConductancePerArea? converted) + { + if (Unit == unit) + { + converted = this; + return true; + } + + ElectricConductancePerArea? convertedOrNull = (Unit, unit) switch + { + // ElectricConductancePerAreaUnit -> BaseUnit + (ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea((_value) * 1e-15d, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea((_value) * 1e3d, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea((_value) * 1e6d, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea((_value / 1e-4) * 1e-6d, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea((_value) * 1e-6d, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea((_value / 1e-4) * 1e-3d, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea((_value) * 1e-3d, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea((_value) * 1e-9d, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea((_value) * 1e-12d, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea(_value / 1e-4, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea(_value / 1e-2, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareFoot, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea(_value / 0.092903, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareInch, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea(_value / 0.00064516, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMile, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea(_value / 2.59e6, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea(_value / 1e-6, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareYard, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea(_value / 0.836127, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot, ElectricConductancePerAreaUnit.SiemensPerSquareMeter) => new ElectricConductancePerArea(_value / 0.09290341161, ElectricConductancePerAreaUnit.SiemensPerSquareMeter), + + // BaseUnit -> ElectricConductancePerAreaUnit + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter) => new ElectricConductancePerArea((_value) / 1e-15d, ElectricConductancePerAreaUnit.FemtosiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter) => new ElectricConductancePerArea((_value) / 1e3d, ElectricConductancePerAreaUnit.KilosiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter) => new ElectricConductancePerArea((_value) / 1e6d, ElectricConductancePerAreaUnit.MegasiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter) => new ElectricConductancePerArea((_value * 1e-4) / 1e-6d, ElectricConductancePerAreaUnit.MicrosiemensPerSquareCentimeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter) => new ElectricConductancePerArea((_value) / 1e-6d, ElectricConductancePerAreaUnit.MicrosiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter) => new ElectricConductancePerArea((_value * 1e-4) / 1e-3d, ElectricConductancePerAreaUnit.MillisiemensPerSquareCentimeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter) => new ElectricConductancePerArea((_value) / 1e-3d, ElectricConductancePerAreaUnit.MillisiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter) => new ElectricConductancePerArea((_value) / 1e-9d, ElectricConductancePerAreaUnit.NanosiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter) => new ElectricConductancePerArea((_value) / 1e-12d, ElectricConductancePerAreaUnit.PicosiemensPerSquareMeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter) => new ElectricConductancePerArea(_value * 1e-4, ElectricConductancePerAreaUnit.SiemensPerSquareCentimeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter) => new ElectricConductancePerArea(_value * 1e-2, ElectricConductancePerAreaUnit.SiemensPerSquareDecimeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareFoot) => new ElectricConductancePerArea(_value * 0.092903, ElectricConductancePerAreaUnit.SiemensPerSquareFoot), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareInch) => new ElectricConductancePerArea(_value * 0.00064516, ElectricConductancePerAreaUnit.SiemensPerSquareInch), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMile) => new ElectricConductancePerArea(_value * 2.59e6, ElectricConductancePerAreaUnit.SiemensPerSquareMile), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter) => new ElectricConductancePerArea(_value * 1e-6, ElectricConductancePerAreaUnit.SiemensPerSquareMillimeter), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerSquareYard) => new ElectricConductancePerArea(_value * 0.836127, ElectricConductancePerAreaUnit.SiemensPerSquareYard), + (ElectricConductancePerAreaUnit.SiemensPerSquareMeter, ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot) => new ElectricConductancePerArea(_value * 0.09290341161, ElectricConductancePerAreaUnit.SiemensPerUsSurveySquareFoot), + + _ => null + }; + + if (convertedOrNull is null) + { + converted = default; + return false; + } + + converted = convertedOrNull.Value; + return true; + } + + /// + IQuantity IQuantity.ToUnit(Enum unit) + { + if (!(unit is ElectricConductancePerAreaUnit typedUnit)) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductancePerAreaUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit, DefaultConversionFunctions); + } + + /// + public ElectricConductancePerArea 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(ElectricConductancePerAreaUnit unit) => ToUnit(unit); + + /// + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + + /// + IValueQuantity IValueQuantity.ToUnit(Enum unit) + { + if (unit is not ElectricConductancePerAreaUnit typedUnit) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductancePerAreaUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit); + } + + /// + IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + + #endregion + + #region ToString Methods + + /// + /// Gets the default string representation of value and unit. + /// + /// String representation. + public override string ToString() + { + return ToString("g"); + } + + /// + /// Gets the default string representation of value and unit using the given format provider. + /// + /// String representation. + /// Format to use for localization and number formatting. Defaults to if null. + public string ToString(IFormatProvider? provider) + { + return ToString("g", provider); + } + + /// + /// + /// Gets the string representation of this instance in the specified format string using . + /// + /// The format string. + /// The string representation. + public string ToString(string? format) + { + return ToString(format, CultureInfo.CurrentCulture); + } + + /// + /// + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// + /// The format string. + /// Format to use for localization and number formatting. Defaults to if null. + /// The string representation. + public string ToString(string? format, IFormatProvider? provider) + { + return QuantityFormatter.Format(this, format, provider); + } + + #endregion + + #region IConvertible Methods + + TypeCode IConvertible.GetTypeCode() + { + return TypeCode.Object; + } + + bool IConvertible.ToBoolean(IFormatProvider? provider) + { + throw new InvalidCastException($"Converting {typeof(ElectricConductancePerArea)} to bool is not supported."); + } + + byte IConvertible.ToByte(IFormatProvider? provider) + { + return Convert.ToByte(_value); + } + + char IConvertible.ToChar(IFormatProvider? provider) + { + throw new InvalidCastException($"Converting {typeof(ElectricConductancePerArea)} to char is not supported."); + } + + DateTime IConvertible.ToDateTime(IFormatProvider? provider) + { + throw new InvalidCastException($"Converting {typeof(ElectricConductancePerArea)} to DateTime is not supported."); + } + + decimal IConvertible.ToDecimal(IFormatProvider? provider) + { + return Convert.ToDecimal(_value); + } + + double IConvertible.ToDouble(IFormatProvider? provider) + { + return Convert.ToDouble(_value); + } + + short IConvertible.ToInt16(IFormatProvider? provider) + { + return Convert.ToInt16(_value); + } + + int IConvertible.ToInt32(IFormatProvider? provider) + { + return Convert.ToInt32(_value); + } + + long IConvertible.ToInt64(IFormatProvider? provider) + { + return Convert.ToInt64(_value); + } + + sbyte IConvertible.ToSByte(IFormatProvider? provider) + { + return Convert.ToSByte(_value); + } + + float IConvertible.ToSingle(IFormatProvider? provider) + { + return Convert.ToSingle(_value); + } + + string IConvertible.ToString(IFormatProvider? provider) + { + return ToString("g", provider); + } + + object IConvertible.ToType(Type conversionType, IFormatProvider? provider) + { + if (conversionType == typeof(ElectricConductancePerArea)) + return this; + else if (conversionType == typeof(ElectricConductancePerAreaUnit)) + return Unit; + else if (conversionType == typeof(QuantityInfo)) + return ElectricConductancePerArea.Info; + else if (conversionType == typeof(BaseDimensions)) + return ElectricConductancePerArea.BaseDimensions; + else + throw new InvalidCastException($"Converting {typeof(ElectricConductancePerArea)} 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 9432eb50b6..025124e1fc 100644 --- a/UnitsNet/GeneratedCode/Quantity.g.cs +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -60,6 +60,7 @@ public partial class Quantity { "ElectricCharge", ElectricCharge.Info }, { "ElectricChargeDensity", ElectricChargeDensity.Info }, { "ElectricConductance", ElectricConductance.Info }, + { "ElectricConductancePerArea", ElectricConductancePerArea.Info }, { "ElectricConductivity", ElectricConductivity.Info }, { "ElectricCurrent", ElectricCurrent.Info }, { "ElectricCurrentDensity", ElectricCurrentDensity.Info }, @@ -196,6 +197,7 @@ public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValu "ElectricCharge" => ElectricCharge.From(value, ElectricCharge.BaseUnit), "ElectricChargeDensity" => ElectricChargeDensity.From(value, ElectricChargeDensity.BaseUnit), "ElectricConductance" => ElectricConductance.From(value, ElectricConductance.BaseUnit), + "ElectricConductancePerArea" => ElectricConductancePerArea.From(value, ElectricConductancePerArea.BaseUnit), "ElectricConductivity" => ElectricConductivity.From(value, ElectricConductivity.BaseUnit), "ElectricCurrent" => ElectricCurrent.From(value, ElectricCurrent.BaseUnit), "ElectricCurrentDensity" => ElectricCurrentDensity.From(value, ElectricCurrentDensity.BaseUnit), @@ -335,6 +337,7 @@ public static bool TryFrom(QuantityValue value, Enum? unit, [NotNullWhen(true)] ElectricChargeUnit electricChargeUnit => ElectricCharge.From(value, electricChargeUnit), ElectricChargeDensityUnit electricChargeDensityUnit => ElectricChargeDensity.From(value, electricChargeDensityUnit), ElectricConductanceUnit electricConductanceUnit => ElectricConductance.From(value, electricConductanceUnit), + ElectricConductancePerAreaUnit electricConductancePerAreaUnit => ElectricConductancePerArea.From(value, electricConductancePerAreaUnit), ElectricConductivityUnit electricConductivityUnit => ElectricConductivity.From(value, electricConductivityUnit), ElectricCurrentUnit electricCurrentUnit => ElectricCurrent.From(value, electricCurrentUnit), ElectricCurrentDensityUnit electricCurrentDensityUnit => ElectricCurrentDensity.From(value, electricCurrentDensityUnit), @@ -484,6 +487,7 @@ public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, Type _ when quantityType == typeof(ElectricCharge) => parser.TryParse(quantityString, formatProvider, ElectricCharge.From, out quantity), Type _ when quantityType == typeof(ElectricChargeDensity) => parser.TryParse(quantityString, formatProvider, ElectricChargeDensity.From, out quantity), Type _ when quantityType == typeof(ElectricConductance) => parser.TryParse(quantityString, formatProvider, ElectricConductance.From, out quantity), + Type _ when quantityType == typeof(ElectricConductancePerArea) => parser.TryParse(quantityString, formatProvider, ElectricConductancePerArea.From, out quantity), Type _ when quantityType == typeof(ElectricConductivity) => parser.TryParse(quantityString, formatProvider, ElectricConductivity.From, out quantity), Type _ when quantityType == typeof(ElectricCurrent) => parser.TryParse(quantityString, formatProvider, ElectricCurrent.From, out quantity), Type _ when quantityType == typeof(ElectricCurrentDensity) => parser.TryParse(quantityString, formatProvider, ElectricCurrentDensity.From, out quantity), @@ -614,6 +618,7 @@ internal static IEnumerable GetQuantityTypes() yield return typeof(ElectricCharge); yield return typeof(ElectricChargeDensity); yield return typeof(ElectricConductance); + yield return typeof(ElectricConductancePerArea); yield return typeof(ElectricConductivity); yield return typeof(ElectricCurrent); yield return typeof(ElectricCurrentDensity); diff --git a/UnitsNet/GeneratedCode/Resources/ElectricConductancePerArea.restext b/UnitsNet/GeneratedCode/Resources/ElectricConductancePerArea.restext new file mode 100644 index 0000000000..396860b9fc --- /dev/null +++ b/UnitsNet/GeneratedCode/Resources/ElectricConductancePerArea.restext @@ -0,0 +1,18 @@ +FemtosiemensPerSquareMeter=fS/m² +KilosiemensPerSquareMeter=kS/m² +MegasiemensPerSquareMeter=MS/m² +MicrosiemensPerSquareCentimeters=µS/cm² +MicrosiemensPerSquareMeter=µS/m² +MillisiemensPerSquareCentimeters=mS/cm² +MillisiemensPerSquareMeter=mS/m² +NanosiemensPerSquareMeter=nS/m² +PicosiemensPerSquareMeter=pS/m² +SiemensPerSquareCentimeters=S/cm² +SiemensPerSquareDecimeters=S/dm² +SiemensPerSquareFeet=S/ft² +SiemensPerSquareInches=S/in² +SiemensPerSquareMeter=S/m² +SiemensPerSquareMiles=S/mi² +SiemensPerSquareMillimeters=S/mm² +SiemensPerSquareYards=S/yd² +SiemensPerUsSurveySquareFeet=S/ft² (US) diff --git a/UnitsNet/GeneratedCode/Units/ElectricConductancePerAreaUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricConductancePerAreaUnit.g.cs new file mode 100644 index 0000000000..ac600360de --- /dev/null +++ b/UnitsNet/GeneratedCode/Units/ElectricConductancePerAreaUnit.g.cs @@ -0,0 +1,49 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Units +{ + // Disable missing XML comment warnings for the generated unit enums. + #pragma warning disable 1591 + + public enum ElectricConductancePerAreaUnit + { + FemtosiemensPerSquareMeter = 9, + KilosiemensPerSquareMeter = 5, + MegasiemensPerSquareMeter = 1, + MicrosiemensPerSquareCentimeter = 8, + MicrosiemensPerSquareMeter = 6, + MillisiemensPerSquareCentimeter = 4, + MillisiemensPerSquareMeter = 7, + NanosiemensPerSquareMeter = 2, + PicosiemensPerSquareMeter = 10, + SiemensPerSquareCentimeter = 3, + SiemensPerSquareDecimeter = 14, + SiemensPerSquareFoot = 15, + SiemensPerSquareInch = 19, + SiemensPerSquareMeter = 17, + SiemensPerSquareMile = 12, + SiemensPerSquareMillimeter = 20, + SiemensPerSquareYard = 18, + SiemensPerUsSurveySquareFoot = 16, + } + + #pragma warning restore 1591 +} From 2c5afeb09e00f28ea53de510f203fe8ce511904a Mon Sep 17 00:00:00 2001 From: Burak Can Date: Thu, 20 Jun 2024 13:42:02 -0400 Subject: [PATCH 3/6] Add convenience method for ElectricConductancePerArea quantity to interact w/ ElectricConductance quantity. --- .../ElectricConductancePerAreaTests.cs | 13 +++++++++++- .../ElectricConductancePerArea.extra.cs | 20 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 UnitsNet/CustomCode/Quantities/ElectricConductancePerArea.extra.cs diff --git a/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs b/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs index dbd8b8de45..a8eb8efd93 100644 --- a/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs +++ b/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs @@ -17,7 +17,8 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. -using System; +using UnitsNet.Units; +using Xunit; namespace UnitsNet.Tests.CustomCode { @@ -42,5 +43,15 @@ public class ElectricConductancePerAreaTests : ElectricConductancePerAreaTestsBa protected override double SiemensPerSquareMillimetersInOneSiemensPerSquareMeter => 1E-6; protected override double SiemensPerSquareYardsInOneSiemensPerSquareMeter => 0.836127; protected override double SiemensPerUsSurveySquareFeetInOneSiemensPerSquareMeter => 0.09290341161; + + [Theory] + [InlineData(10.0, 2.5, 4.0)] + [InlineData(0.0, 2.5, 0.0)] + [InlineData(2.5, 0.0, 0.0)] + public void ElectricConductanceByAreaEqualsElectricConductancePerArea(double electricConductance, double area, double expected) + { + ElectricConductancePerArea ecpa = ElectricConductancePerArea.FromElectricConductanceByArea(ElectricConductance.FromSiemens(electricConductance), Area.FromSquareMeters(area)); + Assert.Equal(expected, ecpa.SiemensPerSquareMeter); + } } } diff --git a/UnitsNet/CustomCode/Quantities/ElectricConductancePerArea.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricConductancePerArea.extra.cs new file mode 100644 index 0000000000..ac9054ae3d --- /dev/null +++ b/UnitsNet/CustomCode/Quantities/ElectricConductancePerArea.extra.cs @@ -0,0 +1,20 @@ +// 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.Units; + +namespace UnitsNet +{ + public partial struct ElectricConductancePerArea + { + /// Get from divided by . + public static ElectricConductancePerArea FromElectricConductanceByArea(ElectricConductance ec, Area area) + { + if(area.SquareMeters == 0.0) + return new ElectricConductancePerArea(0.0, ElectricConductancePerAreaUnit.SiemensPerSquareMeter); + + double ecpa = ec.Siemens / area.SquareMeters; + return new ElectricConductancePerArea(ecpa, ElectricConductancePerAreaUnit.SiemensPerSquareMeter); + } + } +} \ No newline at end of file From cb0a61ae8e9afa9ab2dab0594ae2e885e686a703 Mon Sep 17 00:00:00 2001 From: Burak Can Date: Thu, 20 Jun 2024 13:57:31 -0400 Subject: [PATCH 4/6] Add operator * overload for ElectricConductancePerArea to get ElectricConductance quantity. --- .../CustomCode/ElectricConductancePerAreaTests.cs | 10 +++++++++- .../Quantities/ElectricConductancePerArea.extra.cs | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs b/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs index a8eb8efd93..f9e39063dd 100644 --- a/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs +++ b/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs @@ -53,5 +53,13 @@ public void ElectricConductanceByAreaEqualsElectricConductancePerArea(double ele ElectricConductancePerArea ecpa = ElectricConductancePerArea.FromElectricConductanceByArea(ElectricConductance.FromSiemens(electricConductance), Area.FromSquareMeters(area)); Assert.Equal(expected, ecpa.SiemensPerSquareMeter); } + + [Fact] + public void ElectricConductancePerAreaTimesAreaEqualsElectricConductance() + { + ElectricConductance ec = ElectricConductancePerArea.FromSiemensPerSquareMeter(10.0) * + Area.FromSquareMeters(3.0); + Assert.Equal(ElectricConductance.FromSiemens(30.0), ec); + } } -} +} \ No newline at end of file diff --git a/UnitsNet/CustomCode/Quantities/ElectricConductancePerArea.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricConductancePerArea.extra.cs index ac9054ae3d..e57e90c302 100644 --- a/UnitsNet/CustomCode/Quantities/ElectricConductancePerArea.extra.cs +++ b/UnitsNet/CustomCode/Quantities/ElectricConductancePerArea.extra.cs @@ -16,5 +16,11 @@ public static ElectricConductancePerArea FromElectricConductanceByArea(ElectricC double ecpa = ec.Siemens / area.SquareMeters; return new ElectricConductancePerArea(ecpa, ElectricConductancePerAreaUnit.SiemensPerSquareMeter); } + + /// Get from times . + public static ElectricConductance operator *(ElectricConductancePerArea ecpa, Area area) + { + return ElectricConductance.FromSiemens(ecpa.SiemensPerSquareMeter * area.SquareMeters); + } } } \ No newline at end of file From 0c8e9bc026120482b9c395b05d97e5a624a6f0e0 Mon Sep 17 00:00:00 2001 From: Burak Can Date: Thu, 20 Jun 2024 14:12:18 -0400 Subject: [PATCH 5/6] Add operator / overload for ElectricConductance to get ElectricConductancePerArea quantity. --- .../CustomCode/ElectricConductanceTests.cs | 13 ++++++++++--- .../Quantities/ElectricConductance.extra.cs | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 UnitsNet/CustomCode/Quantities/ElectricConductance.extra.cs diff --git a/UnitsNet.Tests/CustomCode/ElectricConductanceTests.cs b/UnitsNet.Tests/CustomCode/ElectricConductanceTests.cs index 1ac770eba4..c284fa052d 100644 --- a/UnitsNet.Tests/CustomCode/ElectricConductanceTests.cs +++ b/UnitsNet.Tests/CustomCode/ElectricConductanceTests.cs @@ -20,8 +20,7 @@ // 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 Xunit; namespace UnitsNet.Tests.CustomCode { @@ -37,5 +36,13 @@ public class ElectricConductanceTests : ElectricConductanceTestsBase protected override double KilosiemensInOneSiemens => 1E-3; protected override double NanosiemensInOneSiemens => 1E9; + + [Fact] + public void ElectricConductanceDividedByAreaEqualsElectricConductancePerArea() + { + ElectricConductancePerArea ecpa = ElectricConductance.FromSiemens(40.0) / + Area.FromSquareMeters(4.0); + Assert.Equal(ElectricConductancePerArea.FromSiemensPerSquareMeter(10.0), ecpa); + } } -} +} \ No newline at end of file diff --git a/UnitsNet/CustomCode/Quantities/ElectricConductance.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricConductance.extra.cs new file mode 100644 index 0000000000..d1f3ce67d1 --- /dev/null +++ b/UnitsNet/CustomCode/Quantities/ElectricConductance.extra.cs @@ -0,0 +1,14 @@ +// 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. + +namespace UnitsNet +{ + public partial struct ElectricConductance + { + /// Get from divided by . + public static ElectricConductancePerArea operator /(ElectricConductance ec, Area area) + { + return ElectricConductancePerArea.FromElectricConductanceByArea(ec, area); + } + } +} \ No newline at end of file From 1e9a3e67631981269d83a081bcab28945bab7cc7 Mon Sep 17 00:00:00 2001 From: Burak Can Date: Thu, 20 Jun 2024 14:16:06 -0400 Subject: [PATCH 6/6] Remove unused using statements. --- UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs b/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs index f9e39063dd..9d7d8e4a8a 100644 --- a/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs +++ b/UnitsNet.Tests/CustomCode/ElectricConductancePerAreaTests.cs @@ -17,7 +17,6 @@ // 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.Units; using Xunit; namespace UnitsNet.Tests.CustomCode