예제 #1
0
        public void EnumeratorDoesNotIncludeConcurrentModifications()
        {
            //Arrange
            var   arr   = new[] { 1, 2, 3 };
            var   deque = new ConcurrentDeque <Int32>(arr);
            Int32 item;

            //Act
            var iterator = deque.GetEnumerator();

            iterator.MoveNext();

            deque.TryPopLeft(out item);
            deque.TryPopLeft(out item);
            deque.PushLeft(6);

            deque.TryPopRight(out item);
            deque.PushRight(6);

            //Assert
            Assert.AreEqual(1, iterator.Current);

            Assert.True(iterator.MoveNext());
            Assert.AreEqual(2, iterator.Current);

            Assert.True(iterator.MoveNext());
            Assert.AreEqual(3, iterator.Current);

            Assert.False(iterator.MoveNext());
        }