Exemplo n.º 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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public void NullDictionaryYieldsZeroEntries()
        {
            var entries = DictionaryHelper.GetEntries(null);

            Assert.IsNotNull(entries);
            Assert.AreEqual(0, entries.Length);
        }
Exemplo n.º 4
0
        public void DisposableDictionaryEnumerator()
        {
            MockDictionary dict = new MockDictionary();

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

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