提交 e77483aa 编写于 作者: J Jason Malinowski

Delete some of the PasteTrackingServiceTests

There were some tests that generally tested the behavior that "if you
close a document, the tracking span should go away". These tests weren't
actually working right:

1. The AssertMissingPastedTextSpan helper fetched the text container
   and passed that to the PasteTrackingService. If the documents had
   been closed, then the container returned is a throwaway container
   which isn't a text buffer at all. The PasteTrackingService returns
   no span, but it always would have no matter what. As such, this case
   meant this was less a test of the service and more a test of
   TestWorkspace that the buffer was closed when expected.
2. If the documents were open at time, a buffer might get reused by
   TestWorkspace. In those cases, the product code also has no code
   that was clearing the buffer properties out: the test code did.
   As such, those tests passing weren't asserting product behavior,
   they were just asserting the test harness behavior.

In practice, any attempt to resurrect these were really just tests about
the test harness or TestWorkspace, and not product code. So deleting
them is just the right thing.
上级 4c50abd9
......@@ -57,13 +57,13 @@ $$
<WpfFact>
<Trait(Traits.Feature, Traits.Features.PasteTracking)>
Public Async Function PasteTracking_MissingTextSpan_WhenNothingPasted() As Task
Public Sub PasteTracking_MissingTextSpan_WhenNothingPasted()
Using testState = New PasteTrackingTestState(SingleFileCode)
Dim class1Document = testState.OpenDocument(Project1Name, Class1Name)
Await testState.AssertMissingPastedTextSpanAsync(class1Document)
testState.AssertMissingPastedTextSpan(class1Document.GetTextBuffer())
End Using
End Function
End Sub
<WpfFact>
<Trait(Traits.Feature, Traits.Features.PasteTracking)>
......@@ -106,7 +106,7 @@ $$
<WpfFact>
<Trait(Traits.Feature, Traits.Features.PasteTracking)>
Public Async Function PasteTracking_MissingTextSpan_AfterPasteThenEdit() As Task
Public Sub PasteTracking_MissingTextSpan_AfterPasteThenEdit()
Using testState = New PasteTrackingTestState(SingleFileCode)
Dim class1Document = testState.OpenDocument(Project1Name, Class1Name)
......@@ -114,38 +114,9 @@ $$
testState.InsertText(class1Document, "Foo")
Await testState.AssertMissingPastedTextSpanAsync(class1Document)
testState.AssertMissingPastedTextSpan(class1Document.GetTextBuffer())
End Using
End Function
<WpfFact>
<Trait(Traits.Feature, Traits.Features.PasteTracking)>
Public Async Function PasteTracking_MissingTextSpan_AfterPasteThenClose() As Task
Using testState = New PasteTrackingTestState(SingleFileCode)
Dim class1Document = testState.OpenDocument(Project1Name, Class1Name)
testState.SendPaste(class1Document, PastedCode)
testState.CloseDocument(class1Document)
Await testState.AssertMissingPastedTextSpanAsync(class1Document)
End Using
End Function
<WpfFact>
<Trait(Traits.Feature, Traits.Features.PasteTracking)>
Public Async Function PasteTracking_MissingTextSpan_AfterPasteThenCloseThenOpen() As Task
Using testState = New PasteTrackingTestState(SingleFileCode)
Dim class1Document = testState.OpenDocument(Project1Name, Class1Name)
testState.SendPaste(class1Document, PastedCode)
testState.CloseDocument(class1Document)
testState.OpenDocument(class1Document)
Await testState.AssertMissingPastedTextSpanAsync(class1Document)
End Using
End Function
End Sub
<WpfFact>
<Trait(Traits.Feature, Traits.Features.PasteTracking)>
......@@ -190,31 +161,10 @@ $$
testState.SendPaste(class1Document, PastedCode)
Dim expectedClass2TextSpan = testState.SendPaste(class2Document, PastedCode)
testState.CloseDocument(class1Document)
Await testState.AssertMissingPastedTextSpanAsync(class1Document)
Await testState.AssertHasPastedTextSpanAsync(class2Document, expectedClass2TextSpan)
End Using
End Function
<WpfFact>
<Trait(Traits.Feature, Traits.Features.PasteTracking)>
Public Async Function PasteTracking_MissingTextSpan_AfterPasteInMultipleFilesThenAllClosed() As Task
Using testState = New PasteTrackingTestState(MultiFileCode)
Dim class1Document = testState.OpenDocument(Project1Name, Class1Name)
Dim class2Document = testState.OpenDocument(Project1Name, Class2Name)
testState.SendPaste(class1Document, PastedCode)
testState.SendPaste(class2Document, PastedCode)
testState.CloseDocument(class1Document)
testState.CloseDocument(class2Document)
Await testState.AssertMissingPastedTextSpanAsync(class1Document)
Await testState.AssertMissingPastedTextSpanAsync(class2Document)
End Using
End Function
<WpfFact>
<Trait(Traits.Feature, Traits.Features.PasteTracking)>
Public Async Function PasteTracking_HasTextSpanInLinkedFile_AfterPaste() As Task
......@@ -245,23 +195,7 @@ $$
<WpfFact>
<Trait(Traits.Feature, Traits.Features.PasteTracking)>
Public Async Function PasteTracking_MissingTextSpanForLinkedFile_AfterPasteThenCloseAll() As Task
Using testState = New PasteTrackingTestState(MultiFileCode)
Dim class1Document = testState.OpenDocument(Project1Name, Class1Name)
Dim class1LinkedDocument = testState.OpenDocument(Project2Name, Class1Name)
testState.SendPaste(class1Document, PastedCode)
testState.CloseDocument(class1Document)
testState.CloseDocument(class1LinkedDocument)
Await testState.AssertMissingPastedTextSpanAsync(class1LinkedDocument)
End Using
End Function
<WpfFact>
<Trait(Traits.Feature, Traits.Features.PasteTracking)>
Public Async Function PasteTracking_MissingTextSpan_AfterPasteThenLinkedFileEdited() As Task
Public Sub PasteTracking_MissingTextSpan_AfterPasteThenLinkedFileEdited()
Using testState = New PasteTrackingTestState(MultiFileCode)
Dim class1Document = testState.OpenDocument(Project1Name, Class1Name)
Dim class1LinkedDocument = testState.OpenDocument(Project2Name, Class1Name)
......@@ -269,10 +203,10 @@ $$
testState.SendPaste(class1Document, PastedCode)
testState.InsertText(class1LinkedDocument, "Foo")
Await testState.AssertMissingPastedTextSpanAsync(class1Document)
Await testState.AssertMissingPastedTextSpanAsync(class1LinkedDocument)
testState.AssertMissingPastedTextSpan(class1Document.GetTextBuffer())
testState.AssertMissingPastedTextSpan(class1LinkedDocument.GetTextBuffer())
End Using
End Function
End Sub
<WpfFact>
......@@ -287,8 +221,6 @@ $$
testState.CloseDocument(class1Document)
testState.CloseDocument(class1LinkedDocument)
Await testState.AssertMissingPastedTextSpanAsync(class1LinkedDocument)
testState.OpenDocument(class1LinkedDocument)
Dim expectedTextSpan = testState.SendPaste(class1LinkedDocument, PastedCode)
......
......@@ -56,21 +56,6 @@ Namespace Microsoft.CodeAnalysis.PasteTracking
Public Sub CloseDocument(hostDocument As TestHostDocument)
hostDocument.CloseTextView()
Workspace.CloseDocument(hostDocument.Id)
' When all documents sharing the same TextBuffer are closed
' the TextBuffer Properties should be cleared.
Dim textBufferClosed = Workspace.GetOpenDocumentIds().
All(Function(id) Workspace.GetTestDocument(id)?.GetTextBuffer() Is hostDocument.GetTextBuffer())
If textBufferClosed Then
ClearTextBufferProperties(hostDocument)
End If
End Sub
Private Sub ClearTextBufferProperties(testDocument As TestHostDocument)
Dim propertyKeys = testDocument.GetTextBuffer().Properties.PropertyList.Select(Function(kvp) kvp.Key)
For Each key In propertyKeys
testDocument.GetTextBuffer().Properties.RemoveProperty(key)
Next
End Sub
Public Sub InsertText(hostDocument As TestHostDocument, insertedText As String)
......@@ -116,13 +101,10 @@ Namespace Microsoft.CodeAnalysis.PasteTracking
Assert.Equal(textSpan, pastedTextSpan)
End Function
Public Async Function AssertMissingPastedTextSpanAsync(hostDocument As TestHostDocument) As Task
Dim document = Workspace.CurrentSolution.GetDocument(hostDocument.Id)
Dim sourceText = Await document.GetTextAsync()
Public Sub AssertMissingPastedTextSpan(textBuffer As ITextBuffer)
Dim textSpan As TextSpan
Assert.False(PasteTrackingService.TryGetPastedTextSpan(sourceText.Container, textSpan))
End Function
Assert.False(PasteTrackingService.TryGetPastedTextSpan(textBuffer.AsTextContainer(), textSpan))
End Sub
Private Sub Dispose() Implements IDisposable.Dispose
Workspace.Dispose()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册