@@ -23,15 +23,7 @@ public void NoArgFunction()
23
23
Assert . AreEqual ( "noArgs" , nf . Render ( args , factoryImpl ) . ToString ( ) ) ;
24
24
25
25
args . Add ( "aparam" ) ;
26
- try
27
- {
28
- SqlString t = nf . Render ( args , factoryImpl ) ;
29
- Assert . Fail ( "No exception if has argument" ) ;
30
- }
31
- catch ( QueryException )
32
- {
33
- //correct
34
- }
26
+ Assert . Throws < QueryException > ( ( ) => nf . Render ( args , factoryImpl ) ) ;
35
27
}
36
28
37
29
[ Test ]
@@ -53,15 +45,7 @@ public void CastFunc()
53
45
IList args = new ArrayList ( ) ;
54
46
55
47
CastFunction cf = new CastFunction ( ) ;
56
- try
57
- {
58
- SqlString t = cf . Render ( args , factoryImpl ) ;
59
- Assert . Fail ( "No exception if no argument" ) ;
60
- }
61
- catch ( QueryException )
62
- {
63
- //correct
64
- }
48
+ Assert . Throws < QueryException > ( ( ) => cf . Render ( args , factoryImpl ) ) ;
65
49
66
50
args . Add ( "'123'" ) ;
67
51
args . Add ( "long" ) ;
@@ -72,15 +56,7 @@ public void CastFunc()
72
56
args . Clear ( ) ;
73
57
args . Add ( "'123'" ) ;
74
58
args . Add ( "NO_TYPE" ) ;
75
- try
76
- {
77
- SqlString t = cf . Render ( args , factoryImpl ) ;
78
- Assert . Fail ( "Ivalid type accepted" ) ;
79
- }
80
- catch ( QueryException )
81
- {
82
- //correct
83
- }
59
+ Assert . Throws < QueryException > ( ( ) => cf . Render ( args , factoryImpl ) ) ;
84
60
}
85
61
86
62
[ Test ]
@@ -156,15 +132,7 @@ public void ClassicSum()
156
132
args . Clear ( ) ;
157
133
args . Add ( "va1" ) ;
158
134
args . Add ( "va2" ) ;
159
- try
160
- {
161
- SqlString t = csf . Render ( args , factoryImpl ) ;
162
- Assert . Fail ( "No exception 2 argument without <setquantifier>:" + t ) ;
163
- }
164
- catch ( QueryException )
165
- {
166
- //correct
167
- }
135
+ Assert . Throws < QueryException > ( ( ) => csf . Render ( args , factoryImpl ) ) ;
168
136
}
169
137
170
138
[ Test ]
@@ -185,15 +153,7 @@ public void ClassicCount()
185
153
args . Clear ( ) ;
186
154
args . Add ( "va1" ) ;
187
155
args . Add ( "va2" ) ;
188
- try
189
- {
190
- SqlString t = ccf . Render ( args , factoryImpl ) ;
191
- Assert . Fail ( "No exception 2 argument without <setquantifier>:" + t ) ;
192
- }
193
- catch ( QueryException )
194
- {
195
- //correct
196
- }
156
+ Assert . Throws < QueryException > ( ( ) => ccf . Render ( args , factoryImpl ) ) ;
197
157
}
198
158
199
159
[ Test ]
@@ -218,15 +178,7 @@ public void ClassicAvg()
218
178
args . Clear ( ) ;
219
179
args . Add ( "va1" ) ;
220
180
args . Add ( "va2" ) ;
221
- try
222
- {
223
- SqlString t = caf . Render ( args , factoryImpl ) ;
224
- Assert . Fail ( "No exception 2 argument without <setquantifier>:" + t ) ;
225
- }
226
- catch ( QueryException )
227
- {
228
- //correct
229
- }
181
+ Assert . Throws < QueryException > ( ( ) => caf . Render ( args , factoryImpl ) ) ;
230
182
}
231
183
232
184
[ Test ]
@@ -246,27 +198,11 @@ public void ClassicAggregate()
246
198
args . Clear ( ) ;
247
199
args . Add ( "va1" ) ;
248
200
args . Add ( "va2" ) ;
249
- try
250
- {
251
- SqlString t = caf . Render ( args , factoryImpl ) ;
252
- Assert . Fail ( "No exception 2 argument without <setquantifier>:" + t ) ;
253
- }
254
- catch ( QueryException )
255
- {
256
- //correct
257
- }
201
+ Assert . Throws < QueryException > ( ( ) => caf . Render ( args , factoryImpl ) ) ;
258
202
259
203
args . Clear ( ) ;
260
204
args . Add ( "*" ) ;
261
- try
262
- {
263
- SqlString t = caf . Render ( args , factoryImpl ) ;
264
- Assert . Fail ( "No exception '*' :" + t ) ;
265
- }
266
- catch ( QueryException )
267
- {
268
- //correct
269
- }
205
+ Assert . Throws < QueryException > ( ( ) => caf . Render ( args , factoryImpl ) ) ;
270
206
}
271
207
272
208
[ Test ]
@@ -287,29 +223,13 @@ public void AnsiSubstring()
287
223
Assert . AreEqual ( "substring(var1 from 3 for 4)" , asf . Render ( args , factoryImpl ) . ToString ( ) ) ;
288
224
289
225
args . Clear ( ) ;
290
- try
291
- {
292
- SqlString t = asf . Render ( args , factoryImpl ) ;
293
- Assert . Fail ( "Not threw 'Not enough parameters' exception:" + t ) ;
294
- }
295
- catch ( QueryException )
296
- {
297
- //correct
298
- }
226
+ Assert . Throws < QueryException > ( ( ) => asf . Render ( args , factoryImpl ) ) ;
299
227
args . Clear ( ) ;
300
228
args . Add ( "1" ) ;
301
229
args . Add ( "2" ) ;
302
230
args . Add ( "3" ) ;
303
231
args . Add ( "4" ) ;
304
- try
305
- {
306
- SqlString t = asf . Render ( args , factoryImpl ) ;
307
- Assert . Fail ( "Not threw 'Not enough parameters' exception:" + t ) ;
308
- }
309
- catch ( QueryException )
310
- {
311
- //correct
312
- }
232
+ Assert . Throws < QueryException > ( ( ) => asf . Render ( args , factoryImpl ) ) ;
313
233
}
314
234
}
315
235
}
0 commit comments