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)); } }
/// <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); }
public void TestWithNonExceptionType() { TurboException.Throw(typeof(int), "message"); }
public void TestAssertNotTriggered() { TurboException.Assert <ArgumentException>(true, "message"); }