public void MutableEnumerator() { var l = new UnorderedList <int>(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); using (var e = l.GetEnumerator()) while (e.MoveNext()) { if ((e.Current % 2) == 0) { e.RemoveCurrent(); } } Assert.AreEqual( new int[] { 1, 9, 3, 7, 5 }, l.ToArray() ); }
public void MutableEnumeratorRemoveCurrentAndGetNext() { var l = new UnorderedList <int>(); l.Add(1); l.Add(2); int item; using (var e = l.GetEnumerator()) while (e.GetNext(out item)) { e.RemoveCurrent(); } Assert.AreEqual( new int[] { }, l.ToArray() ); }