@@ -52,36 +52,96 @@ namespace UnitsNet.Tests
52
52
// ReSharper disable once PartialTypeWithSinglePart
53
53
public abstract partial class PowerDensityTestsBase
54
54
{
55
+ protected abstract double DecawattsPerCubicMeterInOneWattPerCubicMeter { get ; }
56
+ protected abstract double DeciwattsPerCubicMeterInOneWattPerCubicMeter { get ; }
57
+ protected abstract double GigawattsPerCubicMeterInOneWattPerCubicMeter { get ; }
58
+ protected abstract double KilowattsPerCubicMeterInOneWattPerCubicMeter { get ; }
59
+ protected abstract double MegawattsPerCubicMeterInOneWattPerCubicMeter { get ; }
60
+ protected abstract double MicrowattsPerCubicMeterInOneWattPerCubicMeter { get ; }
61
+ protected abstract double MilliwattsPerCubicMeterInOneWattPerCubicMeter { get ; }
62
+ protected abstract double NanowattsPerCubicMeterInOneWattPerCubicMeter { get ; }
63
+ protected abstract double PicowattsPerCubicMeterInOneWattPerCubicMeter { get ; }
64
+ protected abstract double TerawattsPerCubicMeterInOneWattPerCubicMeter { get ; }
55
65
protected abstract double WattsPerCubicMeterInOneWattPerCubicMeter { get ; }
56
66
57
67
// ReSharper disable VirtualMemberNeverOverriden.Global
68
+ protected virtual double DecawattsPerCubicMeterTolerance { get { return 1e-5 ; } }
69
+ protected virtual double DeciwattsPerCubicMeterTolerance { get { return 1e-5 ; } }
70
+ protected virtual double GigawattsPerCubicMeterTolerance { get { return 1e-5 ; } }
71
+ protected virtual double KilowattsPerCubicMeterTolerance { get { return 1e-5 ; } }
72
+ protected virtual double MegawattsPerCubicMeterTolerance { get { return 1e-5 ; } }
73
+ protected virtual double MicrowattsPerCubicMeterTolerance { get { return 1e-5 ; } }
74
+ protected virtual double MilliwattsPerCubicMeterTolerance { get { return 1e-5 ; } }
75
+ protected virtual double NanowattsPerCubicMeterTolerance { get { return 1e-5 ; } }
76
+ protected virtual double PicowattsPerCubicMeterTolerance { get { return 1e-5 ; } }
77
+ protected virtual double TerawattsPerCubicMeterTolerance { get { return 1e-5 ; } }
58
78
protected virtual double WattsPerCubicMeterTolerance { get { return 1e-5 ; } }
59
79
// ReSharper restore VirtualMemberNeverOverriden.Global
60
80
61
81
[ Fact ]
62
82
public void WattPerCubicMeterToPowerDensityUnits ( )
63
83
{
64
84
PowerDensity wattpercubicmeter = PowerDensity . FromWattsPerCubicMeter ( 1 ) ;
85
+ AssertEx . EqualTolerance ( DecawattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . DecawattsPerCubicMeter , DecawattsPerCubicMeterTolerance ) ;
86
+ AssertEx . EqualTolerance ( DeciwattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . DeciwattsPerCubicMeter , DeciwattsPerCubicMeterTolerance ) ;
87
+ AssertEx . EqualTolerance ( GigawattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . GigawattsPerCubicMeter , GigawattsPerCubicMeterTolerance ) ;
88
+ AssertEx . EqualTolerance ( KilowattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . KilowattsPerCubicMeter , KilowattsPerCubicMeterTolerance ) ;
89
+ AssertEx . EqualTolerance ( MegawattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . MegawattsPerCubicMeter , MegawattsPerCubicMeterTolerance ) ;
90
+ AssertEx . EqualTolerance ( MicrowattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . MicrowattsPerCubicMeter , MicrowattsPerCubicMeterTolerance ) ;
91
+ AssertEx . EqualTolerance ( MilliwattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . MilliwattsPerCubicMeter , MilliwattsPerCubicMeterTolerance ) ;
92
+ AssertEx . EqualTolerance ( NanowattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . NanowattsPerCubicMeter , NanowattsPerCubicMeterTolerance ) ;
93
+ AssertEx . EqualTolerance ( PicowattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . PicowattsPerCubicMeter , PicowattsPerCubicMeterTolerance ) ;
94
+ AssertEx . EqualTolerance ( TerawattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . TerawattsPerCubicMeter , TerawattsPerCubicMeterTolerance ) ;
65
95
AssertEx . EqualTolerance ( WattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . WattsPerCubicMeter , WattsPerCubicMeterTolerance ) ;
66
96
}
67
97
68
98
[ Fact ]
69
99
public void FromValueAndUnit ( )
70
100
{
101
+ AssertEx . EqualTolerance ( 1 , PowerDensity . From ( 1 , PowerDensityUnit . DecawattPerCubicMeter ) . DecawattsPerCubicMeter , DecawattsPerCubicMeterTolerance ) ;
102
+ AssertEx . EqualTolerance ( 1 , PowerDensity . From ( 1 , PowerDensityUnit . DeciwattPerCubicMeter ) . DeciwattsPerCubicMeter , DeciwattsPerCubicMeterTolerance ) ;
103
+ AssertEx . EqualTolerance ( 1 , PowerDensity . From ( 1 , PowerDensityUnit . GigawattPerCubicMeter ) . GigawattsPerCubicMeter , GigawattsPerCubicMeterTolerance ) ;
104
+ AssertEx . EqualTolerance ( 1 , PowerDensity . From ( 1 , PowerDensityUnit . KilowattPerCubicMeter ) . KilowattsPerCubicMeter , KilowattsPerCubicMeterTolerance ) ;
105
+ AssertEx . EqualTolerance ( 1 , PowerDensity . From ( 1 , PowerDensityUnit . MegawattPerCubicMeter ) . MegawattsPerCubicMeter , MegawattsPerCubicMeterTolerance ) ;
106
+ AssertEx . EqualTolerance ( 1 , PowerDensity . From ( 1 , PowerDensityUnit . MicrowattPerCubicMeter ) . MicrowattsPerCubicMeter , MicrowattsPerCubicMeterTolerance ) ;
107
+ AssertEx . EqualTolerance ( 1 , PowerDensity . From ( 1 , PowerDensityUnit . MilliwattPerCubicMeter ) . MilliwattsPerCubicMeter , MilliwattsPerCubicMeterTolerance ) ;
108
+ AssertEx . EqualTolerance ( 1 , PowerDensity . From ( 1 , PowerDensityUnit . NanowattPerCubicMeter ) . NanowattsPerCubicMeter , NanowattsPerCubicMeterTolerance ) ;
109
+ AssertEx . EqualTolerance ( 1 , PowerDensity . From ( 1 , PowerDensityUnit . PicowattPerCubicMeter ) . PicowattsPerCubicMeter , PicowattsPerCubicMeterTolerance ) ;
110
+ AssertEx . EqualTolerance ( 1 , PowerDensity . From ( 1 , PowerDensityUnit . TerawattPerCubicMeter ) . TerawattsPerCubicMeter , TerawattsPerCubicMeterTolerance ) ;
71
111
AssertEx . EqualTolerance ( 1 , PowerDensity . From ( 1 , PowerDensityUnit . WattPerCubicMeter ) . WattsPerCubicMeter , WattsPerCubicMeterTolerance ) ;
72
112
}
73
113
74
114
[ Fact ]
75
115
public void As ( )
76
116
{
77
117
var wattpercubicmeter = PowerDensity . FromWattsPerCubicMeter ( 1 ) ;
118
+ AssertEx . EqualTolerance ( DecawattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . As ( PowerDensityUnit . DecawattPerCubicMeter ) , DecawattsPerCubicMeterTolerance ) ;
119
+ AssertEx . EqualTolerance ( DeciwattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . As ( PowerDensityUnit . DeciwattPerCubicMeter ) , DeciwattsPerCubicMeterTolerance ) ;
120
+ AssertEx . EqualTolerance ( GigawattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . As ( PowerDensityUnit . GigawattPerCubicMeter ) , GigawattsPerCubicMeterTolerance ) ;
121
+ AssertEx . EqualTolerance ( KilowattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . As ( PowerDensityUnit . KilowattPerCubicMeter ) , KilowattsPerCubicMeterTolerance ) ;
122
+ AssertEx . EqualTolerance ( MegawattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . As ( PowerDensityUnit . MegawattPerCubicMeter ) , MegawattsPerCubicMeterTolerance ) ;
123
+ AssertEx . EqualTolerance ( MicrowattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . As ( PowerDensityUnit . MicrowattPerCubicMeter ) , MicrowattsPerCubicMeterTolerance ) ;
124
+ AssertEx . EqualTolerance ( MilliwattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . As ( PowerDensityUnit . MilliwattPerCubicMeter ) , MilliwattsPerCubicMeterTolerance ) ;
125
+ AssertEx . EqualTolerance ( NanowattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . As ( PowerDensityUnit . NanowattPerCubicMeter ) , NanowattsPerCubicMeterTolerance ) ;
126
+ AssertEx . EqualTolerance ( PicowattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . As ( PowerDensityUnit . PicowattPerCubicMeter ) , PicowattsPerCubicMeterTolerance ) ;
127
+ AssertEx . EqualTolerance ( TerawattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . As ( PowerDensityUnit . TerawattPerCubicMeter ) , TerawattsPerCubicMeterTolerance ) ;
78
128
AssertEx . EqualTolerance ( WattsPerCubicMeterInOneWattPerCubicMeter , wattpercubicmeter . As ( PowerDensityUnit . WattPerCubicMeter ) , WattsPerCubicMeterTolerance ) ;
79
129
}
80
130
81
131
[ Fact ]
82
132
public void ConversionRoundTrip ( )
83
133
{
84
134
PowerDensity wattpercubicmeter = PowerDensity . FromWattsPerCubicMeter ( 1 ) ;
135
+ AssertEx . EqualTolerance ( 1 , PowerDensity . FromDecawattsPerCubicMeter ( wattpercubicmeter . DecawattsPerCubicMeter ) . WattsPerCubicMeter , DecawattsPerCubicMeterTolerance ) ;
136
+ AssertEx . EqualTolerance ( 1 , PowerDensity . FromDeciwattsPerCubicMeter ( wattpercubicmeter . DeciwattsPerCubicMeter ) . WattsPerCubicMeter , DeciwattsPerCubicMeterTolerance ) ;
137
+ AssertEx . EqualTolerance ( 1 , PowerDensity . FromGigawattsPerCubicMeter ( wattpercubicmeter . GigawattsPerCubicMeter ) . WattsPerCubicMeter , GigawattsPerCubicMeterTolerance ) ;
138
+ AssertEx . EqualTolerance ( 1 , PowerDensity . FromKilowattsPerCubicMeter ( wattpercubicmeter . KilowattsPerCubicMeter ) . WattsPerCubicMeter , KilowattsPerCubicMeterTolerance ) ;
139
+ AssertEx . EqualTolerance ( 1 , PowerDensity . FromMegawattsPerCubicMeter ( wattpercubicmeter . MegawattsPerCubicMeter ) . WattsPerCubicMeter , MegawattsPerCubicMeterTolerance ) ;
140
+ AssertEx . EqualTolerance ( 1 , PowerDensity . FromMicrowattsPerCubicMeter ( wattpercubicmeter . MicrowattsPerCubicMeter ) . WattsPerCubicMeter , MicrowattsPerCubicMeterTolerance ) ;
141
+ AssertEx . EqualTolerance ( 1 , PowerDensity . FromMilliwattsPerCubicMeter ( wattpercubicmeter . MilliwattsPerCubicMeter ) . WattsPerCubicMeter , MilliwattsPerCubicMeterTolerance ) ;
142
+ AssertEx . EqualTolerance ( 1 , PowerDensity . FromNanowattsPerCubicMeter ( wattpercubicmeter . NanowattsPerCubicMeter ) . WattsPerCubicMeter , NanowattsPerCubicMeterTolerance ) ;
143
+ AssertEx . EqualTolerance ( 1 , PowerDensity . FromPicowattsPerCubicMeter ( wattpercubicmeter . PicowattsPerCubicMeter ) . WattsPerCubicMeter , PicowattsPerCubicMeterTolerance ) ;
144
+ AssertEx . EqualTolerance ( 1 , PowerDensity . FromTerawattsPerCubicMeter ( wattpercubicmeter . TerawattsPerCubicMeter ) . WattsPerCubicMeter , TerawattsPerCubicMeterTolerance ) ;
85
145
AssertEx . EqualTolerance ( 1 , PowerDensity . FromWattsPerCubicMeter ( wattpercubicmeter . WattsPerCubicMeter ) . WattsPerCubicMeter , WattsPerCubicMeterTolerance ) ;
86
146
}
87
147
0 commit comments