public async Task Should_Only_Aggregate_Exceptions_When_There_Are_Many() { // Given var task = new CakeTask("task"); var context = new CakeContextFixture().CreateContext(); // When task.Actions.Add((c) => throw new NotImplementedException()); task.SetDeferExceptions(true); var result = await Record.ExceptionAsync(() => task.Execute(context)); // Then Assert.IsType <NotImplementedException>(result); }
public async Task Should_Throw_On_First_Failed_Action() { // Given var task = new CakeTask("task"); var context = new CakeContextFixture().CreateContext(); // When task.Actions.Add((c) => throw new NotImplementedException()); task.Actions.Add((c) => throw new NotSupportedException()); task.Actions.Add((c) => throw new OutOfMemoryException()); var result = await Record.ExceptionAsync(() => task.Execute(context)); // Then Assert.IsType <NotImplementedException>(result); }
public async Task Should_Aggregate_Exceptions_From_Actions() { // Given var task = new CakeTask("task"); var context = new CakeContextFixture().CreateContext(); // When task.Actions.Add((c) => throw new NotImplementedException()); task.Actions.Add((c) => throw new NotSupportedException()); task.Actions.Add((c) => throw new OutOfMemoryException()); task.SetDeferExceptions(true); var result = await Record.ExceptionAsync(() => 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)); }