@@ -72,9 +72,11 @@ public void SquareMeterToAreaUnits()
72
72
public void ThrowsOnIncompatibleUnits ( )
73
73
{
74
74
Assert . Throws < Exception > ( ( ) => UnitConverter . Convert ( 1 , Unit . Meter , Unit . Second ) ) ;
75
+ Assert . Throws < Exception > ( ( ) => UnitConverter . Convert ( 1 , Unit . SquareMeter , Unit . Second ) ) ;
76
+ Assert . Throws < Exception > ( ( ) => UnitConverter . Convert ( 1 , Unit . CubicMeter , Unit . Second ) ) ;
77
+ Assert . Throws < Exception > ( ( ) => UnitConverter . Convert ( 1 , Unit . Newton , Unit . Second ) ) ;
75
78
Assert . Throws < Exception > ( ( ) => UnitConverter . Convert ( 1 , Unit . Pascal , Unit . Second ) ) ;
76
79
Assert . Throws < Exception > ( ( ) => UnitConverter . Convert ( 1 , Unit . Kilogram , Unit . Second ) ) ;
77
- Assert . Throws < Exception > ( ( ) => UnitConverter . Convert ( 1 , Unit . CubicMeter , Unit . Second ) ) ;
78
80
Assert . Throws < Exception > ( ( ) => UnitConverter . Convert ( 1 , Unit . Degree , Unit . Second ) ) ;
79
81
}
80
82
@@ -85,16 +87,20 @@ public void TryConvertReturnsFalseOnIncompatibleUnits()
85
87
86
88
// Assert from-unit cases. One for each class of unit.
87
89
Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Meter , Unit . Second , out newValue ) ) ;
90
+ Assert . False ( UnitConverter . TryConvert ( 1 , Unit . SquareMeter , Unit . Second , out newValue ) ) ;
91
+ Assert . False ( UnitConverter . TryConvert ( 1 , Unit . CubicMeter , Unit . Second , out newValue ) ) ;
92
+ Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Newton , Unit . Second , out newValue ) ) ;
88
93
Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Pascal , Unit . Second , out newValue ) ) ;
89
94
Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Kilogram , Unit . Second , out newValue ) ) ;
90
- Assert . False ( UnitConverter . TryConvert ( 1 , Unit . CubicMeter , Unit . Second , out newValue ) ) ;
91
95
Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Degree , Unit . Second , out newValue ) ) ;
92
96
93
97
// Assert to-unit cases. One for each class of unit.
94
98
Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Second , Unit . Meter , out newValue ) ) ;
99
+ Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Second , Unit . SquareMeter , out newValue ) ) ;
100
+ Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Second , Unit . CubicMeter , out newValue ) ) ;
101
+ Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Second , Unit . Newton , out newValue ) ) ;
95
102
Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Second , Unit . Pascal , out newValue ) ) ;
96
103
Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Second , Unit . Kilogram , out newValue ) ) ;
97
- Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Second , Unit . CubicMeter , out newValue ) ) ;
98
104
Assert . False ( UnitConverter . TryConvert ( 1 , Unit . Second , Unit . Degree , out newValue ) ) ;
99
105
}
100
106
@@ -105,16 +111,20 @@ public void TryConvertReturnsTrueOnCompatibleUnits()
105
111
106
112
// Assert from-unit cases. One for each class of unit.
107
113
Assert . True ( UnitConverter . TryConvert ( 1 , Unit . Meter , Unit . Centimeter , out newValue ) ) ;
114
+ Assert . True ( UnitConverter . TryConvert ( 1 , Unit . SquareMeter , Unit . SquareCentimeter , out newValue ) ) ;
115
+ Assert . True ( UnitConverter . TryConvert ( 1 , Unit . CubicMeter , Unit . Liter , out newValue ) ) ;
116
+ Assert . True ( UnitConverter . TryConvert ( 1 , Unit . Newton , Unit . KilogramForce , out newValue ) ) ;
108
117
Assert . True ( UnitConverter . TryConvert ( 1 , Unit . Pascal , Unit . KiloPascal , out newValue ) ) ;
109
118
Assert . True ( UnitConverter . TryConvert ( 1 , Unit . Kilogram , Unit . Gram , out newValue ) ) ;
110
- Assert . True ( UnitConverter . TryConvert ( 1 , Unit . CubicMeter , Unit . Liter , out newValue ) ) ;
111
119
Assert . True ( UnitConverter . TryConvert ( 1 , Unit . Degree , Unit . Radian , out newValue ) ) ;
112
120
113
121
// Assert to-unit cases. One for each class of unit.
114
122
Assert . True ( UnitConverter . TryConvert ( 1 , Unit . Centimeter , Unit . Meter , out newValue ) ) ;
123
+ Assert . True ( UnitConverter . TryConvert ( 1 , Unit . SquareCentimeter , Unit . SquareMeter , out newValue ) ) ;
124
+ Assert . True ( UnitConverter . TryConvert ( 1 , Unit . Liter , Unit . CubicMeter , out newValue ) ) ;
125
+ Assert . True ( UnitConverter . TryConvert ( 1 , Unit . KilogramForce , Unit . Newton , out newValue ) ) ;
115
126
Assert . True ( UnitConverter . TryConvert ( 1 , Unit . KiloPascal , Unit . Pascal , out newValue ) ) ;
116
127
Assert . True ( UnitConverter . TryConvert ( 1 , Unit . Gram , Unit . Kilogram , out newValue ) ) ;
117
- Assert . True ( UnitConverter . TryConvert ( 1 , Unit . Liter , Unit . CubicMeter , out newValue ) ) ;
118
128
Assert . True ( UnitConverter . TryConvert ( 1 , Unit . Radian , Unit . Degree , out newValue ) ) ;
119
129
}
120
130
}
0 commit comments