Explorar o código

Remove another AssertThrows helper.

Bart De Smet %!s(int64=7) %!d(string=hai) anos
pai
achega
b6d07f2348

+ 0 - 6
Ix.NET/Source/System.Linq.Async.Tests/System/Linq/AsyncEnumerableTests.cs

@@ -19,12 +19,6 @@ namespace Tests
         protected const int WaitTimeoutMs = 5000;
 
 #pragma warning disable xUnit1013 // Public method should be marked as test
-        public void AssertThrows<E>(Action a)
-            where E : Exception
-        {
-            Assert.Throws<E>(a);
-        }
-
         public void AssertThrows<E>(Action a, Func<E, bool> assert)
             where E : Exception
         {

+ 20 - 8
Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/Count.cs

@@ -26,19 +26,17 @@ namespace Tests
         }
 
         [Fact]
-        public void Count1()
+        public async Task Count1()
         {
-            Assert.Equal(0, new int[0].ToAsyncEnumerable().Count().Result);
-            Assert.Equal(3, new[] { 1, 2, 3 }.ToAsyncEnumerable().Count().Result);
-            AssertThrows<AggregateException>(() => Throw<int>(new Exception("Bang!")).Count().Wait(WaitTimeoutMs));
+            Assert.Equal(0, await new int[0].ToAsyncEnumerable().Count());
+            Assert.Equal(3, await new[] { 1, 2, 3 }.ToAsyncEnumerable().Count());
         }
 
         [Fact]
-        public void Count2()
+        public async Task Count2()
         {
-            Assert.Equal(0, new int[0].ToAsyncEnumerable().Count(x => x < 3).Result);
-            Assert.Equal(2, new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(x => x < 3).Result);
-            AssertThrows<AggregateException>(() => Throw<int>(new Exception("Bang!")).Count(x => x < 3).Wait(WaitTimeoutMs));
+            Assert.Equal(0, await new int[0].ToAsyncEnumerable().Count(x => x < 3));
+            Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(x => x < 3));
         }
 
         [Fact]
@@ -48,5 +46,19 @@ namespace Tests
             var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(new Func<int, bool>(x => { throw ex; }));
             AssertThrowsAsync(ys, ex);
         }
+
+        [Fact]
+        public void Count4()
+        {
+            var ex = new Exception("Bang!");
+            AssertThrowsAsync(Throw<int>(ex).Count(), ex);
+        }
+
+        [Fact]
+        public void Count5()
+        {
+            var ex = new Exception("Bang!");
+            AssertThrowsAsync(Throw<int>(ex).Count(x => x < 3), ex);
+        }
     }
 }

+ 20 - 8
Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/LongCount.cs

@@ -26,19 +26,17 @@ namespace Tests
         }
 
         [Fact]
-        public void LongCount1()
+        public async Task LongCount1()
         {
-            Assert.Equal(0, new int[0].ToAsyncEnumerable().LongCount().Result);
-            Assert.Equal(3, new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount().Result);
-            AssertThrows<AggregateException>(() => Throw<int>(new Exception("Bang!")).LongCount().Wait(WaitTimeoutMs));
+            Assert.Equal(0, await new int[0].ToAsyncEnumerable().LongCount());
+            Assert.Equal(3, await new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount());
         }
 
         [Fact]
-        public void LongCount2()
+        public async Task LongCount2()
         {
-            Assert.Equal(0, new int[0].ToAsyncEnumerable().LongCount(x => x < 3).Result);
-            Assert.Equal(2, new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(x => x < 3).Result);
-            AssertThrows<AggregateException>(() => Throw<int>(new Exception("Bang!")).LongCount(x => x < 3).Wait(WaitTimeoutMs));
+            Assert.Equal(0, await new int[0].ToAsyncEnumerable().LongCount(x => x < 3));
+            Assert.Equal(2, await new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(x => x < 3));
         }
 
         [Fact]
@@ -48,5 +46,19 @@ namespace Tests
             var ys = new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(new Func<int, bool>(x => { throw ex; }));
             AssertThrowsAsync(ys, ex);
         }
+
+        [Fact]
+        public void LongCount4()
+        {
+            var ex = new Exception("Bang!");
+            AssertThrowsAsync(Throw<int>(ex).LongCount(), ex);
+        }
+
+        [Fact]
+        public void LongCount5()
+        {
+            var ex = new Exception("Bang!");
+            AssertThrowsAsync(Throw<int>(ex).LongCount(x => x < 3), ex);
+        }
     }
 }