Ejemplo n.º 1
0
        public void IteratorDisposedIsTrueOnceDisposed()
        {
            var iter = new TaskEnumerator <int>(JustOne(), 1);

            iter.Dispose();

            Assert.IsTrue(iter.Disposed);
        }
Ejemplo n.º 2
0
        public void IteratorRaisesOnceIteratorIsDisposed()
        {
            var iter = new TaskEnumerator <int>(JustOne(), 1);

            iter.Dispose();

            try {
                using (var e = iter.CurrentItems) {
                    var _ = e.Current;
                    Assert.Fail("e.Current did not throw an InvalidOperationException");
                }
            } catch (InvalidOperationException) {
            }
        }
Ejemplo n.º 3
0
        public void IteratorRaisesIfCurrentIsAccessedBeforeInitialMoveNext()
        {
            var iter = new TaskEnumerator <int>(JustOne(), 1);

            Assert.IsFalse(iter.Disposed);
            Scheduler.WaitFor(iter.Fetch());

            try {
                using (var e = iter.CurrentItems) {
                    var _ = e.Current;
                    Assert.Fail("e.Current did not throw an InvalidOperationException");
                }
            } catch (InvalidOperationException) {
            }

            iter.Dispose();
        }
Ejemplo n.º 4
0
        public void IteratorFailsMoveNextOnceIterationIsComplete()
        {
            var iter = new TaskEnumerator <int>(JustOne(), 1);

            Assert.IsFalse(iter.Disposed);
            Scheduler.WaitFor(iter.Fetch());

            using (var e = iter.CurrentItems) {
                Assert.IsTrue(e.MoveNext());
                Assert.AreEqual(1, e.Current);
                Assert.IsFalse(e.MoveNext());
            }

            Assert.IsFalse(iter.Disposed);
            Scheduler.WaitFor(iter.Fetch());
            Assert.IsTrue(iter.Disposed);

            iter.Dispose();
        }
Ejemplo n.º 5
0
        public void TestTypeCoercion()
        {
            var iter = new TaskEnumerator <int>(TwoTypes(), 1);

            Assert.IsFalse(iter.Disposed);
            Scheduler.WaitFor(iter.Fetch());

            using (var e = iter.CurrentItems) {
                Assert.IsTrue(e.MoveNext());
                Assert.AreEqual(1, e.Current);
            }

            Assert.IsFalse(iter.Disposed);

            try {
                Scheduler.WaitFor(iter.Fetch());
                Assert.Fail("Fetch did not throw an InvalidCastException");
            } catch (FutureException fe) {
                Assert.IsInstanceOf <InvalidCastException>(fe.InnerException);
            }

            iter.Dispose();
        }