|
|
@@ -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()
|
|
|
{
|