Exemplo n.º 1
0
 private void TestTypedExceptionWithMessage <TExc>() where TExc : Exception
 {
     try
     {
         TurboException.Throw <TExc>("test message");
         Assert.Fail("Should throw exception");
     }
     catch (Exception ex)
     {
         Assert.AreEqual("test message", ex.Message);
         Assert.IsTrue(ex.GetType() == typeof(TExc));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Enters to the protected code section. Throws user exception if termination was requested
 /// </summary>
 /// <typeparam name="TException">The type of exception to throw when attempt was unsuccessful</typeparam>
 /// <returns>Guard primitive to track the protected section scope with 'using' statement</returns>
 public EntryCountingEventGuard Enter<TException>() where TException : Exception
 {
     if (!TryEnterClientCore())
         TurboException.Throw<TException>();
     return new EntryCountingEventGuard(this);
 }
Exemplo n.º 3
0
 public void TestWithNonExceptionType()
 {
     TurboException.Throw(typeof(int), "message");
 }
Exemplo n.º 4
0
 public void TestAssertNotTriggered()
 {
     TurboException.Assert <ArgumentException>(true, "message");
 }