@@ -286,35 +286,17 @@ public void Test_ConnectionInfo_Timeout_Valid()
286286 Resources . HOST , int . Parse ( Resources . PORT ) , Resources . USERNAME ,
287287 Resources . PASSWORD , new KeyboardInteractiveAuthenticationMethod ( Resources . USERNAME ) ) ;
288288
289- try
290- {
291- connectionInfo . Timeout = TimeSpan . FromMilliseconds ( - 2 ) ;
292- }
293- catch ( ArgumentOutOfRangeException ex )
294- {
295- Assert . IsNull ( ex . InnerException ) ;
296- ArgumentExceptionAssert . MessageEquals ( "The timeout must represent a value between -1 and Int32.MaxValue milliseconds, inclusive." , ex ) ;
289+ var ex = Assert . Throws < ArgumentOutOfRangeException > ( ( ) => connectionInfo . Timeout = TimeSpan . FromMilliseconds ( - 2 ) ) ;
290+ Assert . AreEqual ( "Timeout" , ex . ParamName ) ;
297291
298- Assert . AreEqual ( " Timeout" , ex . ParamName ) ;
299- }
292+ ex = Assert . Throws < ArgumentOutOfRangeException > ( ( ) => connectionInfo . Timeout = TimeSpan . FromMilliseconds ( ( double ) int . MaxValue + 1 ) ) ;
293+ Assert . AreEqual ( "Timeout" , ex . ParamName ) ;
300294
301295 connectionInfo . Timeout = TimeSpan . FromMilliseconds ( - 1 ) ;
302296 Assert . AreEqual ( connectionInfo . Timeout , TimeSpan . FromMilliseconds ( - 1 ) ) ;
303297
304298 connectionInfo . Timeout = TimeSpan . FromMilliseconds ( int . MaxValue ) ;
305299 Assert . AreEqual ( connectionInfo . Timeout , TimeSpan . FromMilliseconds ( int . MaxValue ) ) ;
306-
307- try
308- {
309- connectionInfo . Timeout = TimeSpan . FromMilliseconds ( ( double ) int . MaxValue + 1 ) ;
310- }
311- catch ( ArgumentOutOfRangeException ex )
312- {
313- Assert . IsNull ( ex . InnerException ) ;
314- ArgumentExceptionAssert . MessageEquals ( "The timeout must represent a value between -1 and Int32.MaxValue milliseconds, inclusive." , ex ) ;
315-
316- Assert . AreEqual ( "Timeout" , ex . ParamName ) ;
317- }
318300 }
319301
320302 [ TestMethod ]
@@ -325,35 +307,17 @@ public void Test_ConnectionInfo_ChannelCloseTimeout_Valid()
325307 Resources . HOST , int . Parse ( Resources . PORT ) , Resources . USERNAME ,
326308 Resources . PASSWORD , new KeyboardInteractiveAuthenticationMethod ( Resources . USERNAME ) ) ;
327309
328- try
329- {
330- connectionInfo . ChannelCloseTimeout = TimeSpan . FromMilliseconds ( - 2 ) ;
331- }
332- catch ( ArgumentOutOfRangeException ex )
333- {
334- Assert . IsNull ( ex . InnerException ) ;
335- ArgumentExceptionAssert . MessageEquals ( "The timeout must represent a value between -1 and Int32.MaxValue milliseconds, inclusive." , ex ) ;
310+ var ex = Assert . Throws < ArgumentOutOfRangeException > ( ( ) => connectionInfo . ChannelCloseTimeout = TimeSpan . FromMilliseconds ( - 2 ) ) ;
311+ Assert . AreEqual ( "ChannelCloseTimeout" , ex . ParamName ) ;
336312
337- Assert . AreEqual ( " ChannelCloseTimeout" , ex . ParamName ) ;
338- }
313+ ex = Assert . Throws < ArgumentOutOfRangeException > ( ( ) => connectionInfo . ChannelCloseTimeout = TimeSpan . FromMilliseconds ( ( double ) int . MaxValue + 1 ) ) ;
314+ Assert . AreEqual ( "ChannelCloseTimeout" , ex . ParamName ) ;
339315
340316 connectionInfo . ChannelCloseTimeout = TimeSpan . FromMilliseconds ( - 1 ) ;
341317 Assert . AreEqual ( connectionInfo . ChannelCloseTimeout , TimeSpan . FromMilliseconds ( - 1 ) ) ;
342318
343319 connectionInfo . ChannelCloseTimeout = TimeSpan . FromMilliseconds ( int . MaxValue ) ;
344320 Assert . AreEqual ( connectionInfo . ChannelCloseTimeout , TimeSpan . FromMilliseconds ( int . MaxValue ) ) ;
345-
346- try
347- {
348- connectionInfo . ChannelCloseTimeout = TimeSpan . FromMilliseconds ( ( double ) int . MaxValue + 1 ) ;
349- }
350- catch ( ArgumentOutOfRangeException ex )
351- {
352- Assert . IsNull ( ex . InnerException ) ;
353- ArgumentExceptionAssert . MessageEquals ( "The timeout must represent a value between -1 and Int32.MaxValue milliseconds, inclusive." , ex ) ;
354-
355- Assert . AreEqual ( "ChannelCloseTimeout" , ex . ParamName ) ;
356- }
357321 }
358322
359323 [ TestMethod ]
0 commit comments