Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
064585c0
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
064585c0
编写于
10月 23, 2018
作者:
Š
Šimon Koníček
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "Updating test infrastructure to support different insertion characters"
This reverts commit
300b4d35
.
上级
a519cdc0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
36 deletion
+35
-36
src/EditorFeatures/CSharpTest/FixInterpolatedVerbatimString/FixInterpolatedVerbatimStringCommandHandlerTests.cs
...tring/FixInterpolatedVerbatimStringCommandHandlerTests.cs
+35
-36
未找到文件。
src/EditorFeatures/CSharpTest/FixInterpolatedVerbatimString/FixInterpolatedVerbatimStringCommandHandlerTests.cs
浏览文件 @
064585c0
...
...
@@ -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
inserted
CharSnapshotText
=
default
;
int
inserted
CharCaretPosition
=
default
;
string
quote
CharSnapshotText
=
default
;
int
quote
CharCaretPosition
=
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
,
inserted
CharCaretPosition
);
return
(
quoteCharSnapshotText
,
quote
CharCaretPosition
);
}
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
(
inserted
CharSnapshotText
,
view
.
TextBuffer
.
CurrentSnapshot
.
GetText
());
Assert
.
Equal
(
inserted
CharCaretPosition
,
view
.
Caret
.
Position
.
BufferPosition
.
Position
);
// Ensure that after undo, the ordering fix is undone but the
quote
remains inserted
Assert
.
Equal
(
quote
CharSnapshotText
,
view
.
TextBuffer
.
CurrentSnapshot
.
GetText
());
Assert
.
Equal
(
quote
CharCaretPosition
,
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
(
inserted
CharSnapshotText
,
view
.
TextBuffer
.
CurrentSnapshot
.
GetText
());
Assert
.
Equal
(
inserted
CharCaretPosition
,
view
.
Caret
.
Position
.
BufferPosition
.
Position
);
Assert
.
Equal
(
quote
CharSnapshotText
,
view
.
TextBuffer
.
CurrentSnapshot
.
GetText
());
Assert
.
Equal
(
quote
CharCaretPosition
,
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录