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

IndexOfKey() private méthode

private IndexOfKey ( ) : void
Résultat void
        public static void IndexOfKey()
        {
            SortedList sortList1 = Helpers.CreateStringSortedList(100);
            Helpers.PerformActionOnAllSortedListWrappers(sortList1, sortList2 =>
            {
                for (int i = 0; i < sortList2.Count; i++)
                {
                    string key = "Key_" + i.ToString("D2");
                    string value = "Value_" + i;

                    int index = sortList2.IndexOfKey(key);
                    Assert.Equal(i, index);
                    Assert.Equal(value, sortList2.GetByIndex(index));
                }

                Assert.Equal(-1, sortList2.IndexOfKey("Non Existent Key"));

                string removedKey = "Key_01";
                sortList2.Remove(removedKey);
                Assert.Equal(-1, sortList2.IndexOfKey(removedKey));
            });
        }
SortedListTests