Exemplo n.º 1
0
        public void WeakToWeak()
        {
            WeakCollectionChangedList list = new WeakCollectionChangedList();

            _proxyForWeakToWeakTest = new ListProxy(list);

            Assert.True(list.AddObject(), "GC hasn't run");

            GC.Collect();
            GC.WaitForPendingFinalizers();

            Assert.IsTrue(list.AddObject(), "GC run, but proxy should still hold a reference");

            _proxyForWeakToWeakTest = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();

            Assert.IsFalse(list.AddObject(), "Proxy is gone and GC has run");
        }
Exemplo n.º 2
0
        public void WeakToWeak()
        {
            WeakCollectionChangedList list = new WeakCollectionChangedList();
            var proxy = new ListProxy(list);

            Assert.True(list.AddObject());

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            Assert.IsTrue(list.AddObject());

            proxy = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            Assert.IsFalse(list.AddObject());
        }