|
@@ -26,112 +26,6 @@ namespace Tests
|
|
|
await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerableEx.IsEmpty<int>(null, CancellationToken.None));
|
|
|
}
|
|
|
|
|
|
- [Fact]
|
|
|
- public async Task ElementAt_Null()
|
|
|
- {
|
|
|
- await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ElementAt<int>(null, 0));
|
|
|
- await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => AsyncEnumerable.ElementAt<int>(AsyncEnumerable.Return(42), -1));
|
|
|
-
|
|
|
- await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ElementAt<int>(null, 0, CancellationToken.None));
|
|
|
- await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => AsyncEnumerable.ElementAt<int>(AsyncEnumerable.Return(42), -1, CancellationToken.None));
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public void ElementAt1()
|
|
|
- {
|
|
|
- var res = AsyncEnumerable.Empty<int>().ElementAt(0);
|
|
|
- AssertThrows<Exception>(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException);
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public void ElementAt2()
|
|
|
- {
|
|
|
- var res = AsyncEnumerable.Return<int>(42).ElementAt(0);
|
|
|
- Assert.Equal(42, res.Result);
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public void ElementAt3()
|
|
|
- {
|
|
|
- var res = AsyncEnumerable.Return<int>(42).ElementAt(1);
|
|
|
- AssertThrows<Exception>(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException);
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public void ElementAt4()
|
|
|
- {
|
|
|
- var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAt(1);
|
|
|
- Assert.Equal(42, res.Result);
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public void ElementAt5()
|
|
|
- {
|
|
|
- var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAt(7);
|
|
|
- AssertThrows<Exception>(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() is ArgumentOutOfRangeException);
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public void ElementAt6()
|
|
|
- {
|
|
|
- var ex = new Exception("Bang!");
|
|
|
- var res = AsyncEnumerable.Throw<int>(ex).ElementAt(15);
|
|
|
- AssertThrows<Exception>(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public async Task ElementAtOrDefault_Null()
|
|
|
- {
|
|
|
- await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ElementAtOrDefault<int>(null, 0));
|
|
|
- await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => AsyncEnumerable.ElementAtOrDefault<int>(AsyncEnumerable.Return(42), -1));
|
|
|
-
|
|
|
- await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ElementAtOrDefault<int>(null, 0, CancellationToken.None));
|
|
|
- await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => AsyncEnumerable.ElementAtOrDefault<int>(AsyncEnumerable.Return(42), -1, CancellationToken.None));
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public void ElementAtOrDefault1()
|
|
|
- {
|
|
|
- var res = AsyncEnumerable.Empty<int>().ElementAtOrDefault(0);
|
|
|
- Assert.Equal(0, res.Result);
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public void ElementAtOrDefault2()
|
|
|
- {
|
|
|
- var res = AsyncEnumerable.Return<int>(42).ElementAtOrDefault(0);
|
|
|
- Assert.Equal(42, res.Result);
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public void ElementAtOrDefault3()
|
|
|
- {
|
|
|
- var res = AsyncEnumerable.Return<int>(42).ElementAtOrDefault(1);
|
|
|
- Assert.Equal(0, res.Result);
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public void ElementAtOrDefault4()
|
|
|
- {
|
|
|
- var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtOrDefault(1);
|
|
|
- Assert.Equal(42, res.Result);
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public void ElementAtOrDefault5()
|
|
|
- {
|
|
|
- var res = new[] { 1, 42, 3 }.ToAsyncEnumerable().ElementAtOrDefault(7);
|
|
|
- Assert.Equal(0, res.Result);
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- public void ElementAtOrDefault6()
|
|
|
- {
|
|
|
- var ex = new Exception("Bang!");
|
|
|
- var res = AsyncEnumerable.Throw<int>(ex).ElementAtOrDefault(15);
|
|
|
- AssertThrows<Exception>(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
|
|
|
- }
|
|
|
-
|
|
|
[Fact]
|
|
|
public async Task ToDictionary_Null()
|
|
|
{
|