Пример #1
0
        public void DocumentDoesNotHoldReferenceToTextEditor()
        {
            bool collectedTextEditor = false;
            TextDocument textDocument = new TextDocument();

            TextEditor textEditor = new TextEditorWithGCCallback(delegate { collectedTextEditor = true; });
            textEditor.Document = textDocument;
            textEditor = null;

            GarbageCollect();
            Assert.IsTrue(collectedTextEditor);
            GC.KeepAlive(textDocument);
        }
Пример #2
0
        public void DocumentDoesNotHoldReferenceToTextEditor()
        {
            bool         collectedTextEditor = false;
            TextDocument textDocument        = new TextDocument();

            TextEditor textEditor = new TextEditorWithGCCallback(delegate { collectedTextEditor = true; });

            textEditor.Document = textDocument;
            textEditor          = null;

            GarbageCollect();
            Assert.IsTrue(collectedTextEditor);
            GC.KeepAlive(textDocument);
        }