public void Enumerator()
        {
            var    dictionary = new WeakKeyDictionary <object, int>();
            object keepAlive1 = new object();
            object keepAlive2 = new object();

            dictionary[keepAlive1] = 0;
            Enumerator_Helper(dictionary);
            dictionary[keepAlive2] = 2;
            GC.Collect();

            var enumeratedContents = dictionary.ToList();

            Assert.Equal(2, enumeratedContents.Count);
            Assert.Contains(new KeyValuePair <object, int>(keepAlive1, 0), enumeratedContents);
            Assert.Contains(new KeyValuePair <object, int>(keepAlive2, 2), enumeratedContents);
        }
        public void Enumerator()
        {
            object keepAlive1 = new object();
            object keepAlive2 = new object();
            object collected  = new object();
            var    dictionary = new WeakKeyDictionary <object, int>();

            dictionary[keepAlive1] = 0;
            dictionary[collected]  = 1;
            dictionary[keepAlive2] = 2;
            collected = null;
            GC.Collect();

            var enumeratedContents = dictionary.ToList();

            Assert.Equal(2, enumeratedContents.Count);
            Assert.True(enumeratedContents.Contains(new KeyValuePair <object, int>(keepAlive1, 0)));
            Assert.True(enumeratedContents.Contains(new KeyValuePair <object, int>(keepAlive2, 2)));
        }