Exemplo n.º 1
0
 public virtual void test_predicate_fail2()
 {
     System.Predicate <string> a = Unchecked.predicate((t) =>
     {
         throw new Exception();
     });
     assertThrows(() => a("A"), typeof(Exception));
 }
Exemplo n.º 2
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Converts checked exceptions to unchecked based on the {@code Predicate} interface.
 /// <para>
 /// This wraps the specified predicate returning an instance that handles checked exceptions.
 /// If a checked exception is thrown it is converted to an <seealso cref="UncheckedIOException"/>
 /// or <seealso cref="RuntimeException"/> as appropriate.
 ///
 /// </para>
 /// </summary>
 /// @param <T>  the type of the predicate </param>
 /// <param name="predicate">  the predicate to be decorated </param>
 /// <returns> the predicate instance that handles checked exceptions </returns>
 public static System.Predicate <T> predicate <T>(CheckedPredicate <T> predicate)
 {
     return((t) =>
     {
         try
         {
             return Unchecked.predicate(t);
         }
         catch (Exception ex)
         {
             throw propagate(ex);
         }
     });
 }
Exemplo n.º 3
0
 //-------------------------------------------------------------------------
 public virtual void test_predicate_success()
 {
     System.Predicate <string> a = Unchecked.predicate((t) => true);
     assertEquals(a("A"), true);
 }