Browse Source

Remove blocking ForEach.

Bart De Smet 8 years ago
parent
commit
1647285672

+ 0 - 70
Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Single.cs

@@ -746,20 +746,6 @@ namespace Tests
             await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ForEachAsync<int>(AsyncEnumerable.Return(42), default(Action<int, int>), CancellationToken.None));
         }
 
-        [Fact]
-        public void ForEach_Null()
-        {
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.ForEach<int>(null, x => { }));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.ForEach<int>(AsyncEnumerable.Return(42), default(Action<int>)));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.ForEach<int>(null, (x, i) => { }));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.ForEach<int>(AsyncEnumerable.Return(42), default(Action<int, int>)));
-
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.ForEach<int>(null, x => { }, CancellationToken.None));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.ForEach<int>(AsyncEnumerable.Return(42), default(Action<int>), CancellationToken.None));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.ForEach<int>(null, (x, i) => { }, CancellationToken.None));
-            AssertThrows<ArgumentNullException>(() => AsyncEnumerable.ForEach<int>(AsyncEnumerable.Return(42), default(Action<int, int>), CancellationToken.None));
-        }
-
         [Fact]
         public void ForEachAsync1()
         {
@@ -770,32 +756,12 @@ namespace Tests
             Assert.Equal(10, sum);
         }
 
-        [Fact]
-        public void ForEach1()
-        {
-            var sum = 0;
-            var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable();
-
-            xs.ForEach(x => sum += x);
-            Assert.Equal(10, sum);
-        }
-
         [Fact]
         public void ForEachAsync2()
         {
             var sum = 0;
             var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable();
 
-            xs.ForEach((x, i) => sum += x * i);
-            Assert.Equal(1 * 0 + 2 * 1 + 3 * 2 + 4 * 3, sum);
-        }
-
-        [Fact]
-        public void ForEach2()
-        {
-            var sum = 0;
-            var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable();
-
             xs.ForEachAsync((x, i) => sum += x * i).Wait(WaitTimeoutMs);
             Assert.Equal(1 * 0 + 2 * 1 + 3 * 2 + 4 * 3, sum);
         }
@@ -809,15 +775,6 @@ namespace Tests
             AssertThrows<Exception>(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
         }
 
-        [Fact]
-        public void ForEach3()
-        {
-            var ex = new Exception("Bang");
-            var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable();
-
-            AssertThrows<Exception>(() => xs.ForEach(x => { throw ex; }), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
-        }
-
         [Fact]
         public void ForEachAsync4()
         {
@@ -827,15 +784,6 @@ namespace Tests
             AssertThrows<Exception>(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
         }
 
-        [Fact]
-        public void ForEach4()
-        {
-            var ex = new Exception("Bang");
-            var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable();
-
-            AssertThrows<Exception>(() => xs.ForEach((x, i) => { throw ex; }), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
-        }
-
         [Fact]
         public void ForEachAsync5()
         {
@@ -845,15 +793,6 @@ namespace Tests
             AssertThrows<Exception>(() => xs.ForEachAsync(x => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
         }
 
-        [Fact]
-        public void ForEach5()
-        {
-            var ex = new Exception("Bang");
-            var xs = AsyncEnumerable.Throw<int>(ex);
-
-            AssertThrows<Exception>(() => xs.ForEach(x => { throw ex; }), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
-        }
-
         [Fact]
         public void ForEachAsync6()
         {
@@ -863,15 +802,6 @@ namespace Tests
             AssertThrows<Exception>(() => xs.ForEachAsync((x, i) => { throw ex; }).Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
         }
 
-        [Fact]
-        public void ForEach6()
-        {
-            var ex = new Exception("Bang");
-            var xs = AsyncEnumerable.Throw<int>(ex);
-
-            AssertThrows<Exception>(() => xs.ForEach((x, i) => { throw ex; }), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
-        }
-
         [Fact]
         public void Take_Null()
         {

+ 0 - 40
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ForEach.cs

@@ -10,46 +10,6 @@ namespace System.Linq
 {
     public static partial class AsyncEnumerable
     {
-        public static void ForEach<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> action)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-            if (action == null)
-                throw new ArgumentNullException(nameof(action));
-
-            source.ForEach(action, CancellationToken.None);
-        }
-
-        public static void ForEach<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource, int> action)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-            if (action == null)
-                throw new ArgumentNullException(nameof(action));
-
-            source.ForEach(action, CancellationToken.None);
-        }
-
-        public static void ForEach<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> action, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-            if (action == null)
-                throw new ArgumentNullException(nameof(action));
-
-            source.ForEachAsync(action, cancellationToken).Wait(cancellationToken);
-        }
-
-        public static void ForEach<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource, int> action, CancellationToken cancellationToken)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-            if (action == null)
-                throw new ArgumentNullException(nameof(action));
-
-            source.ForEachAsync(action, cancellationToken).Wait(cancellationToken);
-        }
-
         public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource> action)
         {
             if (source == null)