Esempio n. 1
0
        public void Add_does_not_cause_concurrent_modifications()
        {
            var list = new CopyOnWriteList <int> {
                1, 2, 3
            };
            var e = list.GetEnumerator();

            // Adding an item should not cause concurrent modifications
            list.Add(4);
            Assert.DoesNotThrow(() => e.MoveNext());
        }
Esempio n. 2
0
        public void Add_does_not_enumerate_added_items()
        {
            var list = new CopyOnWriteList <int> {
                1, 2, 3
            };
            var e = list.GetEnumerator();

            Assert.True(e.MoveNext());
            Assert.Equal(1, e.Current);

            // Adding an item should not cause concurrent modifications
            list.Add(4);
            Assert.DoesNotThrow(() => e.MoveNext());
            Assert.Equal(2, e.Current);

            Assert.True(e.MoveNext());
            Assert.Equal(3, e.Current);

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