Пример #1
0
        public void GetKeys()
        {
            int[] random         = ArrayUtility.GenerateRandomIntArray(5, 1000);
            int[] sortedDistinct = ArrayUtility.GetSortedDistinct(random);

            KevinDictionary <int, string> kd           = new KevinDictionary <int, string>(100);
            SortedList <int, int>         originalKeys = new SortedList <int, int>();

            for (int i = 0; i < sortedDistinct.Length; i++)
            {
                kd.Put(sortedDistinct[i], sortedDistinct[i].ToString());
                originalKeys.Add(sortedDistinct[i], sortedDistinct[i]);
            }

            int[] keysFromDictionary = kd.Keys.ToArray();
            int[] sdk = ArrayUtility.GetSortedDistinct(keysFromDictionary);
            Assert.IsTrue(ArrayUtility.AreIntegerEnumerablesEqual(originalKeys.Values.ToArray(), sdk));

            for (int i = 0; i < sortedDistinct.Length; i++)
            {
                kd.Remove(sortedDistinct[i]);
                originalKeys.Remove(sortedDistinct[i]);

                keysFromDictionary = kd.Keys.ToArray();
                sdk = ArrayUtility.GetSortedDistinct(keysFromDictionary);

                Assert.IsTrue(ArrayUtility.AreIntegerEnumerablesEqual(originalKeys.Values.ToArray(), sdk));
            }
        }