public void AggregateShouldAggregateExceptionsCorrectly() { var aggregator = new ParallelRunDataAggregator(); aggregator.Aggregate(null, null, exception: null, elapsedTime: TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, runCompleteArgsAttachments: null); Assert.IsNull(aggregator.GetAggregatedException(), "Aggregated exception must be null"); var exception1 = new NotImplementedException(); aggregator.Aggregate(null, null, exception: exception1, elapsedTime: TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, runCompleteArgsAttachments: null); var aggregatedException = aggregator.GetAggregatedException() as AggregateException; Assert.IsNotNull(aggregatedException, "Aggregated exception must NOT be null"); Assert.IsNotNull(aggregatedException.InnerExceptions, "Inner exception list must NOT be null"); Assert.AreEqual(aggregatedException.InnerExceptions.Count, 1, "Inner exception lsit must have one element"); Assert.AreEqual(aggregatedException.InnerExceptions[0], exception1, "Inner exception must be the one set."); var exception2 = new NotSupportedException(); aggregator.Aggregate(null, null, exception: exception2, elapsedTime: TimeSpan.Zero, isAborted: false, isCanceled: false, runContextAttachments: null, runCompleteArgsAttachments: null); aggregatedException = aggregator.GetAggregatedException() as AggregateException; Assert.IsNotNull(aggregatedException, "Aggregated exception must NOT be null"); Assert.IsNotNull(aggregatedException.InnerExceptions, "Inner exception list must NOT be null"); Assert.AreEqual(aggregatedException.InnerExceptions.Count, 2, "Inner exception lsit must have one element"); Assert.AreEqual(aggregatedException.InnerExceptions[1], exception2, "Inner exception must be the one set."); }