protected virtual void AssertIterator(IQueue4 queue, string[] data, int size) { IEnumerator iter = queue.Iterator(); for (int idx = 0; idx < size; idx++) { Assert.IsTrue(iter.MoveNext(), "should be able to move in iteration #" + idx + " of " + size); Assert.AreEqual(data[idx], iter.Current); } Assert.IsFalse(iter.MoveNext()); }
public virtual void TestIteratorThrowsOnConcurrentModification() { object[] elements = new object[] { "foo", "bar" }; IQueue4 queue = NewQueue(elements); IEnumerator iterator = queue.Iterator(); Iterator4Assert.AssertNext("foo", iterator); queue.Add("baz"); Assert.AreEqual("foo", iterator.Current, "accessing current element should be harmless" ); Assert.Expect(typeof(InvalidOperationException), new _ICodeBlock_31(iterator)); }
public virtual IEnumerator Iterator() { return(_queue.Iterator()); }