Example #1
0
 public virtual void Execute(ThrowingRunnable throwingRunnable)
 {
     try
     {
         throwingRunnable.Run();
     }
     catch (Exception e)
     {
         _throwables.Add(e);
     }
 }
Example #2
0
 private static void AssertThrows(Type exceptionClass, Matcher <string> message, ThrowingRunnable action)
 {
     try
     {
         action.Run();
         fail("Should have failed");
     }
     catch (Exception e)
     {
         assertTrue(exceptionClass.IsInstanceOfType(e));
         assertThat(e.Message, message);
     }
 }
 private Thread CreateActionThread(ThrowingRunnable action)
 {
     return(new Thread(() =>
     {
         try
         {
             action.Run();
         }
         catch (IOException e)
         {
             throw new Exception(e);
         }
     }));
 }
Example #4
0
 /// <summary>
 /// Convenience for wrapping contestants, especially for lambdas, which throws any sort of
 /// checked exception.
 /// </summary>
 /// <param name="runnable"> actual contestant. </param>
 /// <returns> contestant wrapped in a try-catch (and re-throw as unchecked exception). </returns>
 public static ThreadStart Throwing(ThrowingRunnable runnable)
 {
     return(() =>
     {
         try
         {
             runnable.Run();
         }
         catch (Exception e)
         {
             throw new Exception(e);
         }
     });
 }