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

SerialSyncNotTaskExceptionTest() private method

private SerialSyncNotTaskExceptionTest ( ) : Task
return Task
        public async Task SerialSyncNotTaskExceptionTest()
        {
            var source = new[] { true, false };

            int ran = 0;

            var exception = new Exception();
            try
            {
                await AsyncParallel.ForEach(
                    source, new ParallelOptions { MaxDegreeOfParallelism = 1 },
                    b =>
                    {
                        if (b)
                            throw exception;

                        Interlocked.Increment(ref ran);
                        return Task.FromResult(true);
                    });
                Assert.Fail();
            }
            catch (Exception e)
            {
                Assert.AreEqual(exception, e);
            }
            finally
            {
                Assert.AreEqual(0, ran);
            }
        }