public void Rethrow() { IExceptionHandler handler = new ExceptionHandlerBuilder() .Handler(new ReThrowExceptionHandler()); string message1 = null; string message2 = null; try { try { Level1(); } catch (Exception e1) { message1 = e1.ToString(); Assert.IsTrue(message1.Contains("Level3")); handler.Handle(e1); } } catch (Exception e2) { message2 = e2.ToString(); Assert.IsTrue(message1.Contains("Level3")); Assert.IsTrue(message2.StartsWith(message1)); } }
public void Builder() { ContextExceptionHandler <Exception> handler1 = new ContextExceptionHandler <Exception>(false); ContextExceptionHandler <Exception> handler2 = new ContextExceptionHandler <Exception>(true); ContextExceptionHandler <Exception> handler3 = new ContextExceptionHandler <Exception>(false); IExceptionHandler handler = new ExceptionHandlerBuilder() .Handler(handler1) .Handler(handler2) .Handler(handler3); handler.Handle(new Exception()); Assert.AreEqual(1, handler1.Count); Assert.AreEqual(1, handler2.Count); Assert.AreEqual(0, handler3.Count); }