@@ -23,15 +23,7 @@ public void NoArgFunction()
2323Assert . AreEqual ( "noArgs" , nf . Render ( args , factoryImpl ) . ToString ( ) ) ;
2424
2525args . 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 ) ) ;
3527}
3628
3729[ Test ]
@@ -53,15 +45,7 @@ public void CastFunc()
5345IList args = new ArrayList ( ) ;
5446
5547CastFunction 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 ) ) ;
6549
6650args . Add ( "'123'" ) ;
6751args . Add ( "long" ) ;
@@ -72,15 +56,7 @@ public void CastFunc()
7256args . Clear ( ) ;
7357args . Add ( "'123'" ) ;
7458args . 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 ) ) ;
8460}
8561
8662[ Test ]
@@ -156,15 +132,7 @@ public void ClassicSum()
156132args . Clear ( ) ;
157133args . Add ( "va1" ) ;
158134args . 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 ) ) ;
168136}
169137
170138[ Test ]
@@ -185,15 +153,7 @@ public void ClassicCount()
185153args . Clear ( ) ;
186154args . Add ( "va1" ) ;
187155args . 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 ) ) ;
197157}
198158
199159[ Test ]
@@ -218,15 +178,7 @@ public void ClassicAvg()
218178args . Clear ( ) ;
219179args . Add ( "va1" ) ;
220180args . 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 ) ) ;
230182}
231183
232184[ Test ]
@@ -246,27 +198,11 @@ public void ClassicAggregate()
246198args . Clear ( ) ;
247199args . Add ( "va1" ) ;
248200args . 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 ) ) ;
258202
259203args . Clear ( ) ;
260204args . 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 ) ) ;
270206}
271207
272208[ Test ]
@@ -287,29 +223,13 @@ public void AnsiSubstring()
287223Assert . AreEqual ( "substring(var1 from 3 for 4)" , asf . Render ( args , factoryImpl ) . ToString ( ) ) ;
288224
289225args . 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 ) ) ;
299227args . Clear ( ) ;
300228args . Add ( "1" ) ;
301229args . Add ( "2" ) ;
302230args . Add ( "3" ) ;
303231args . 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 ) ) ;
313233}
314234}
315235}
0 commit comments