Esempio n. 1
0
        public void TestInvalidatedEnumeratorDetection()
        {
            Deque <int> intDeque = createDeque(8);

            using (IEnumerator <int> enumerator = intDeque.GetEnumerator()) {
                Assert.IsTrue(enumerator.MoveNext());
                intDeque.AddFirst(12345);
                Assert.Throws <InvalidOperationException>(
                    delegate() { enumerator.MoveNext(); }
                    );
            }
        }
Esempio n. 2
0
        public void TestThrowOnInvalidEnumeratorPosition()
        {
            Deque <int> intDeque = createNonNormalizedDeque(40);

            using (IEnumerator <int> enumerator = intDeque.GetEnumerator()) {
                Assert.Throws <InvalidOperationException>(
                    delegate() { Console.WriteLine(enumerator.Current); }
                    );

                while (enumerator.MoveNext())
                {
                }

                Assert.Throws <InvalidOperationException>(
                    delegate() { Console.WriteLine(enumerator.Current); }
                    );
            }
        }
Esempio n. 3
0
        public void TestEnumerator()
        {
            Deque <int> intDeque = createNonNormalizedDeque(40);

            for (int testRun = 0; testRun < 2; ++testRun)
            {
                using (IEnumerator <int> enumerator = intDeque.GetEnumerator()) {
                    for (int index = 0; index < intDeque.Count; ++index)
                    {
                        Assert.IsTrue(enumerator.MoveNext());
                        Assert.AreEqual(index, enumerator.Current);
                    }

                    Assert.IsFalse(enumerator.MoveNext());

                    enumerator.Reset();
                }
            }
        }