System.Linq.Tests.WhereTests.Where_SourceThrowsOnConcurrentModification C# (CSharp) Method

Where_SourceThrowsOnConcurrentModification() private method

private Where_SourceThrowsOnConcurrentModification ( ) : void
return void
        public void Where_SourceThrowsOnConcurrentModification()
        {
            List<int> source = new List<int>() { 1, 2, 3, 4, 5 };
            Func<int, bool> truePredicate = (value) => true;

            var enumerator = source.Where(truePredicate).GetEnumerator();

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

            source.Add(6);
            Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext());
        }
WhereTests