diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs index 849a7fb520..7e39c00584 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs @@ -21,7 +21,7 @@ public async Task ToArray_Null() } [Fact] - public async Task ToArray1() + public async Task ToArray_IAsyncIListProvider_Simple() { var xs = new[] { 42, 25, 39 }; var res = xs.ToAsyncEnumerable().ToArrayAsync(); @@ -29,7 +29,23 @@ public async Task ToArray1() } [Fact] - public async Task ToArray2() + public async Task ToArray_IAsyncIListProvider_Empty1() + { + var xs = new int[0]; + var res = xs.ToAsyncEnumerable().ToArrayAsync(); + Assert.True((await res).SequenceEqual(xs)); + } + + [Fact] + public async Task ToArray_IAsyncIListProvider_Empty2() + { + var xs = new HashSet(); + var res = xs.ToAsyncEnumerable().ToArrayAsync(); + Assert.True((await res).SequenceEqual(xs)); + } + + [Fact] + public async Task ToArray_Empty() { var xs = AsyncEnumerable.Empty(); var res = xs.ToArrayAsync(); @@ -37,7 +53,7 @@ public async Task ToArray2() } [Fact] - public async Task ToArray3Async() + public async Task ToArray_Throw() { var ex = new Exception("Bang!"); var res = Throw(ex).ToArrayAsync(); @@ -45,7 +61,7 @@ public async Task ToArray3Async() } [Fact] - public async Task ToArray4() + public async Task ToArray_Query() { var xs = await AsyncEnumerable.Range(5, 50).Take(10).ToArrayAsync(); var ex = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; @@ -54,7 +70,7 @@ public async Task ToArray4() } [Fact] - public async Task ToArray5() + public async Task ToArray_Set() { var res = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; var xs = new HashSet(res); diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs index d39069616f..2ba83c0705 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToHashSet.cs @@ -23,11 +23,26 @@ public async Task ToHashSet_Null() } [Fact] - public async Task ToHashSet1() + public async Task ToHashSet_Simple() { var xs = new[] { 1, 2, 1, 2, 3, 4, 1, 2, 3, 4 }; var res = xs.ToAsyncEnumerable().ToHashSetAsync(); Assert.True((await res).OrderBy(x => x).SequenceEqual(new[] { 1, 2, 3, 4 })); } + + [Fact] + public async Task ToHashSet_Comparer() + { + var xs = new[] { 1, 12, 11, 2, 3, 14, 1, 12, 13, 4 }; + var res = xs.ToAsyncEnumerable().ToHashSetAsync(new Eq()); + Assert.True((await res).OrderBy(x => x).SequenceEqual(new[] { 1, 3, 12, 14 })); + } + + private class Eq : IEqualityComparer + { + public bool Equals(int x, int y) => x % 10 == y % 10; + + public int GetHashCode(int obj) => obj % 10; + } } } diff --git a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs index 70c25723ed..e699c0ff0d 100644 --- a/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs +++ b/Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs @@ -20,7 +20,7 @@ public async Task ToList_Null() } [Fact] - public async Task ToList1() + public async Task ToList_Simple() { var xs = new[] { 42, 25, 39 }; var res = xs.ToAsyncEnumerable().ToListAsync(); @@ -28,7 +28,7 @@ public async Task ToList1() } [Fact] - public async Task ToList2() + public async Task ToList_Empty() { var xs = AsyncEnumerable.Empty(); var res = xs.ToListAsync(); @@ -36,7 +36,7 @@ public async Task ToList2() } [Fact] - public async Task ToList3Async() + public async Task ToList_Throw() { var ex = new Exception("Bang!"); var res = Throw(ex).ToListAsync();