Example #1
0
            public void Should_Only_Aggregate_Exceptions_When_There_Are_Many()
            {
                // Given
                var task    = new ActionTask("task");
                var context = new CakeContextFixture().CreateContext();

                // When
                task.Actions.Add((c) => throw new NotImplementedException());
                task.SetDeferExceptions(true);
                var result = Record.Exception(() => task.Execute(context));

                // Then
                Assert.IsType <NotImplementedException>(result);
            }
Example #2
0
            public void Should_Aggregate_Exceptions_From_Actions()
            {
                // Given
                var task    = new ActionTask("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 = Record.Exception(() => 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));
            }