public void Should_Only_Aggregate_Exceptions_When_There_Are_Many() { // Given var task = new ActionTask("task"); var builder = new CakeTaskBuilder <ActionTask>(task); var context = new CakeContextFixture().CreateContext(); // When builder.Does(() => throw new NotImplementedException()); builder.DeferOnError(); var result = Record.Exception(() => builder.Task.Execute(context)); // Then Assert.IsType <NotImplementedException>(result); }
public void Should_Aggregate_Exceptions_From_Actions() { // Given var task = new ActionTask("task"); var builder = new CakeTaskBuilder <ActionTask>(task); var context = new CakeContextFixture().CreateContext(); // When builder.Does(() => throw new NotImplementedException()); builder.Does(() => throw new NotSupportedException()); builder.Does(() => throw new OutOfMemoryException()); builder.DeferOnError(); var result = Record.Exception(() => builder.Task.Execute(context)); // Then Assert.IsType <AggregateException>(result); var ex = result as AggregateException; Assert.Contains(ex.InnerExceptions, x => x.GetType() == typeof(NotImplementedException)); Assert.Contains(ex.InnerExceptions, x => x.GetType() == typeof(NotSupportedException)); Assert.Contains(ex.InnerExceptions, x => x.GetType() == typeof(OutOfMemoryException)); }