コード例 #1
0
        public void CopyToTest()
        {
            KeyValuePair <int, int>[] array;

            using (FileBackedDictionary <int, int> dictionary = new FileBackedDictionary <int, int>())
            {
                for (int i = 1; i <= 100; i++)
                {
                    dictionary.Add(i, i);
                }

                Assert.AreEqual(dictionary.Count, 100);

                array = new KeyValuePair <int, int> [dictionary.Count];
                dictionary.CopyTo(array, 0);

                foreach (KeyValuePair <int, int> kvp in array)
                {
                    Assert.IsTrue(dictionary.Contains(kvp), kvp.Key.ToString());
                    Assert.AreEqual(dictionary[kvp.Key], kvp.Value);
                }
            }
        }
コード例 #2
0
ファイル: FileBackedDictionaryTest.cs プロジェクト: rmc00/gsf
        public void CopyToTest()
        {
            KeyValuePair<int, int>[] array;

            using (FileBackedDictionary<int, int> dictionary = new FileBackedDictionary<int, int>())
            {
                for (int i = 1; i <= 100; i++)
                    dictionary.Add(i, i);

                Assert.AreEqual(dictionary.Count, 100);

                array = new KeyValuePair<int, int>[dictionary.Count];
                dictionary.CopyTo(array, 0);

                foreach (KeyValuePair<int, int> kvp in array)
                {
                    Assert.IsTrue(dictionary.Contains(kvp), kvp.Key.ToString());
                    Assert.AreEqual(dictionary[kvp.Key], kvp.Value);
                }
            }
        }