System.Collections.Tests.SortedListTests.GetKeyList_GetEnumerator_Invalid C# (CSharp) Méthode

GetKeyList_GetEnumerator_Invalid() private méthode

private GetKeyList_GetEnumerator_Invalid ( ) : void
Résultat void
        public static void GetKeyList_GetEnumerator_Invalid()
        {
            SortedList sortList1 = Helpers.CreateIntSortedList(100);
            Helpers.PerformActionOnAllSortedListWrappers(sortList1, sortList2 =>
            {
                IList keys = sortList2.GetKeyList();
                // If the underlying collection is modified, MoveNext, Reset, Entry, Key and Value throw, but Current etc. doesn't
                IEnumerator enumerator = keys.GetEnumerator();
                enumerator.MoveNext();
                sortList2.Add(101, 101);

                Assert.NotNull(enumerator.Current);
                Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext());
                Assert.Throws<InvalidOperationException>(() => enumerator.Reset());

                // Current etc. throw if index < 0
                enumerator = keys.GetEnumerator();
                Assert.Throws<InvalidOperationException>(() => enumerator.Current);

                // Current etc. throw after resetting
                enumerator = keys.GetEnumerator();
                enumerator.MoveNext();

                enumerator.Reset();
                Assert.Throws<InvalidOperationException>(() => enumerator.Current);

                // Current etc. throw if the current index is >= count
                enumerator = keys.GetEnumerator();
                while (enumerator.MoveNext()) ;
                Assert.False(enumerator.MoveNext());
                Assert.Throws<InvalidOperationException>(() => enumerator.Current);
            });
        }
SortedListTests