Browse Source

Moving ToList and ToArray tests.

Bart De Smet 8 years ago
parent
commit
c2045b56df

+ 0 - 82
Ix.NET/Source/System.Interactive.Async.Tests/AsyncTests.Aggregates.cs

@@ -636,88 +636,6 @@ namespace Tests
             AssertThrows<Exception>(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
         }
 
-        [Fact]
-        public async Task ToList_Null()
-        {
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ToList<int>(null));
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ToList<int>(null, CancellationToken.None));
-        }
-
-        [Fact]
-        public void ToList1()
-        {
-            var xs = new[] { 42, 25, 39 };
-            var res = xs.ToAsyncEnumerable().ToList();
-            Assert.True(res.Result.SequenceEqual(xs));
-        }
-
-        [Fact]
-        public void ToList2()
-        {
-            var xs = AsyncEnumerable.Empty<int>();
-            var res = xs.ToList();
-            Assert.True(res.Result.Count == 0);
-        }
-
-        [Fact]
-        public void ToList3()
-        {
-            var ex = new Exception("Bang!");
-            var res = AsyncEnumerable.Throw<int>(ex).ToList();
-            AssertThrows<Exception>(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
-        }
-
-        [Fact]
-        public async Task ToArray_Null()
-        {
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ToArray<int>(null));
-            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ToArray<int>(null, CancellationToken.None));
-        }
-
-        [Fact]
-        public void ToArray1()
-        {
-            var xs = new[] { 42, 25, 39 };
-            var res = xs.ToAsyncEnumerable().ToArray();
-            Assert.True(res.Result.SequenceEqual(xs));
-        }
-
-        [Fact]
-        public void ToArray2()
-        {
-            var xs = AsyncEnumerable.Empty<int>();
-            var res = xs.ToArray();
-            Assert.True(res.Result.Length == 0);
-        }
-
-        [Fact]
-        public void ToArray3()
-        {
-            var ex = new Exception("Bang!");
-            var res = AsyncEnumerable.Throw<int>(ex).ToArray();
-            AssertThrows<Exception>(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
-        }
-
-        [Fact]
-        public async Task ToArray4()
-        {
-            var xs = await AsyncEnumerable.Range(5, 50).Take(10).ToArray();
-            var ex = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
-
-            Assert.True(ex.SequenceEqual(xs));
-        }
-
-        [Fact]
-        public async Task ToArray5()
-        {
-            var res = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
-            var xs = new HashSet<int>(res);
-
-            var arr = await xs.ToAsyncEnumerable().ToArray();
-
-            Assert.True(res.SequenceEqual(arr));
-        }
-
         [Fact]
         public async Task ToDictionary_Null()
         {

+ 67 - 0
Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToArray.cs

@@ -0,0 +1,67 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace Tests
+{
+    public class ToArray : AsyncEnumerableTests
+    {
+        [Fact]
+        public async Task ToArray_Null()
+        {
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ToArray<int>(null));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ToArray<int>(null, CancellationToken.None));
+        }
+
+        [Fact]
+        public void ToArray1()
+        {
+            var xs = new[] { 42, 25, 39 };
+            var res = xs.ToAsyncEnumerable().ToArray();
+            Assert.True(res.Result.SequenceEqual(xs));
+        }
+
+        [Fact]
+        public void ToArray2()
+        {
+            var xs = AsyncEnumerable.Empty<int>();
+            var res = xs.ToArray();
+            Assert.True(res.Result.Length == 0);
+        }
+
+        [Fact]
+        public void ToArray3()
+        {
+            var ex = new Exception("Bang!");
+            var res = AsyncEnumerable.Throw<int>(ex).ToArray();
+            AssertThrows<Exception>(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
+        }
+
+        [Fact]
+        public async Task ToArray4()
+        {
+            var xs = await AsyncEnumerable.Range(5, 50).Take(10).ToArray();
+            var ex = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
+
+            Assert.True(ex.SequenceEqual(xs));
+        }
+
+        [Fact]
+        public async Task ToArray5()
+        {
+            var res = new[] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
+            var xs = new HashSet<int>(res);
+
+            var arr = await xs.ToAsyncEnumerable().ToArray();
+
+            Assert.True(res.SequenceEqual(arr));
+        }
+    }
+}

+ 46 - 0
Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToList.cs

@@ -0,0 +1,46 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
+
+using System;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace Tests
+{
+    public class ToList : AsyncEnumerableTests
+    {
+        [Fact]
+        public async Task ToList_Null()
+        {
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ToList<int>(null));
+            await Assert.ThrowsAsync<ArgumentNullException>(() => AsyncEnumerable.ToList<int>(null, CancellationToken.None));
+        }
+
+        [Fact]
+        public void ToList1()
+        {
+            var xs = new[] { 42, 25, 39 };
+            var res = xs.ToAsyncEnumerable().ToList();
+            Assert.True(res.Result.SequenceEqual(xs));
+        }
+
+        [Fact]
+        public void ToList2()
+        {
+            var xs = AsyncEnumerable.Empty<int>();
+            var res = xs.ToList();
+            Assert.True(res.Result.Count == 0);
+        }
+
+        [Fact]
+        public void ToList3()
+        {
+            var ex = new Exception("Bang!");
+            var res = AsyncEnumerable.Throw<int>(ex).ToList();
+            AssertThrows<Exception>(() => res.Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
+        }
+    }
+}