public void EventsErrorsExceptionsTest() { var os = new OperationStackBuilder().Build() .Then(op => { throw new Exception(); return(op.Return()); }) .OnErrors(h => { Assert.False(h.Errors.All(e => e.IsHandled)); foreach (var e in h.Errors) { e.Handle(); } }) .OnExceptions(h => { Assert.True(h.ExceptionErrors.All(e => e.Error.IsHandled)); return(h.Return()); }) .Then(op => { var oe = new OperationEvent("Test event"); //op.Throw(oe); }) .OnEvents(h => { Assert.True(h.Events.All(e => e.IsHandled)); return(h.Return()); }) .Then(op => { var oe = new OperationEvent(new Exception()); op.Throw(oe); }) .OnEvents(h => { Assert.True(h.Events.All(e => e.IsHandled)); return(h.Return()); }) .Then(op => { var oe = new OperationEvent("Test event"); oe.Throw(); // Should throw an exception because the OperationEvent is not an error return(op.Return()); }) .OnErrors(h => { Assert.False(h.Errors.All(e => e.IsHandled)); return(h.Return()); }) .OnExceptions(h => { foreach (var e in h.ExceptionErrors) { e.Error.Handle(); } }); var r = os.Execute(); Assert.True(r.Events.All(e => e.IsHandled)); }