File tree Expand file tree Collapse file tree 4 files changed +76
-0
lines changed
UnitsNet.Tests/CustomCode
UnitsNet/CustomCode/Quantities Expand file tree Collapse file tree 4 files changed +76
-0
lines changed Original file line number Diff line number Diff line change 22
22
23
23
24
24
using System ;
25
+ using UnitsNet . Units ;
26
+ using Xunit ;
25
27
26
28
namespace UnitsNet . Tests . CustomCode
27
29
{
@@ -31,5 +33,19 @@ public class ElectricConductivityTests : ElectricConductivityTestsBase
31
33
protected override double SiemensPerMeterInOneSiemensPerMeter => 1 ;
32
34
protected override double SiemensPerInchInOneSiemensPerMeter => 2.54e-2 ;
33
35
protected override double SiemensPerFootInOneSiemensPerMeter => 3.048e-1 ;
36
+
37
+ [ Theory ]
38
+ [ InlineData ( - 1.0 , - 1.0 ) ]
39
+ [ InlineData ( - 2.0 , - 0.5 ) ]
40
+ [ InlineData ( 0.0 , 0.0 ) ]
41
+ [ InlineData ( 1.0 , 1.0 ) ]
42
+ [ InlineData ( 2.0 , 0.5 ) ]
43
+ public static void InverseTest ( double value , double expected )
44
+ {
45
+ var unit = new ElectricConductivity ( value , ElectricConductivityUnit . SiemensPerMeter ) ;
46
+ var inverse = unit . Inverse ( ) ;
47
+
48
+ AssertEx . Equals ( expected , inverse . OhmMeters ) ;
49
+ }
34
50
}
35
51
}
Original file line number Diff line number Diff line change 22
22
23
23
24
24
using System ;
25
+ using UnitsNet . Units ;
26
+ using Xunit ;
25
27
26
28
namespace UnitsNet . Tests . CustomCode
27
29
{
@@ -55,5 +57,19 @@ public class ElectricResistivityTests : ElectricResistivityTestsBase
55
57
protected override double PicoohmsCentimeterInOneOhmMeter => 1e14 ;
56
58
57
59
protected override double PicoohmMetersInOneOhmMeter => 1e+12 ;
60
+
61
+ [ Theory ]
62
+ [ InlineData ( - 1.0 , - 1.0 ) ]
63
+ [ InlineData ( - 2.0 , - 0.5 ) ]
64
+ [ InlineData ( 0.0 , 0.0 ) ]
65
+ [ InlineData ( 1.0 , 1.0 ) ]
66
+ [ InlineData ( 2.0 , 0.5 ) ]
67
+ public static void InverseTest ( double value , double expected )
68
+ {
69
+ var unit = new ElectricResistivity ( value , ElectricResistivityUnit . OhmMeter ) ;
70
+ var inverse = unit . Inverse ( ) ;
71
+
72
+ AssertEx . Equals ( expected , inverse . SiemensPerMeter ) ;
73
+ }
58
74
}
59
75
}
Original file line number Diff line number Diff line change
1
+ // Licensed under MIT No Attribution, see LICENSE file at the root.
2
+ // Copyright 2013 Andreas Gullberg Larsen ([email protected] ). Maintained at https://github.com/angularsen/UnitsNet.
3
+
4
+ using UnitsNet . Units ;
5
+
6
+ namespace UnitsNet
7
+ {
8
+ public partial struct ElectricConductivity
9
+ {
10
+ /// <summary>
11
+ /// Calculates the inverse or <see cref="ElectricResistivity"/> of this unit.
12
+ /// </summary>
13
+ /// <returns>The inverse or <see cref="ElectricResistivity"/> of this unit.</returns>
14
+ public ElectricResistivity Inverse ( )
15
+ {
16
+ if ( SiemensPerMeter == 0.0 )
17
+ return new ElectricResistivity ( 0.0 , ElectricResistivityUnit . OhmMeter ) ;
18
+
19
+ return new ElectricResistivity ( 1 / SiemensPerMeter , ElectricResistivityUnit . OhmMeter ) ;
20
+ }
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ // Licensed under MIT No Attribution, see LICENSE file at the root.
2
+ // Copyright 2013 Andreas Gullberg Larsen ([email protected] ). Maintained at https://github.com/angularsen/UnitsNet.
3
+
4
+ using UnitsNet . Units ;
5
+
6
+ namespace UnitsNet
7
+ {
8
+ public partial struct ElectricResistivity
9
+ {
10
+ /// <summary>
11
+ /// Calculates the inverse or <see cref="ElectricConductivity"/> of this unit.
12
+ /// </summary>
13
+ /// <returns>The inverse or <see cref="ElectricConductivity"/> of this unit.</returns>
14
+ public ElectricConductivity Inverse ( )
15
+ {
16
+ if ( OhmMeters == 0.0 )
17
+ return new ElectricConductivity ( 0 , ElectricConductivityUnit . SiemensPerMeter ) ;
18
+
19
+ return new ElectricConductivity ( 1 / OhmMeters , ElectricConductivityUnit . SiemensPerMeter ) ;
20
+ }
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments