提交 2bed76f6 编写于 作者: G Gen Lu

Add tests

上级 078ed21e
......@@ -37,13 +37,13 @@ protected override TestWorkspace CreateWorkspace(string fileContents)
string expectedItemOrNull, string expectedDescriptionOrNull,
SourceCodeKind sourceCodeKind, bool usePreviousCharAsTrigger, bool checkForAbsence,
int? glyph, int? matchPriority, bool? hasSuggestionItem, string displayTextSuffix,
string inlineDescription = null, List<CompletionFilter> matchingFilters = null)
string inlineDescription = null, List<CompletionFilter> matchingFilters = null, CompletionItemFlags? flags = null)
{
return base.VerifyWorkerAsync(
code, position, expectedItemOrNull, expectedDescriptionOrNull,
sourceCodeKind, usePreviousCharAsTrigger, checkForAbsence,
glyph, matchPriority, hasSuggestionItem, displayTextSuffix,
inlineDescription, matchingFilters);
inlineDescription, matchingFilters, flags);
}
private protected override async Task VerifyWorkerAsync(
......@@ -52,7 +52,7 @@ protected override TestWorkspace CreateWorkspace(string fileContents)
SourceCodeKind sourceCodeKind, bool usePreviousCharAsTrigger,
bool checkForAbsence, int? glyph, int? matchPriority,
bool? hasSuggestionItem, string displayTextSuffix, string inlineDescription = null,
List<CompletionFilter> matchingFilters = null)
List<CompletionFilter> matchingFilters = null, CompletionItemFlags? flags = null)
{
await VerifyAtPositionAsync(code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind, checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription, matchingFilters);
await VerifyInFrontOfCommentAsync(code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind, checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription, matchingFilters);
......@@ -87,7 +87,7 @@ protected override string ItemPartiallyWritten(string expectedItemOrNull)
code, position, expectedItemOrNull, expectedDescriptionOrNull,
sourceCodeKind, usePreviousCharAsTrigger, checkForAbsence, glyph,
matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription,
matchingFilters);
matchingFilters, flags: null);
}
private Task VerifyInFrontOfCommentAsync(
......
......@@ -35,17 +35,17 @@ internal override CompletionProvider CreateCompletionProvider()
string expectedItemOrNull, string expectedDescriptionOrNull,
SourceCodeKind sourceCodeKind, bool usePreviousCharAsTrigger, bool checkForAbsence,
int? glyph, int? matchPriority, bool? hasSuggestionItem, string displayTextSuffix,
string inlineDescription = null, List<CompletionFilter> matchingFilters = null)
string inlineDescription = null, List<CompletionFilter> matchingFilters = null, CompletionItemFlags? flags = null)
{
await VerifyAtPositionAsync(
code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind,
checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription,
matchingFilters);
matchingFilters, flags);
await VerifyAtEndOfFileAsync(
code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind,
checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription,
matchingFilters);
matchingFilters, flags);
// Items cannot be partially written if we're checking for their absence,
// or if we're verifying that the list will show up (without specifying an actual item)
......
......@@ -35,13 +35,13 @@ protected override IEqualityComparer<string> GetStringComparer()
string code, int position, string expectedItemOrNull, string expectedDescriptionOrNull,
SourceCodeKind sourceCodeKind, bool usePreviousCharAsTrigger, bool checkForAbsence,
int? glyph, int? matchPriority, bool? hasSuggestionItem, string displayTextSuffix,
string inlineDescription = null, List<CompletionFilter> matchingFilters = null)
string inlineDescription = null, List<CompletionFilter> matchingFilters = null, CompletionItemFlags? flags = null)
{
return BaseVerifyWorkerAsync(
code, position, expectedItemOrNull, expectedDescriptionOrNull,
sourceCodeKind, usePreviousCharAsTrigger, checkForAbsence,
glyph, matchPriority, hasSuggestionItem, displayTextSuffix,
inlineDescription, matchingFilters);
inlineDescription, matchingFilters, flags);
}
[Fact]
......
......@@ -40,13 +40,13 @@ protected override IEqualityComparer<string> GetStringComparer()
string code, int position, string expectedItemOrNull, string expectedDescriptionOrNull,
SourceCodeKind sourceCodeKind, bool usePreviousCharAsTrigger, bool checkForAbsence,
int? glyph, int? matchPriority, bool? hasSuggestionItem, string displayTextSuffix,
string inlineDescription = null, List<CompletionFilter> matchingFilters = null)
string inlineDescription = null, List<CompletionFilter> matchingFilters = null, CompletionItemFlags? flags = null)
{
return BaseVerifyWorkerAsync(
code, position, expectedItemOrNull, expectedDescriptionOrNull,
sourceCodeKind, usePreviousCharAsTrigger, checkForAbsence,
glyph, matchPriority, hasSuggestionItem, displayTextSuffix,
inlineDescription, matchingFilters);
inlineDescription, matchingFilters, flags);
}
[Fact]
......
......@@ -32,13 +32,13 @@ internal override CompletionProvider CreateCompletionProvider()
string code, int position, string expectedItemOrNull, string expectedDescriptionOrNull,
SourceCodeKind sourceCodeKind, bool usePreviousCharAsTrigger, bool checkForAbsence,
int? glyph, int? matchPriority, bool? hasSuggestionItem, string displayTextSuffix,
string inlineDescription, List<CompletionFilter> matchingFilters)
string inlineDescription, List<CompletionFilter> matchingFilters, CompletionItemFlags? flags = null)
{
return base.VerifyWorkerAsync(code, position,
expectedItemOrNull, expectedDescriptionOrNull,
SourceCodeKind.Regular, usePreviousCharAsTrigger, checkForAbsence,
glyph, matchPriority, hasSuggestionItem, displayTextSuffix,
inlineDescription, matchingFilters);
inlineDescription, matchingFilters, flags);
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
......
......@@ -928,7 +928,7 @@ class Program { }
}";
var markup = CreateMarkupForSingleProject(file2, file1, LanguageNames.CSharp);
await VerifyTypeImportItemExistsAsync(markup, "My", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.MyAttribute");
await VerifyTypeImportItemExistsAsync(markup, "My", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.MyAttribute", flags: CompletionItemFlags.Expanded);
await VerifyTypeImportItemIsAbsentAsync(markup, "MyAttributeWithoutSuffix", inlineDescription: "Foo"); // We intentionally ignore attribute types without proper suffix for perf reason
await VerifyTypeImportItemIsAbsentAsync(markup, "MyAttribute", inlineDescription: "Foo");
await VerifyTypeImportItemIsAbsentAsync(markup, "MyClass", inlineDescription: "Foo");
......@@ -988,10 +988,10 @@ class Program
}";
var markup = CreateMarkupForSingleProject(file2, file1, LanguageNames.CSharp);
await VerifyTypeImportItemExistsAsync(markup, "MyAttribute", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.MyAttribute");
await VerifyTypeImportItemExistsAsync(markup, "MyAttributeWithoutSuffix", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.MyAttributeWithoutSuffix");
await VerifyTypeImportItemExistsAsync(markup, "MyAttribute", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.MyAttribute", flags: CompletionItemFlags.CachedAndExpanded);
await VerifyTypeImportItemExistsAsync(markup, "MyAttributeWithoutSuffix", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.MyAttributeWithoutSuffix", flags: CompletionItemFlags.CachedAndExpanded);
await VerifyTypeImportItemIsAbsentAsync(markup, "My", inlineDescription: "Foo");
await VerifyTypeImportItemExistsAsync(markup, "MyClass", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.MyClass");
await VerifyTypeImportItemExistsAsync(markup, "MyClass", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.MyClass", flags: CompletionItemFlags.CachedAndExpanded);
}
[InlineData(SourceCodeKind.Regular)]
......@@ -1049,7 +1049,7 @@ class Program { }
}";
var markup = CreateMarkupForSingleProject(file2, file1, LanguageNames.CSharp);
await VerifyTypeImportItemExistsAsync(markup, "Myattribute", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.Myattribute");
await VerifyTypeImportItemExistsAsync(markup, "Myattribute", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.Myattribute", flags: CompletionItemFlags.CachedAndExpanded);
await VerifyTypeImportItemIsAbsentAsync(markup, "My", inlineDescription: "Foo");
await VerifyTypeImportItemIsAbsentAsync(markup, "MyClass", inlineDescription: "Foo");
}
......@@ -1109,9 +1109,9 @@ class Program
}";
var markup = CreateMarkupForSingleProject(file2, file1, LanguageNames.CSharp);
await VerifyTypeImportItemExistsAsync(markup, "Myattribute", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.Myattribute");
await VerifyTypeImportItemExistsAsync(markup, "Myattribute", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.Myattribute", flags: CompletionItemFlags.Expanded);
await VerifyTypeImportItemIsAbsentAsync(markup, "My", inlineDescription: "Foo");
await VerifyTypeImportItemExistsAsync(markup, "MyClass", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.MyClass");
await VerifyTypeImportItemExistsAsync(markup, "MyClass", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.MyClass", flags: CompletionItemFlags.CachedAndExpanded);
}
[InlineData(SourceCodeKind.Regular)]
......@@ -1174,7 +1174,7 @@ class Program
var markup = CreateMarkupForProjecWithProjectReference(file2, file1, LanguageNames.CSharp, LanguageNames.VisualBasic);
await VerifyTypeImportItemExistsAsync(markup, "Myattribute", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.Myattribute");
await VerifyTypeImportItemExistsAsync(markup, "Myattribute", glyph: (int)Glyph.ClassPublic, inlineDescription: "Foo", expectedDescriptionOrNull: "class Foo.Myattribute", flags: CompletionItemFlags.Expanded);
await VerifyTypeImportItemIsAbsentAsync(markup, "My", inlineDescription: "Foo");
await VerifyTypeImportItemIsAbsentAsync(markup, "MyVBClass", inlineDescription: "Foo");
}
......@@ -1307,9 +1307,9 @@ private static void AssertRelativeOrder(List<string> expectedTypesInRelativeOrde
}
}
private Task VerifyTypeImportItemExistsAsync(string markup, string expectedItem, int glyph, string inlineDescription, string displayTextSuffix = null, string expectedDescriptionOrNull = null)
private Task VerifyTypeImportItemExistsAsync(string markup, string expectedItem, int glyph, string inlineDescription, string displayTextSuffix = null, string expectedDescriptionOrNull = null, CompletionItemFlags? flags = null)
{
return VerifyItemExistsAsync(markup, expectedItem, displayTextSuffix: displayTextSuffix, glyph: glyph, inlineDescription: inlineDescription, expectedDescriptionOrNull: expectedDescriptionOrNull);
return VerifyItemExistsAsync(markup, expectedItem, displayTextSuffix: displayTextSuffix, glyph: glyph, inlineDescription: inlineDescription, expectedDescriptionOrNull: expectedDescriptionOrNull, flags: flags);
}
......
......@@ -45,18 +45,18 @@ private async Task VerifyItemsAbsentAsync(string markup, params string[] items)
string code, int position, string expectedItemOrNull, string expectedDescriptionOrNull,
SourceCodeKind sourceCodeKind, bool usePreviousCharAsTrigger, bool checkForAbsence,
int? glyph, int? matchPriority, bool? hasSuggestionItem, string displayTextSuffix,
string inlineDescription = null, List<CompletionFilter> matchingFilters = null)
string inlineDescription = null, List<CompletionFilter> matchingFilters = null, CompletionItemFlags? flags = null)
{
// We don't need to try writing comments in from of items in doc comments.
await VerifyAtPositionAsync(
code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind,
checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription,
matchingFilters);
matchingFilters, flags);
await VerifyAtEndOfFileAsync(
code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind,
checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription,
matchingFilters);
matchingFilters, flags);
// Items cannot be partially written if we're checking for their absence,
// or if we're verifying that the list will show up (without specifying an actual item)
......@@ -65,12 +65,12 @@ private async Task VerifyItemsAbsentAsync(string markup, params string[] items)
await VerifyAtPosition_ItemPartiallyWrittenAsync(
code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull,
sourceCodeKind, checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix,
inlineDescription, matchingFilters);
inlineDescription, matchingFilters, flags);
await VerifyAtEndOfFile_ItemPartiallyWrittenAsync(
code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull,
sourceCodeKind, checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix,
inlineDescription, matchingFilters);
inlineDescription, matchingFilters, flags);
}
}
......
......@@ -34,12 +34,12 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Completion.Complet
sourceCodeKind As SourceCodeKind, usePreviousCharAsTrigger As Boolean,
checkForAbsence As Boolean, glyph As Integer?, matchPriority As Integer?,
hasSuggestionItem As Boolean?, displayTextSuffix As String, inlineDescription As String,
matchingFilters As List(Of CompletionFilter)) As Task
matchingFilters As List(Of CompletionFilter), flags As CompletionItemFlags?) As Task
Return MyBase.VerifyWorkerAsync(
code, position, expectedItemOrNull, expectedDescriptionOrNull,
sourceCodeKind, usePreviousCharAsTrigger, checkForAbsence,
glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription,
matchingFilters)
matchingFilters, flags)
End Function
Private Protected Overrides Async Function VerifyWorkerAsync(
......@@ -48,7 +48,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Completion.Complet
sourceCodeKind As SourceCodeKind, usePreviousCharAsTrigger As Boolean,
checkForAbsence As Boolean, glyph As Integer?, matchPriority As Integer?,
hasSuggestionItem As Boolean?, displayTextSuffix As String, inlineDescription As String,
matchingFilters As List(Of CompletionFilter)) As Task
matchingFilters As List(Of CompletionFilter), flags As CompletionItemFlags?) As Task
' Script/interactive support removed for now.
' TODO: Re-enable these when interactive is back in the product.
If sourceCodeKind <> Microsoft.CodeAnalysis.SourceCodeKind.Regular Then
......@@ -58,12 +58,12 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Completion.Complet
Await VerifyAtPositionAsync(
code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind,
checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription,
matchingFilters)
matchingFilters, flags)
Await VerifyAtEndOfFileAsync(
code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind,
checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription,
matchingFilters)
matchingFilters, flags)
' Items cannot be partially written if we're checking for their absence,
' or if we're verifying that the list will show up (without specifying an actual item)
......
......@@ -22,7 +22,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Completion.Complet
sourceCodeKind As SourceCodeKind, usePreviousCharAsTrigger As Boolean,
checkForAbsence As Boolean, glyph As Integer?, matchPriority As Integer?,
hasSuggestionItem As Boolean?, displayTextSuffix As String, inlineDescription As String,
matchingFilters As List(Of CompletionFilter)) As Task
matchingFilters As List(Of CompletionFilter), flags As CompletionItemFlags?) As Task
' Script/interactive support removed for now.
' TODO: Re-enable these when interactive is back in the product.
If sourceCodeKind <> SourceCodeKind.Regular Then
......@@ -33,7 +33,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Completion.Complet
code, position, expectedItemOrNull, expectedDescriptionOrNull,
sourceCodeKind, usePreviousCharAsTrigger, checkForAbsence, glyph,
matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription,
matchingFilters)
matchingFilters, flags)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Completion)>
......
......@@ -568,7 +568,7 @@ End Class</a>.Value
Dim position As Integer
MarkupTestFile.GetPosition(markup.NormalizeLineEndings(), code, position)
Await BaseVerifyWorkerAsync(code, position, "[Class]()", "Sub CBase.Class()", SourceCodeKind.Regular, False, False, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
Await BaseVerifyWorkerAsync(code, position, "[Class]()", "Sub CBase.Class()", SourceCodeKind.Regular, False, False, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
......@@ -589,7 +589,7 @@ End Class</a>.Value
Await BaseVerifyWorkerAsync(
code, position, "[Class]", "Property CBase.Class As Integer",
SourceCodeKind.Regular, False, False, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
SourceCodeKind.Regular, False, False, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
......
......@@ -7818,10 +7818,10 @@ End Namespace
Dim position = workspace.DocumentWithCursor.CursorPosition.Value
Await CheckResultsAsync(document, position, "InstanceMethod", expectedDescriptionOrNull:=Nothing, usePreviousCharAsTrigger:=False, checkForAbsence:=False,
glyph:=Nothing, matchPriority:=Nothing, hasSuggestionModeItem:=Nothing, displayTextSuffix:=Nothing, inlineDescription:=Nothing,
matchingFilters:=Nothing)
matchingFilters:=Nothing, flags:=Nothing)
Await CheckResultsAsync(document, position, "SharedMethod", expectedDescriptionOrNull:=Nothing, usePreviousCharAsTrigger:=False, checkForAbsence:=False,
glyph:=Nothing, matchPriority:=Nothing, hasSuggestionModeItem:=Nothing, displayTextSuffix:=Nothing, inlineDescription:=Nothing,
matchingFilters:=Nothing)
matchingFilters:=Nothing, flags:=Nothing)
End Using
End Function
......
......@@ -27,9 +27,9 @@ Namespace Tests
sourceCodeKind As SourceCodeKind, usePreviousCharAsTrigger As Boolean,
checkForAbsence As Boolean, glyph As Integer?, matchPriority As Integer?,
hasSuggestionItem As Boolean?, displayTextSuffix As String, inlineDescription As String,
matchingFilters As List(Of CompletionFilter)) As Task
Await VerifyAtPositionAsync(code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind, checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription, matchingFilters)
Await VerifyAtEndOfFileAsync(code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind, checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription, matchingFilters)
matchingFilters As List(Of CompletionFilter), flags As CompletionItemFlags?) As Task
Await VerifyAtPositionAsync(code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind, checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription, matchingFilters, flags)
Await VerifyAtEndOfFileAsync(code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind, checkForAbsence, glyph, matchPriority, hasSuggestionItem, displayTextSuffix, inlineDescription, matchingFilters, flags)
End Function
Private Async Function VerifyItemsExistAsync(markup As String, ParamArray items() As String) As Task
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册