提交 5df20a96 编写于 作者: J Jason Malinowski

Fix issue where tests were creating TestWorkspaces during test disposal

TestWorkspaceFixture is a type you can use to have a single
TestWorkspace be shared between multiple tests. To ensure that the
TestWorkspace doesn't end up with views being opened between tests,
many tests in their dispose method call CloseTextView(). This was
calling GetWorkspace(), which creates the workspace lazily, so in some
cases we'd create a test when we didn't expect it. Since this was
happening in xUnit's Dispose() handling, there wasn't a synchronization
context which is now required due to 0911290b06184eb.
上级 80321de9
......@@ -64,7 +64,9 @@ private static void UpdateText(ITextBuffer textBuffer, string text)
public void CloseTextView()
{
GetWorkspace().Documents.Single().CloseTextView();
// The standard use for TestWorkspaceFixture is to call this method in the test's dispose to make sure it's ready to be used for
// the next test. But some tests in a test class won't use it, so _workspace might still be null.
_workspace?.Documents.Single().CloseTextView();
// The editor caches TextFormattingRunProperties instances for better perf, but since things like
// Brushes are DispatcherObjects, they are tied to the thread they are created on. Since we're going
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册