@@ -36,28 +36,48 @@ namespace UnitsNet.Tests
36
36
// ReSharper disable once PartialTypeWithSinglePart
37
37
public abstract partial class RotationalSpeedTestsBase
38
38
{
39
- protected abstract double RadiansPerSecondInOneRevolutionPerSecond { get ; }
40
- protected abstract double RevolutionsPerMinuteInOneRevolutionPerSecond { get ; }
41
- protected abstract double RevolutionsPerSecondInOneRevolutionPerSecond { get ; }
39
+ protected abstract double CentiradiansPerSecondInOneRadianPerSecond { get ; }
40
+ protected abstract double DeciradiansPerSecondInOneRadianPerSecond { get ; }
41
+ protected abstract double MicroradiansPerSecondInOneRadianPerSecond { get ; }
42
+ protected abstract double MilliradiansPerSecondInOneRadianPerSecond { get ; }
43
+ protected abstract double NanoradiansPerSecondInOneRadianPerSecond { get ; }
44
+ protected abstract double RadiansPerSecondInOneRadianPerSecond { get ; }
45
+ protected abstract double RevolutionsPerMinuteInOneRadianPerSecond { get ; }
46
+ protected abstract double RevolutionsPerSecondInOneRadianPerSecond { get ; }
42
47
43
48
// ReSharper disable VirtualMemberNeverOverriden.Global
49
+ protected virtual double CentiradiansPerSecondTolerance { get { return 1e-5 ; } }
50
+ protected virtual double DeciradiansPerSecondTolerance { get { return 1e-5 ; } }
51
+ protected virtual double MicroradiansPerSecondTolerance { get { return 1e-5 ; } }
52
+ protected virtual double MilliradiansPerSecondTolerance { get { return 1e-5 ; } }
53
+ protected virtual double NanoradiansPerSecondTolerance { get { return 1e-5 ; } }
44
54
protected virtual double RadiansPerSecondTolerance { get { return 1e-5 ; } }
45
55
protected virtual double RevolutionsPerMinuteTolerance { get { return 1e-5 ; } }
46
56
protected virtual double RevolutionsPerSecondTolerance { get { return 1e-5 ; } }
47
57
// ReSharper restore VirtualMemberNeverOverriden.Global
48
58
49
59
[ Test ]
50
- public void RevolutionPerSecondToRotationalSpeedUnits ( )
60
+ public void RadianPerSecondToRotationalSpeedUnits ( )
51
61
{
52
- RotationalSpeed revolutionpersecond = RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ;
53
- Assert . AreEqual ( RadiansPerSecondInOneRevolutionPerSecond , revolutionpersecond . RadiansPerSecond , RadiansPerSecondTolerance ) ;
54
- Assert . AreEqual ( RevolutionsPerMinuteInOneRevolutionPerSecond , revolutionpersecond . RevolutionsPerMinute , RevolutionsPerMinuteTolerance ) ;
55
- Assert . AreEqual ( RevolutionsPerSecondInOneRevolutionPerSecond , revolutionpersecond . RevolutionsPerSecond , RevolutionsPerSecondTolerance ) ;
62
+ RotationalSpeed radianpersecond = RotationalSpeed . FromRadiansPerSecond ( 1 ) ;
63
+ Assert . AreEqual ( CentiradiansPerSecondInOneRadianPerSecond , radianpersecond . CentiradiansPerSecond , CentiradiansPerSecondTolerance ) ;
64
+ Assert . AreEqual ( DeciradiansPerSecondInOneRadianPerSecond , radianpersecond . DeciradiansPerSecond , DeciradiansPerSecondTolerance ) ;
65
+ Assert . AreEqual ( MicroradiansPerSecondInOneRadianPerSecond , radianpersecond . MicroradiansPerSecond , MicroradiansPerSecondTolerance ) ;
66
+ Assert . AreEqual ( MilliradiansPerSecondInOneRadianPerSecond , radianpersecond . MilliradiansPerSecond , MilliradiansPerSecondTolerance ) ;
67
+ Assert . AreEqual ( NanoradiansPerSecondInOneRadianPerSecond , radianpersecond . NanoradiansPerSecond , NanoradiansPerSecondTolerance ) ;
68
+ Assert . AreEqual ( RadiansPerSecondInOneRadianPerSecond , radianpersecond . RadiansPerSecond , RadiansPerSecondTolerance ) ;
69
+ Assert . AreEqual ( RevolutionsPerMinuteInOneRadianPerSecond , radianpersecond . RevolutionsPerMinute , RevolutionsPerMinuteTolerance ) ;
70
+ Assert . AreEqual ( RevolutionsPerSecondInOneRadianPerSecond , radianpersecond . RevolutionsPerSecond , RevolutionsPerSecondTolerance ) ;
56
71
}
57
72
58
73
[ Test ]
59
74
public void FromValueAndUnit ( )
60
75
{
76
+ Assert . AreEqual ( 1 , RotationalSpeed . From ( 1 , RotationalSpeedUnit . CentiradianPerSecond ) . CentiradiansPerSecond , CentiradiansPerSecondTolerance ) ;
77
+ Assert . AreEqual ( 1 , RotationalSpeed . From ( 1 , RotationalSpeedUnit . DeciradianPerSecond ) . DeciradiansPerSecond , DeciradiansPerSecondTolerance ) ;
78
+ Assert . AreEqual ( 1 , RotationalSpeed . From ( 1 , RotationalSpeedUnit . MicroradianPerSecond ) . MicroradiansPerSecond , MicroradiansPerSecondTolerance ) ;
79
+ Assert . AreEqual ( 1 , RotationalSpeed . From ( 1 , RotationalSpeedUnit . MilliradianPerSecond ) . MilliradiansPerSecond , MilliradiansPerSecondTolerance ) ;
80
+ Assert . AreEqual ( 1 , RotationalSpeed . From ( 1 , RotationalSpeedUnit . NanoradianPerSecond ) . NanoradiansPerSecond , NanoradiansPerSecondTolerance ) ;
61
81
Assert . AreEqual ( 1 , RotationalSpeed . From ( 1 , RotationalSpeedUnit . RadianPerSecond ) . RadiansPerSecond , RadiansPerSecondTolerance ) ;
62
82
Assert . AreEqual ( 1 , RotationalSpeed . From ( 1 , RotationalSpeedUnit . RevolutionPerMinute ) . RevolutionsPerMinute , RevolutionsPerMinuteTolerance ) ;
63
83
Assert . AreEqual ( 1 , RotationalSpeed . From ( 1 , RotationalSpeedUnit . RevolutionPerSecond ) . RevolutionsPerSecond , RevolutionsPerSecondTolerance ) ;
@@ -66,84 +86,94 @@ public void FromValueAndUnit()
66
86
[ Test ]
67
87
public void As ( )
68
88
{
69
- var revolutionpersecond = RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ;
70
- Assert . AreEqual ( RadiansPerSecondInOneRevolutionPerSecond , revolutionpersecond . As ( RotationalSpeedUnit . RadianPerSecond ) , RadiansPerSecondTolerance ) ;
71
- Assert . AreEqual ( RevolutionsPerMinuteInOneRevolutionPerSecond , revolutionpersecond . As ( RotationalSpeedUnit . RevolutionPerMinute ) , RevolutionsPerMinuteTolerance ) ;
72
- Assert . AreEqual ( RevolutionsPerSecondInOneRevolutionPerSecond , revolutionpersecond . As ( RotationalSpeedUnit . RevolutionPerSecond ) , RevolutionsPerSecondTolerance ) ;
89
+ var radianpersecond = RotationalSpeed . FromRadiansPerSecond ( 1 ) ;
90
+ Assert . AreEqual ( CentiradiansPerSecondInOneRadianPerSecond , radianpersecond . As ( RotationalSpeedUnit . CentiradianPerSecond ) , CentiradiansPerSecondTolerance ) ;
91
+ Assert . AreEqual ( DeciradiansPerSecondInOneRadianPerSecond , radianpersecond . As ( RotationalSpeedUnit . DeciradianPerSecond ) , DeciradiansPerSecondTolerance ) ;
92
+ Assert . AreEqual ( MicroradiansPerSecondInOneRadianPerSecond , radianpersecond . As ( RotationalSpeedUnit . MicroradianPerSecond ) , MicroradiansPerSecondTolerance ) ;
93
+ Assert . AreEqual ( MilliradiansPerSecondInOneRadianPerSecond , radianpersecond . As ( RotationalSpeedUnit . MilliradianPerSecond ) , MilliradiansPerSecondTolerance ) ;
94
+ Assert . AreEqual ( NanoradiansPerSecondInOneRadianPerSecond , radianpersecond . As ( RotationalSpeedUnit . NanoradianPerSecond ) , NanoradiansPerSecondTolerance ) ;
95
+ Assert . AreEqual ( RadiansPerSecondInOneRadianPerSecond , radianpersecond . As ( RotationalSpeedUnit . RadianPerSecond ) , RadiansPerSecondTolerance ) ;
96
+ Assert . AreEqual ( RevolutionsPerMinuteInOneRadianPerSecond , radianpersecond . As ( RotationalSpeedUnit . RevolutionPerMinute ) , RevolutionsPerMinuteTolerance ) ;
97
+ Assert . AreEqual ( RevolutionsPerSecondInOneRadianPerSecond , radianpersecond . As ( RotationalSpeedUnit . RevolutionPerSecond ) , RevolutionsPerSecondTolerance ) ;
73
98
}
74
99
75
100
[ Test ]
76
101
public void ConversionRoundTrip ( )
77
102
{
78
- RotationalSpeed revolutionpersecond = RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ;
79
- Assert . AreEqual ( 1 , RotationalSpeed . FromRadiansPerSecond ( revolutionpersecond . RadiansPerSecond ) . RevolutionsPerSecond , RadiansPerSecondTolerance ) ;
80
- Assert . AreEqual ( 1 , RotationalSpeed . FromRevolutionsPerMinute ( revolutionpersecond . RevolutionsPerMinute ) . RevolutionsPerSecond , RevolutionsPerMinuteTolerance ) ;
81
- Assert . AreEqual ( 1 , RotationalSpeed . FromRevolutionsPerSecond ( revolutionpersecond . RevolutionsPerSecond ) . RevolutionsPerSecond , RevolutionsPerSecondTolerance ) ;
103
+ RotationalSpeed radianpersecond = RotationalSpeed . FromRadiansPerSecond ( 1 ) ;
104
+ Assert . AreEqual ( 1 , RotationalSpeed . FromCentiradiansPerSecond ( radianpersecond . CentiradiansPerSecond ) . RadiansPerSecond , CentiradiansPerSecondTolerance ) ;
105
+ Assert . AreEqual ( 1 , RotationalSpeed . FromDeciradiansPerSecond ( radianpersecond . DeciradiansPerSecond ) . RadiansPerSecond , DeciradiansPerSecondTolerance ) ;
106
+ Assert . AreEqual ( 1 , RotationalSpeed . FromMicroradiansPerSecond ( radianpersecond . MicroradiansPerSecond ) . RadiansPerSecond , MicroradiansPerSecondTolerance ) ;
107
+ Assert . AreEqual ( 1 , RotationalSpeed . FromMilliradiansPerSecond ( radianpersecond . MilliradiansPerSecond ) . RadiansPerSecond , MilliradiansPerSecondTolerance ) ;
108
+ Assert . AreEqual ( 1 , RotationalSpeed . FromNanoradiansPerSecond ( radianpersecond . NanoradiansPerSecond ) . RadiansPerSecond , NanoradiansPerSecondTolerance ) ;
109
+ Assert . AreEqual ( 1 , RotationalSpeed . FromRadiansPerSecond ( radianpersecond . RadiansPerSecond ) . RadiansPerSecond , RadiansPerSecondTolerance ) ;
110
+ Assert . AreEqual ( 1 , RotationalSpeed . FromRevolutionsPerMinute ( radianpersecond . RevolutionsPerMinute ) . RadiansPerSecond , RevolutionsPerMinuteTolerance ) ;
111
+ Assert . AreEqual ( 1 , RotationalSpeed . FromRevolutionsPerSecond ( radianpersecond . RevolutionsPerSecond ) . RadiansPerSecond , RevolutionsPerSecondTolerance ) ;
82
112
}
83
113
84
114
[ Test ]
85
115
public void ArithmeticOperators ( )
86
116
{
87
- RotationalSpeed v = RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ;
88
- Assert . AreEqual ( - 1 , - v . RevolutionsPerSecond , RevolutionsPerSecondTolerance ) ;
89
- Assert . AreEqual ( 2 , ( RotationalSpeed . FromRevolutionsPerSecond ( 3 ) - v ) . RevolutionsPerSecond , RevolutionsPerSecondTolerance ) ;
90
- Assert . AreEqual ( 2 , ( v + v ) . RevolutionsPerSecond , RevolutionsPerSecondTolerance ) ;
91
- Assert . AreEqual ( 10 , ( v * 10 ) . RevolutionsPerSecond , RevolutionsPerSecondTolerance ) ;
92
- Assert . AreEqual ( 10 , ( 10 * v ) . RevolutionsPerSecond , RevolutionsPerSecondTolerance ) ;
93
- Assert . AreEqual ( 2 , ( RotationalSpeed . FromRevolutionsPerSecond ( 10 ) / 5 ) . RevolutionsPerSecond , RevolutionsPerSecondTolerance ) ;
94
- Assert . AreEqual ( 2 , RotationalSpeed . FromRevolutionsPerSecond ( 10 ) / RotationalSpeed . FromRevolutionsPerSecond ( 5 ) , RevolutionsPerSecondTolerance ) ;
117
+ RotationalSpeed v = RotationalSpeed . FromRadiansPerSecond ( 1 ) ;
118
+ Assert . AreEqual ( - 1 , - v . RadiansPerSecond , RadiansPerSecondTolerance ) ;
119
+ Assert . AreEqual ( 2 , ( RotationalSpeed . FromRadiansPerSecond ( 3 ) - v ) . RadiansPerSecond , RadiansPerSecondTolerance ) ;
120
+ Assert . AreEqual ( 2 , ( v + v ) . RadiansPerSecond , RadiansPerSecondTolerance ) ;
121
+ Assert . AreEqual ( 10 , ( v * 10 ) . RadiansPerSecond , RadiansPerSecondTolerance ) ;
122
+ Assert . AreEqual ( 10 , ( 10 * v ) . RadiansPerSecond , RadiansPerSecondTolerance ) ;
123
+ Assert . AreEqual ( 2 , ( RotationalSpeed . FromRadiansPerSecond ( 10 ) / 5 ) . RadiansPerSecond , RadiansPerSecondTolerance ) ;
124
+ Assert . AreEqual ( 2 , RotationalSpeed . FromRadiansPerSecond ( 10 ) / RotationalSpeed . FromRadiansPerSecond ( 5 ) , RadiansPerSecondTolerance ) ;
95
125
}
96
126
97
127
[ Test ]
98
128
public void ComparisonOperators ( )
99
129
{
100
- RotationalSpeed oneRevolutionPerSecond = RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ;
101
- RotationalSpeed twoRevolutionsPerSecond = RotationalSpeed . FromRevolutionsPerSecond ( 2 ) ;
102
-
103
- Assert . True ( oneRevolutionPerSecond < twoRevolutionsPerSecond ) ;
104
- Assert . True ( oneRevolutionPerSecond <= twoRevolutionsPerSecond ) ;
105
- Assert . True ( twoRevolutionsPerSecond > oneRevolutionPerSecond ) ;
106
- Assert . True ( twoRevolutionsPerSecond >= oneRevolutionPerSecond ) ;
107
-
108
- Assert . False ( oneRevolutionPerSecond > twoRevolutionsPerSecond ) ;
109
- Assert . False ( oneRevolutionPerSecond >= twoRevolutionsPerSecond ) ;
110
- Assert . False ( twoRevolutionsPerSecond < oneRevolutionPerSecond ) ;
111
- Assert . False ( twoRevolutionsPerSecond <= oneRevolutionPerSecond ) ;
130
+ RotationalSpeed oneRadianPerSecond = RotationalSpeed . FromRadiansPerSecond ( 1 ) ;
131
+ RotationalSpeed twoRadiansPerSecond = RotationalSpeed . FromRadiansPerSecond ( 2 ) ;
132
+
133
+ Assert . True ( oneRadianPerSecond < twoRadiansPerSecond ) ;
134
+ Assert . True ( oneRadianPerSecond <= twoRadiansPerSecond ) ;
135
+ Assert . True ( twoRadiansPerSecond > oneRadianPerSecond ) ;
136
+ Assert . True ( twoRadiansPerSecond >= oneRadianPerSecond ) ;
137
+
138
+ Assert . False ( oneRadianPerSecond > twoRadiansPerSecond ) ;
139
+ Assert . False ( oneRadianPerSecond >= twoRadiansPerSecond ) ;
140
+ Assert . False ( twoRadiansPerSecond < oneRadianPerSecond ) ;
141
+ Assert . False ( twoRadiansPerSecond <= oneRadianPerSecond ) ;
112
142
}
113
143
114
144
[ Test ]
115
145
public void CompareToIsImplemented ( )
116
146
{
117
- RotationalSpeed revolutionpersecond = RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ;
118
- Assert . AreEqual ( 0 , revolutionpersecond . CompareTo ( revolutionpersecond ) ) ;
119
- Assert . Greater ( revolutionpersecond . CompareTo ( RotationalSpeed . Zero ) , 0 ) ;
120
- Assert . Less ( RotationalSpeed . Zero . CompareTo ( revolutionpersecond ) , 0 ) ;
147
+ RotationalSpeed radianpersecond = RotationalSpeed . FromRadiansPerSecond ( 1 ) ;
148
+ Assert . AreEqual ( 0 , radianpersecond . CompareTo ( radianpersecond ) ) ;
149
+ Assert . Greater ( radianpersecond . CompareTo ( RotationalSpeed . Zero ) , 0 ) ;
150
+ Assert . Less ( RotationalSpeed . Zero . CompareTo ( radianpersecond ) , 0 ) ;
121
151
}
122
152
123
153
[ Test ]
124
154
[ ExpectedException ( typeof ( ArgumentException ) ) ]
125
155
public void CompareToThrowsOnTypeMismatch ( )
126
156
{
127
- RotationalSpeed revolutionpersecond = RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ;
157
+ RotationalSpeed radianpersecond = RotationalSpeed . FromRadiansPerSecond ( 1 ) ;
128
158
// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
129
- revolutionpersecond . CompareTo ( new object ( ) ) ;
159
+ radianpersecond . CompareTo ( new object ( ) ) ;
130
160
}
131
161
132
162
[ Test ]
133
163
[ ExpectedException ( typeof ( ArgumentNullException ) ) ]
134
164
public void CompareToThrowsOnNull ( )
135
165
{
136
- RotationalSpeed revolutionpersecond = RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ;
166
+ RotationalSpeed radianpersecond = RotationalSpeed . FromRadiansPerSecond ( 1 ) ;
137
167
// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
138
- revolutionpersecond . CompareTo ( null ) ;
168
+ radianpersecond . CompareTo ( null ) ;
139
169
}
140
170
141
171
142
172
[ Test ]
143
173
public void EqualityOperators ( )
144
174
{
145
- RotationalSpeed a = RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ;
146
- RotationalSpeed b = RotationalSpeed . FromRevolutionsPerSecond ( 2 ) ;
175
+ RotationalSpeed a = RotationalSpeed . FromRadiansPerSecond ( 1 ) ;
176
+ RotationalSpeed b = RotationalSpeed . FromRadiansPerSecond ( 2 ) ;
147
177
148
178
// ReSharper disable EqualExpressionComparison
149
179
Assert . True ( a == a ) ;
@@ -157,23 +187,23 @@ public void EqualityOperators()
157
187
[ Test ]
158
188
public void EqualsIsImplemented ( )
159
189
{
160
- RotationalSpeed v = RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ;
161
- Assert . IsTrue ( v . Equals ( RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ) ) ;
190
+ RotationalSpeed v = RotationalSpeed . FromRadiansPerSecond ( 1 ) ;
191
+ Assert . IsTrue ( v . Equals ( RotationalSpeed . FromRadiansPerSecond ( 1 ) ) ) ;
162
192
Assert . IsFalse ( v . Equals ( RotationalSpeed . Zero ) ) ;
163
193
}
164
194
165
195
[ Test ]
166
196
public void EqualsReturnsFalseOnTypeMismatch ( )
167
197
{
168
- RotationalSpeed revolutionpersecond = RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ;
169
- Assert . IsFalse ( revolutionpersecond . Equals ( new object ( ) ) ) ;
198
+ RotationalSpeed radianpersecond = RotationalSpeed . FromRadiansPerSecond ( 1 ) ;
199
+ Assert . IsFalse ( radianpersecond . Equals ( new object ( ) ) ) ;
170
200
}
171
201
172
202
[ Test ]
173
203
public void EqualsReturnsFalseOnNull ( )
174
204
{
175
- RotationalSpeed revolutionpersecond = RotationalSpeed . FromRevolutionsPerSecond ( 1 ) ;
176
- Assert . IsFalse ( revolutionpersecond . Equals ( null ) ) ;
205
+ RotationalSpeed radianpersecond = RotationalSpeed . FromRadiansPerSecond ( 1 ) ;
206
+ Assert . IsFalse ( radianpersecond . Equals ( null ) ) ;
177
207
}
178
208
}
179
209
}
0 commit comments