Eli Arbel 9 年 前
コミット
562316ad93

+ 1 - 1
Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.Aggregates.cs

@@ -1709,7 +1709,7 @@ namespace System.Linq
             using (var e = source.GetEnumerator())
             {
                 if (!await e.MoveNext(cancellationToken).ConfigureAwait(false))
-                    throw new InvalidOperationException("Source sequence doesn't contain any elements.");
+                    throw new InvalidOperationException(Strings.NO_ELEMENTS);
 
                 var current = e.Current;
                 var resKey = keySelector(current);

+ 1 - 1
Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.Single.cs

@@ -1279,7 +1279,7 @@ namespace System.Linq
             source.ForEachAsync(action, cancellationToken).Wait(cancellationToken);
         }
 
-        public static async Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource, int> action, CancellationToken cancellationToken)
+        public static Task ForEachAsync<TSource>(this IAsyncEnumerable<TSource> source, Action<TSource, int> action, CancellationToken cancellationToken)
         {
             if (source == null)
                 throw new ArgumentNullException(nameof(source));

+ 10 - 8
Ix.NET/Source/Tests/AsyncTests.Aggregates.cs

@@ -18,6 +18,8 @@ namespace Tests
 {
     public partial class AsyncTests
     {
+        private const int WaitTimeoutMs = 5000;
+
         [Fact]
         public async Task Aggregate_Null()
         {
@@ -168,16 +170,16 @@ namespace Tests
         [Fact]
         public void Count1()
         {
-            Assert.AreEqual(new int[0].ToAsyncEnumerable().Count().Result, 0);
-            Assert.AreEqual(new[] { 1, 2, 3 }.ToAsyncEnumerable().Count().Result, 3);
+            Assert.Equal(new int[0].ToAsyncEnumerable().Count().Result, 0);
+            Assert.Equal(new[] { 1, 2, 3 }.ToAsyncEnumerable().Count().Result, 3);
             AssertThrows<AggregateException>(() => AsyncEnumerable.Throw<int>(new Exception("Bang!")).Count().Wait(WaitTimeoutMs));
         }
 
         [Fact]
         public void Count2()
         {
-            Assert.AreEqual(new int[0].ToAsyncEnumerable().Count(x => x < 3).Result, 0);
-            Assert.AreEqual(new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(x => x < 3).Result, 2);
+            Assert.Equal(new int[0].ToAsyncEnumerable().Count(x => x < 3).Result, 0);
+            Assert.Equal(new[] { 1, 2, 3 }.ToAsyncEnumerable().Count(x => x < 3).Result, 2);
             AssertThrows<AggregateException>(() => AsyncEnumerable.Throw<int>(new Exception("Bang!")).Count(x => x < 3).Wait(WaitTimeoutMs));
         }
 
@@ -204,16 +206,16 @@ namespace Tests
         [Fact]
         public void LongCount1()
         {
-            Assert.AreEqual(new int[0].ToAsyncEnumerable().LongCount().Result, 0);
-            Assert.AreEqual(new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount().Result, 3);
+            Assert.Equal(new int[0].ToAsyncEnumerable().LongCount().Result, 0);
+            Assert.Equal(new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount().Result, 3);
             AssertThrows<AggregateException>(() => AsyncEnumerable.Throw<int>(new Exception("Bang!")).LongCount().Wait(WaitTimeoutMs));
         }
 
         [Fact]
         public void LongCount2()
         {
-            Assert.AreEqual(new int[0].ToAsyncEnumerable().LongCount(x => x < 3).Result, 0);
-            Assert.AreEqual(new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(x => x < 3).Result, 2);
+            Assert.Equal(new int[0].ToAsyncEnumerable().LongCount(x => x < 3).Result, 0);
+            Assert.Equal(new[] { 1, 2, 3 }.ToAsyncEnumerable().LongCount(x => x < 3).Result, 2);
             AssertThrows<AggregateException>(() => AsyncEnumerable.Throw<int>(new Exception("Bang!")).LongCount(x => x < 3).Wait(WaitTimeoutMs));
         }
 

+ 1 - 1
Ix.NET/Source/Tests/AsyncTests.Bugs.cs

@@ -191,7 +191,7 @@ namespace Tests
 
             try
             {
-                t.Wait();
+                t.Wait(WaitTimeoutMs);
                 Assert.True(false);
             }
             catch

+ 1 - 1
Ix.NET/Source/Tests/AsyncTests.Exceptions.cs

@@ -323,7 +323,7 @@ namespace Tests
             var e = xs.GetEnumerator();
 
             Assert.False(b);
-            AssertThrows<Exception>(() => e.MoveNext().Wait(), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
+            AssertThrows<Exception>(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).Flatten().InnerExceptions.Single() == ex);
 
             Assert.True(b);
         }

+ 4 - 4
Ix.NET/Source/Tests/AsyncTests.Single.cs

@@ -549,7 +549,7 @@ namespace Tests
 
             Assert.False(hasv);
             Assert.False(done);
-            Assert.Same(((AggregateException)exa).Flatten().InnerExceptions.Single(), ex);
+            Assert.Same(exa, ex);
         }
 
         [Fact]
@@ -565,7 +565,7 @@ namespace Tests
             AssertThrows<Exception>(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ex_.InnerException == ex);
 
             Assert.False(hasv);
-            Assert.Same(((AggregateException)exa).Flatten().InnerExceptions.Single(), ex);
+            Assert.Same(exa, ex);
         }
 
         [Fact]
@@ -602,7 +602,7 @@ namespace Tests
             var sum = 0;
             var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable();
 
-            xs.ForEachAsync(x => sum += x).Wait();
+            xs.ForEachAsync(x => sum += x).Wait(WaitTimeoutMs);
             Assert.Equal(10, sum);
         }
 
@@ -632,7 +632,7 @@ namespace Tests
             var sum = 0;
             var xs = new[] { 1, 2, 3, 4 }.ToAsyncEnumerable();
 
-            xs.ForEachAsync((x, i) => sum += x * i).Wait();
+            xs.ForEachAsync((x, i) => sum += x * i).Wait(WaitTimeoutMs);
             Assert.Equal(1 * 0 + 2 * 1 + 3 * 2 + 4 * 3, sum);
         }