示例#1
0
        public void NonEmptyDictionary()
        {
            Hashtable map = new Hashtable();

            map.Add(1, "one");
            map.Add(2, "two");
            map.Add(3, "three");

            ArrayList entryList = new ArrayList(DictionaryHelper.GetEntries(map));

            Assert.AreEqual(3, entryList.Count);

            DictionaryEntry first = Shift(entryList);

            Assert.AreEqual(first.Value, map[first.Key]);
            map.Remove(first.Key);

            DictionaryEntry second = Shift(entryList);

            Assert.AreEqual(second.Value, map[second.Key]);
            map.Remove(second.Key);

            DictionaryEntry third = Shift(entryList);

            Assert.AreEqual(third.Value, map[third.Key]);
            map.Remove(third.Key);

            Assert.AreEqual(0, map.Count);
            Assert.AreEqual(0, entryList.Count);
        }
        public void NonEmptyDictionary()
        {
            var map = new Hashtable
            {
                [1] = "one",
                [2] = "two",
                [3] = "three"
            };

            var entryList = new ArrayList(DictionaryHelper.GetEntries(map));

            Assert.AreEqual(3, entryList.Count);

            var first = Shift(entryList);

            Assert.AreEqual(first.Value, map[first.Key]);
            map.Remove(first.Key);

            var second = Shift(entryList);

            Assert.AreEqual(second.Value, map[second.Key]);
            map.Remove(second.Key);

            var third = Shift(entryList);

            Assert.AreEqual(third.Value, map[third.Key]);
            map.Remove(third.Key);

            Assert.AreEqual(0, map.Count);
            Assert.AreEqual(0, entryList.Count);
        }
        public void NullDictionaryYieldsZeroEntries()
        {
            var entries = DictionaryHelper.GetEntries(null);

            Assert.IsNotNull(entries);
            Assert.AreEqual(0, entries.Length);
        }
示例#4
0
        public void DisposableDictionaryEnumerator()
        {
            MockDictionary dict = new MockDictionary();

            dict.Add(1, "one");
            Assert.IsFalse(dict.EnumeratorDisposed);
            DictionaryHelper.GetEntries(dict);
            Assert.IsTrue(dict.EnumeratorDisposed);
        }
        public void DisposableDictionaryEnumerator()
        {
            var dict = new MockDictionary {
                { 1, "one" }
            };

            Assert.IsFalse(dict.EnumeratorDisposed);
            DictionaryHelper.GetEntries(dict);
            Assert.IsTrue(dict.EnumeratorDisposed);
        }
示例#6
0
 public void EmptyDictionaryYieldsZeroEntries()
 {
     DictionaryEntry[] entries = DictionaryHelper.GetEntries(new Hashtable());
     Assert.AreEqual(0, entries.Length);
 }