|
@@ -31,7 +31,6 @@ namespace Tests
|
|
|
HasNext(e, 2);
|
|
HasNext(e, 2);
|
|
|
HasNext(e, 4);
|
|
HasNext(e, 4);
|
|
|
NoNext(e);
|
|
NoNext(e);
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
@@ -527,78 +526,5 @@ namespace Tests
|
|
|
HasNext(e, 2);
|
|
HasNext(e, 2);
|
|
|
AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
|
|
AssertThrows(() => e.MoveNextAsync().Wait(WaitTimeoutMs), (Exception ex_) => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- [Fact]
|
|
|
|
|
- public void Buffer_Null()
|
|
|
|
|
- {
|
|
|
|
|
- AssertThrows<ArgumentNullException>(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable<int>), 1));
|
|
|
|
|
- AssertThrows<ArgumentNullException>(() => AsyncEnumerableEx.Buffer(default(IAsyncEnumerable<int>), 1, 1));
|
|
|
|
|
-
|
|
|
|
|
- AssertThrows<ArgumentOutOfRangeException>(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), -1));
|
|
|
|
|
- AssertThrows<ArgumentOutOfRangeException>(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), -1, 1));
|
|
|
|
|
- AssertThrows<ArgumentOutOfRangeException>(() => AsyncEnumerableEx.Buffer(AsyncEnumerable.Return(42), 1, -1));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [Fact]
|
|
|
|
|
- public void Buffer1()
|
|
|
|
|
- {
|
|
|
|
|
- var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(2);
|
|
|
|
|
-
|
|
|
|
|
- var e = xs.GetAsyncEnumerator();
|
|
|
|
|
-
|
|
|
|
|
- Assert.True(e.MoveNextAsync().Result);
|
|
|
|
|
- Assert.True(e.Current.SequenceEqual(new[] { 1, 2 }));
|
|
|
|
|
-
|
|
|
|
|
- Assert.True(e.MoveNextAsync().Result);
|
|
|
|
|
- Assert.True(e.Current.SequenceEqual(new[] { 3, 4 }));
|
|
|
|
|
-
|
|
|
|
|
- Assert.True(e.MoveNextAsync().Result);
|
|
|
|
|
- Assert.True(e.Current.SequenceEqual(new[] { 5 }));
|
|
|
|
|
-
|
|
|
|
|
- Assert.False(e.MoveNextAsync().Result);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [Fact]
|
|
|
|
|
- public void Buffer2()
|
|
|
|
|
- {
|
|
|
|
|
- var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(3, 2);
|
|
|
|
|
-
|
|
|
|
|
- var e = xs.GetAsyncEnumerator();
|
|
|
|
|
-
|
|
|
|
|
- Assert.True(e.MoveNextAsync().Result);
|
|
|
|
|
- Assert.True(e.Current.SequenceEqual(new[] { 1, 2, 3 }));
|
|
|
|
|
-
|
|
|
|
|
- Assert.True(e.MoveNextAsync().Result);
|
|
|
|
|
- Assert.True(e.Current.SequenceEqual(new[] { 3, 4, 5 }));
|
|
|
|
|
-
|
|
|
|
|
- Assert.True(e.MoveNextAsync().Result);
|
|
|
|
|
- Assert.True(e.Current.SequenceEqual(new[] { 5 }));
|
|
|
|
|
-
|
|
|
|
|
- Assert.False(e.MoveNextAsync().Result);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [Fact]
|
|
|
|
|
- public void Buffer3()
|
|
|
|
|
- {
|
|
|
|
|
- var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(2, 3);
|
|
|
|
|
-
|
|
|
|
|
- var e = xs.GetAsyncEnumerator();
|
|
|
|
|
-
|
|
|
|
|
- Assert.True(e.MoveNextAsync().Result);
|
|
|
|
|
- Assert.True(e.Current.SequenceEqual(new[] { 1, 2 }));
|
|
|
|
|
-
|
|
|
|
|
- Assert.True(e.MoveNextAsync().Result);
|
|
|
|
|
- Assert.True(e.Current.SequenceEqual(new[] { 4, 5 }));
|
|
|
|
|
-
|
|
|
|
|
- Assert.False(e.MoveNextAsync().Result);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- [Fact]
|
|
|
|
|
- public async Task Buffer4()
|
|
|
|
|
- {
|
|
|
|
|
- var xs = new[] { 1, 2, 3, 4, 5 }.ToAsyncEnumerable().Buffer(3, 2);
|
|
|
|
|
-
|
|
|
|
|
- await SequenceIdentity(xs);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|