AsyncEx.Tests.AsyncParallelTests.ParallelExceptionsTest C# (CSharp) Method

ParallelExceptionsTest() private method

private ParallelExceptionsTest ( ) : Task
return Task
        public async Task ParallelExceptionsTest()
        {
            var source = Enumerable.Repeat(true, 20).ToArray();

            var barrier = new AsyncBarrier(source.Length);

            var task = AsyncParallel.ForEach(
                source, async b =>
                {
                    await barrier.SignalAndWaitAsync();
                    throw new Exception();
                });

            await task.ContinueWith(t => { Assert.AreEqual(source.Length, t.Exception.InnerExceptions.Count); });
        }