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); }