提交 064585c0 编写于 作者: Š Šimon Koníček

Revert "Updating test infrastructure to support different insertion characters"

This reverts commit 300b4d35.
上级 a519cdc0
......@@ -29,34 +29,33 @@ private static TestWorkspace CreateTestWorkspace(string inputMarkup)
return workspace;
}
private static (string insertedCharSnapshotText, int insertedCharCaretPosition) TypeChar(TestWorkspace workspace, char ch)
private static (string quoteCharSnapshotText, int quoteCharCaretPosition) TypeQuoteChar(TestWorkspace workspace)
{
var view = workspace.Documents.Single().GetTextView();
var commandHandler = new FixInterpolatedVerbatimStringCommandHandler();
string insertedCharSnapshotText = default;
int insertedCharCaretPosition = default;
string quoteCharSnapshotText = default;
int quoteCharCaretPosition = default;
commandHandler.ExecuteCommand(new TypeCharCommandArgs(view, view.TextBuffer, ch),
commandHandler.ExecuteCommand(new TypeCharCommandArgs(view, view.TextBuffer, '"'),
() =>
{
var editorOperations = workspace.GetService<IEditorOperationsFactoryService>().GetEditorOperations(view);
editorOperations.InsertText(ch.ToString());
editorOperations.InsertText("\"");
// We want to get the snapshot after the character was inserted, but before the command is executed
insertedCharSnapshotText = view.TextBuffer.CurrentSnapshot.GetText();
insertedCharCaretPosition = view.Caret.Position.BufferPosition.Position;
quoteCharSnapshotText = view.TextBuffer.CurrentSnapshot.GetText();
quoteCharCaretPosition = view.Caret.Position.BufferPosition.Position;
}, TestCommandExecutionContext.Create());
return (insertedCharSnapshotText, insertedCharCaretPosition);
return (quoteCharSnapshotText, quoteCharCaretPosition);
}
private static void TestHandled(char insertedChar, string inputMarkup, string expectedOutputMarkup)
private static void TestHandled(string inputMarkup, string expectedOutputMarkup)
{
using (var workspace = CreateTestWorkspace(inputMarkup))
{
var (insertedCharSnapshotText, insertedCharCaretPosition) = TypeChar(workspace, insertedChar);
var (quoteCharSnapshotText, quoteCharCaretPosition) = TypeQuoteChar(workspace);
var view = workspace.Documents.Single().GetTextView();
MarkupTestFile.GetSpans(expectedOutputMarkup,
......@@ -68,13 +67,13 @@ private static void TestHandled(char insertedChar, string inputMarkup, string ex
var history = workspace.GetService<ITextUndoHistoryRegistry>().GetHistory(view.TextBuffer);
history.Undo(count: 1);
// Ensure that after undo, the ordering fix is undone but the typed character remains inserted
Assert.Equal(insertedCharSnapshotText, view.TextBuffer.CurrentSnapshot.GetText());
Assert.Equal(insertedCharCaretPosition, view.Caret.Position.BufferPosition.Position);
// Ensure that after undo, the ordering fix is undone but the quote remains inserted
Assert.Equal(quoteCharSnapshotText, view.TextBuffer.CurrentSnapshot.GetText());
Assert.Equal(quoteCharCaretPosition, view.Caret.Position.BufferPosition.Position);
}
}
private static void TestNotHandled(char insertedChar, string inputMarkup)
private static void TestNotHandled(string inputMarkup)
{
using (var workspace = CreateTestWorkspace(inputMarkup))
{
......@@ -82,16 +81,16 @@ private static void TestNotHandled(char insertedChar, string inputMarkup)
var originalSnapshotText = originalView.TextBuffer.CurrentSnapshot.GetText();
var originalCaretPosition = originalView.Caret.Position.BufferPosition.Position;
var (insertedCharSnapshotText, insertedCharCaretPosition) = TypeChar(workspace, insertedChar);
var (quoteCharSnapshotText, quoteCharCaretPosition) = TypeQuoteChar(workspace);
var view = workspace.Documents.Single().GetTextView();
Assert.Equal(insertedCharSnapshotText, view.TextBuffer.CurrentSnapshot.GetText());
Assert.Equal(insertedCharCaretPosition, view.Caret.Position.BufferPosition.Position);
Assert.Equal(quoteCharSnapshotText, view.TextBuffer.CurrentSnapshot.GetText());
Assert.Equal(quoteCharCaretPosition, view.Caret.Position.BufferPosition.Position);
var history = workspace.GetService<ITextUndoHistoryRegistry>().GetHistory(view.TextBuffer);
history.Undo(count: 1);
// Ensure that after undo, the typed character is removed because the command made no changes
// Ensure that after undo, the quote is removed because the command made no changes
Assert.Equal(originalSnapshotText, view.TextBuffer.CurrentSnapshot.GetText());
Assert.Equal(originalCaretPosition, view.Caret.Position.BufferPosition.Position);
}
......@@ -100,7 +99,7 @@ private static void TestNotHandled(char insertedChar, string inputMarkup)
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestAfterAtSignDollarSign()
{
TestHandled('"',
TestHandled(
@"class C
{
void M()
......@@ -120,7 +119,7 @@ void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingAfterDollarSignAtSign()
{
TestNotHandled('"',
TestNotHandled(
@"class C
{
void M()
......@@ -133,7 +132,7 @@ void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingAfterAtSign()
{
TestNotHandled('"',
TestNotHandled(
@"class C
{
void M()
......@@ -146,7 +145,7 @@ void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingAfterDollarSign()
{
TestNotHandled('"',
TestNotHandled(
@"class C
{
void M()
......@@ -159,25 +158,25 @@ void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingInEmptyFileAfterAtSignDollarSign()
{
TestNotHandled('"', @"@$[||]");
TestNotHandled(@"@$[||]");
}
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingInEmptyFileAfterDollarSign()
{
TestNotHandled('"', @"$[||]");
TestNotHandled(@"$[||]");
}
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingInEmptyFile()
{
TestNotHandled('"', @"[||]");
TestNotHandled(@"[||]");
}
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestAfterAtSignDollarSignEndOfFile()
{
TestHandled('"',
TestHandled(
@"class C
{
void M()
......@@ -193,7 +192,7 @@ void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingInClassDeclaration()
{
TestNotHandled('"',
TestNotHandled(
@"class C
{
@$[||]
......@@ -203,7 +202,7 @@ public void TestMissingInClassDeclaration()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingInComment1()
{
TestNotHandled('"',
TestNotHandled(
@"class C
{
void M()
......@@ -216,7 +215,7 @@ void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingInComment2()
{
TestNotHandled('"',
TestNotHandled(
@"class C
{
void M()
......@@ -229,7 +228,7 @@ void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingInString()
{
TestNotHandled('"',
TestNotHandled(
@"class C
{
void M()
......@@ -242,7 +241,7 @@ void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingInVerbatimString()
{
TestNotHandled('"',
TestNotHandled(
@"class C
{
void M()
......@@ -255,7 +254,7 @@ void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingInInterpolatedString()
{
TestNotHandled('"',
TestNotHandled(
@"class C
{
void M()
......@@ -268,7 +267,7 @@ void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingInInterpolatedVerbatimString1()
{
TestNotHandled('"',
TestNotHandled(
@"class C
{
void M()
......@@ -281,7 +280,7 @@ void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestMissingInInterpolatedVerbatimString2()
{
TestNotHandled('"',
TestNotHandled(
@"class C
{
void M()
......@@ -294,7 +293,7 @@ void M()
[WpfFact, Trait(Traits.Feature, Traits.Features.FixInterpolatedVerbatimString)]
public void TestTrivia()
{
TestHandled('"',
TestHandled(
@"class C
{
void M()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册