浏览代码

Remove CancellationTestAsyncEnumerable.

Bart De Smet 8 年之前
父节点
当前提交
58b8bef8a4
共有 3 个文件被更改,包括 0 次插入192 次删除
  1. 0 40
      Ix.NET/Source/Tests/AsyncTests.Creation.cs
  2. 0 104
      Ix.NET/Source/Tests/AsyncTests.Single.cs
  3. 0 48
      Ix.NET/Source/Tests/AsyncTests.cs

+ 0 - 40
Ix.NET/Source/Tests/AsyncTests.Creation.cs

@@ -394,46 +394,6 @@ namespace Tests
             Assert.True(disposed.Task.Result);
         }
 
-        [Fact]
-        public async Task Using6()
-        {
-            var i = 0;
-            var disposed = new TaskCompletionSource<bool>();
-
-            var xs = AsyncEnumerable.Using(
-                () =>
-                {
-                    i++;
-                    return new MyD(() => { disposed.TrySetResult(true); });
-                },
-                _ => new CancellationTestAsyncEnumerable(2) // need to use this to verify we actually cancel
-            );
-
-            Assert.Equal(0, i);
-
-            var e = xs.GetAsyncEnumerator();
-            Assert.Equal(1, i);
-
-            HasNext(e, 0);
-            HasNext(e, 1);
-
-            var cts = new CancellationTokenSource();
-            var t = e.MoveNextAsync(cts.Token);
-            cts.Cancel();
-
-            try
-            {
-                t.Wait(WaitTimeoutMs);
-            }
-            catch (AggregateException ex)
-            {
-                ex.Flatten().Handle(inner => inner is TaskCanceledException);
-            }
-
-            Assert.True(disposed.Task.IsCompleted);
-            Assert.True(await disposed.Task);
-        }
-
         [Fact]
         public async Task Using7()
         {

+ 0 - 104
Ix.NET/Source/Tests/AsyncTests.Single.cs

@@ -91,18 +91,6 @@ namespace Tests
             NoNext(e);
         }
 
-        [Fact]
-        public void Select6()
-        {
-            var xs = new CancellationTestAsyncEnumerable(10);
-            var ys = xs.Select(i => i + 3).Select(x => (char)('a' + x));
-
-            var e = ys.GetAsyncEnumerator();
-            HasNext(e, 'd');
-            HasNext(e, 'e');
-            HasNext(e, 'f');
-        }
-
         [Fact]
         public async Task Select7()
         {
@@ -121,32 +109,6 @@ namespace Tests
             await SequenceIdentity(ys);
         }
 
-
-        [Fact]
-        public void SelectWhere1()
-        {
-            var xs = new CancellationTestAsyncEnumerable(10);
-            var ys = xs.Select(i => i + 2).Where(i => i % 2 == 0);
-
-            var e = ys.GetAsyncEnumerator();
-            HasNext(e, 2);
-            HasNext(e, 4);
-            HasNext(e, 6);
-        }
-
-        [Fact]
-        public void WhereSelect1()
-        {
-            var xs = new CancellationTestAsyncEnumerable(10);
-            var ys = xs.Where(i => i % 2 == 0).Select(i => i + 2);
-
-            var e = ys.GetAsyncEnumerator();
-            HasNext(e, 2);
-            HasNext(e, 4);
-            HasNext(e, 6);
-        }
-
-
         [Fact]
         public void SelectWhere2()
         {
@@ -184,15 +146,6 @@ namespace Tests
             NoNext(e);
         }
 
-        [Fact]
-        public async Task WhereSelect4()
-        {
-            var xs = new CancellationTestAsyncEnumerable(10).Take(5);
-            var ys = xs.Where(i => i % 2 == 0).Select(i => i + 2);
-
-            await SequenceIdentity(ys);
-        }
-
         [Fact]
         public void Where_Null()
         {
@@ -1491,34 +1444,6 @@ namespace Tests
             await SequenceIdentity(xs);
         }
 
-        [Fact]
-        public async Task DefaultIfEmpty16()
-        {
-            var xs = new CancellationTestAsyncEnumerable(10)
-                .Take(5)
-                .Reverse() // so we have an ilist provider 
-                .DefaultIfEmpty(24)
-                .Append(5); // for the onlyIsCheap to true
-
-            var r = new[] { 4, 3, 2, 1, 0, 5 };
-
-            Assert.Equal(r, await xs.ToArray());
-        }
-
-        [Fact]
-        public async Task DefaultIfEmpty17()
-        {
-            var xs = new CancellationTestAsyncEnumerable(10)
-                .Take(5)
-                .DefaultIfEmpty(24)
-                .Append(5); // for the onlyIsCheap to true
-
-            var r = new[] { 0, 1, 2, 3, 4, 5};
-
-            Assert.Equal(r, await xs.ToArray());
-        }
-
-
         [Fact]
         public void Distinct_Null()
         {
@@ -1740,35 +1665,6 @@ namespace Tests
             Assert.Equal(new[] { 4, 3, 2, 1 }, await ys.ToArray());
         }
 
-        [Fact]
-        public async Task Reverse10()
-        {
-            var xs = new CancellationTestAsyncEnumerable(10).Skip(1).Take(3);
-            var ys = xs.Reverse().Prepend(4); // to trigger onlyIfCheap
-
-            Assert.Equal(new[] { 4, 3, 2, 1 }, await ys.ToArray());
-        }
-
-        [Fact]
-        public async Task Reverse11()
-        {
-            var xs = new CancellationTestAsyncEnumerable(10).Skip(1).Take(3);
-            var ys = xs.Reverse().Prepend(4); // to trigger onlyIfCheap
-
-            Assert.Equal(new[] { 4, 3, 2, 1 }, await ys.ToList());
-        }
-
-
-        [Fact]
-        public async Task Reverse12()
-        {
-            var xs = new CancellationTestAsyncEnumerable(10).Skip(1).Take(3);
-            var ys = xs.Reverse().Prepend(4).Prepend(5); // to trigger onlyIfCheap
-
-            Assert.Equal(new[] { 5, 4, 3, 2, 1 }, await ys.ToArray());
-        }
-
-
         [Fact]
         public void OrderBy_Null()
         {

+ 0 - 48
Ix.NET/Source/Tests/AsyncTests.cs

@@ -87,53 +87,5 @@ namespace Tests
             e1Result.ShouldAllBeEquivalentTo(e2Result);
         }
 #pragma warning restore xUnit1013 // Public method should be marked as test        
-
-        /// <summary>
-        /// Waits WaitTimeoutMs or until cancellation is requested. If cancellation was not requested, MoveNext returns true.
-        /// </summary>
-        internal sealed class CancellationTestAsyncEnumerable : IAsyncEnumerable<int>
-        {
-            private readonly int iterationsBeforeDelay;
-
-            public CancellationTestAsyncEnumerable(int iterationsBeforeDelay = 0)
-            {
-                this.iterationsBeforeDelay = iterationsBeforeDelay;
-            }
-            IAsyncEnumerator<int> IAsyncEnumerable<int>.GetAsyncEnumerator() => GetEnumerator();
-
-            public TestEnumerator GetEnumerator() => new TestEnumerator(iterationsBeforeDelay);
-
-
-            internal sealed class TestEnumerator : IAsyncEnumerator<int>
-            {
-                private readonly int iterationsBeforeDelay;
-
-                public TestEnumerator(int iterationsBeforeDelay)
-                {
-                    this.iterationsBeforeDelay = iterationsBeforeDelay;
-                }
-                int i = -1;
-                public void Dispose()
-                {
-                }
-
-                public bool MoveNextWasCalled { get; private set; }
-
-                public int Current => i;
-
-                public async Task<bool> MoveNextAsync()
-                {
-                    MoveNextWasCalled = true;
-
-                    i++;
-                    if (Current >= iterationsBeforeDelay)
-                    {
-                        await Task.Delay(WaitTimeoutMs);
-                    }
-
-                    return true;
-                }
-            }
-        }
     }
 }