diff --git a/UnitsNet.Tests/CustomCode/ElectricConductivityTests.cs b/UnitsNet.Tests/CustomCode/ElectricConductivityTests.cs
index bbb32fbf10..e737605987 100644
--- a/UnitsNet.Tests/CustomCode/ElectricConductivityTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricConductivityTests.cs
@@ -22,6 +22,8 @@
using System;
+using UnitsNet.Units;
+using Xunit;
namespace UnitsNet.Tests.CustomCode
{
@@ -31,5 +33,19 @@ public class ElectricConductivityTests : ElectricConductivityTestsBase
protected override double SiemensPerMeterInOneSiemensPerMeter => 1;
protected override double SiemensPerInchInOneSiemensPerMeter => 2.54e-2;
protected override double SiemensPerFootInOneSiemensPerMeter => 3.048e-1;
+
+ [Theory]
+ [InlineData( -1.0, -1.0 )]
+ [InlineData( -2.0, -0.5 )]
+ [InlineData( 0.0, 0.0 )]
+ [InlineData( 1.0, 1.0 )]
+ [InlineData( 2.0, 0.5 )]
+ public static void InverseTest( double value, double expected )
+ {
+ var unit = new ElectricConductivity( value, ElectricConductivityUnit.SiemensPerMeter );
+ var inverse = unit.Inverse();
+
+ AssertEx.Equals( expected, inverse.OhmMeters );
+ }
}
}
diff --git a/UnitsNet.Tests/CustomCode/ElectricResistivityTests.cs b/UnitsNet.Tests/CustomCode/ElectricResistivityTests.cs
index 59cca6e1d8..378ec9a82d 100644
--- a/UnitsNet.Tests/CustomCode/ElectricResistivityTests.cs
+++ b/UnitsNet.Tests/CustomCode/ElectricResistivityTests.cs
@@ -22,6 +22,8 @@
using System;
+using UnitsNet.Units;
+using Xunit;
namespace UnitsNet.Tests.CustomCode
{
@@ -55,5 +57,19 @@ public class ElectricResistivityTests : ElectricResistivityTestsBase
protected override double PicoohmsCentimeterInOneOhmMeter => 1e14;
protected override double PicoohmMetersInOneOhmMeter => 1e+12;
+
+ [Theory]
+ [InlineData( -1.0, -1.0 )]
+ [InlineData( -2.0, -0.5 )]
+ [InlineData( 0.0, 0.0 )]
+ [InlineData( 1.0, 1.0 )]
+ [InlineData( 2.0, 0.5 )]
+ public static void InverseTest( double value, double expected )
+ {
+ var unit = new ElectricResistivity( value, ElectricResistivityUnit.OhmMeter );
+ var inverse = unit.Inverse();
+
+ AssertEx.Equals( expected, inverse.SiemensPerMeter );
+ }
}
}
diff --git a/UnitsNet/CustomCode/Quantities/ElectricConductivity.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricConductivity.extra.cs
new file mode 100644
index 0000000000..766f78c677
--- /dev/null
+++ b/UnitsNet/CustomCode/Quantities/ElectricConductivity.extra.cs
@@ -0,0 +1,22 @@
+// 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 ElectricConductivity
+ {
+ ///
+ /// Calculates the inverse or of this unit.
+ ///
+ /// The inverse or of this unit.
+ public ElectricResistivity Inverse()
+ {
+ if( SiemensPerMeter == 0.0 )
+ return new ElectricResistivity( 0.0, ElectricResistivityUnit.OhmMeter );
+
+ return new ElectricResistivity( 1 / SiemensPerMeter, ElectricResistivityUnit.OhmMeter );
+ }
+ }
+}
diff --git a/UnitsNet/CustomCode/Quantities/ElectricResistivity.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricResistivity.extra.cs
new file mode 100644
index 0000000000..a58e80c8a9
--- /dev/null
+++ b/UnitsNet/CustomCode/Quantities/ElectricResistivity.extra.cs
@@ -0,0 +1,22 @@
+// 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 ElectricResistivity
+ {
+ ///
+ /// Calculates the inverse or of this unit.
+ ///
+ /// The inverse or of this unit.
+ public ElectricConductivity Inverse()
+ {
+ if( OhmMeters == 0.0 )
+ return new ElectricConductivity( 0, ElectricConductivityUnit.SiemensPerMeter );
+
+ return new ElectricConductivity( 1 / OhmMeters, ElectricConductivityUnit.SiemensPerMeter );
+ }
+ }
+}