提交 37f8654d 编写于 作者: B Brett Forsgren

update unit tests to use localized resources

上级 75935b04
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.CodeRefactorings.GenerateFromMembers.AddConstructorParameters;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Test.Utilities;
using Xunit;
......@@ -57,7 +54,7 @@ public void TestSmartTagDisplayText1()
{
TestSmartTagText(
@"using System . Collections . Generic ; class Program { [|bool b ; HashSet < string > s ;|] public Program ( bool b ) { this . b = b ; } } ",
@"Add parameters to 'Program(bool)'",
string.Format(FeaturesResources.AddParametersTo, "Program", "bool"),
index: 0);
}
......@@ -66,7 +63,7 @@ public void TestSmartTagDisplayText2()
{
TestSmartTagText(
@"using System . Collections . Generic ; class Program { [|bool b ; HashSet < string > s ;|] public Program ( bool b ) { this . b = b ; } } ",
@"Add optional parameters to 'Program(bool)'",
string.Format(FeaturesResources.AddOptionalParametersTo, "Program", "bool"),
index: 1);
}
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.CodeRefactorings.GenerateFromMembers.GenerateConstructor;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Simplification;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Test.Utilities;
using Xunit;
......@@ -148,7 +145,7 @@ public void TestSmartTagText1()
{
TestSmartTagText(
@"using System.Collections.Generic; class Program { [|bool b; HashSet<string> s;|] }",
@"Generate constructor 'Program(bool, HashSet<string>)'");
string.Format(FeaturesResources.GenerateConstructor, "Program", "bool, HashSet<string>"));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
......@@ -156,7 +153,7 @@ public void TestSmartTagText2()
{
TestSmartTagText(
@"using System . Collections . Generic ; class Program { [|bool b ; HashSet < string > s ;|] public Program ( bool b ) { this . b = b ; } } ",
@"Generate field assigning constructor 'Program(bool, HashSet<string>)'");
string.Format(FeaturesResources.GenerateFieldAssigningConstructor, "Program", "bool, HashSet<string>"));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
......@@ -164,7 +161,7 @@ public void TestSmartTagText3()
{
TestSmartTagText(
@"using System . Collections . Generic ; class Program { [|bool b ; HashSet < string > s ;|] public Program ( bool b ) { this . b = b ; } } ",
@"Generate delegating constructor 'Program(bool, HashSet<string>)'",
string.Format(FeaturesResources.GenerateDelegatingConstructor, "Program", "bool, HashSet<string>"),
index: 1);
}
......
......@@ -154,7 +154,7 @@ public void TestSmartTagText1()
{
TestSmartTagText(
@"using System . Collections . Generic ; class Program { [|bool b ; HashSet < string > s ;|] public Program ( bool b ) { this . b = b ; } } ",
@"Generate 'Equals(object)'");
FeaturesResources.GenerateEqualsObject);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateEqualsAndGetHashCode)]
......@@ -162,7 +162,7 @@ public void TestSmartTagText2()
{
TestSmartTagText(
@"using System . Collections . Generic ; class Program { [|bool b ; HashSet < string > s ;|] public Program ( bool b ) { this . b = b ; } } ",
@"Generate 'GetHashCode()'",
FeaturesResources.GenerateGetHashCode,
index: 1);
}
......@@ -171,7 +171,7 @@ public void TestSmartTagText3()
{
TestSmartTagText(
@"using System . Collections . Generic ; class Program { [|bool b ; HashSet < string > s ;|] public Program ( bool b ) { this . b = b ; } } ",
@"Generate Both",
FeaturesResources.GenerateBoth,
index: 2);
}
}
......
......@@ -876,7 +876,7 @@ void Main ( )
}
}";
TestExactActionSetOffered(code, new[] { "Introduce local constant for '5'" });
TestExactActionSetOffered(code, new[] { string.Format(FeaturesResources.IntroduceLocalConstantFor, "5") });
Test(code,
@"
......@@ -916,7 +916,7 @@ void Main ( )
}";
TestExactActionSetOffered(code,
new[] { "Introduce local constant for '5'", "Introduce local constant for all occurrences of '5'" });
new[] { string.Format(FeaturesResources.IntroduceLocalConstantFor, "5"), string.Format(FeaturesResources.IntroduceLocalConstantForAll, "5") });
}
[WorkItem(529795)]
......
......@@ -362,7 +362,7 @@ void Foo(bool boolean = false, Class1 obj = default(Class1))
}
";
VerifyItemExists(markup, "obj:",
expectedDescriptionOrNull: "(parameter) Class1 obj = default(Class1)");
expectedDescriptionOrNull: $"({FeaturesResources.Parameter}) Class1 obj = default(Class1)");
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Completion.Providers;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Completion.Providers;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Completion.CompletionProviders;
using Roslyn.Test.Utilities;
......@@ -2447,7 +2448,7 @@ void M()
{
$$";
VerifyItemExists(markup, "M", expectedDescriptionOrNull: "void C.M(int i) (+ 1 overload)");
VerifyItemExists(markup, "M", expectedDescriptionOrNull: $"void C.M(int i) (+ 1 {FeaturesResources.Overload})");
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
......@@ -2462,7 +2463,7 @@ void M()
{
$$";
VerifyItemExists(markup, "M", expectedDescriptionOrNull: "void C.M(int i) (+ 2 overloads)");
VerifyItemExists(markup, "M", expectedDescriptionOrNull: $"void C.M(int i) (+ 2 {FeaturesResources.Overloads})");
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
......@@ -2476,7 +2477,7 @@ void M<T>()
{
$$";
VerifyItemExists(markup, "M<>", expectedDescriptionOrNull: "void C.M<T>(T i) (+ 1 generic overload)");
VerifyItemExists(markup, "M<>", expectedDescriptionOrNull: $"void C.M<T>(T i) (+ 1 {FeaturesResources.GenericOverload})");
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
......@@ -2491,7 +2492,7 @@ void M<T>()
{
$$";
VerifyItemExists(markup, "M<>", expectedDescriptionOrNull: "void C.M<T>(int i) (+ 2 generic overloads)");
VerifyItemExists(markup, "M<>", expectedDescriptionOrNull: $"void C.M<T>(int i) (+ 2 {FeaturesResources.GenericOverload})");
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
......@@ -2517,7 +2518,7 @@ void M(T foo)
{
$$";
VerifyItemExists(markup, "foo", expectedDescriptionOrNull: "(parameter) T foo");
VerifyItemExists(markup, "foo", expectedDescriptionOrNull: $"({FeaturesResources.Parameter}) T foo");
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
......@@ -2530,7 +2531,7 @@ void M()
{
$$";
VerifyItemExists(markup, "T", expectedDescriptionOrNull: "T in C<T>");
VerifyItemExists(markup, "T", expectedDescriptionOrNull: $"T {FeaturesResources.In} C<T>");
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
......@@ -2546,10 +2547,10 @@ void M()
";
var expectedDescription =
@"(local variable) 'a a
$@"({FeaturesResources.LocalVariable}) 'a a
Anonymous Types:
'a is new { }";
{FeaturesResources.AnonymousTypes}
'a {FeaturesResources.Is} new {{ }}";
VerifyItemExists(markup, "a", expectedDescription);
}
......@@ -6297,9 +6298,9 @@ async Task foo()
}
}";
var description = @"(awaitable) Task Program.foo()
var description = $@"({CSharpEditorResources.Awaitable}) Task Program.foo()
Usage:
await foo();";
{CSharpFeaturesResources.Await} foo();";
VerifyItemWithMscorlib45(markup, "foo", description, "C#");
}
......@@ -6318,9 +6319,9 @@ async Task<int> foo()
}
}";
var description = @"(awaitable) Task<int> Program.foo()
var description = $@"({CSharpEditorResources.Awaitable}) Task<int> Program.foo()
Usage:
int x = await foo();";
int x = {CSharpFeaturesResources.Await} foo();";
VerifyItemWithMscorlib45(markup, "foo", description, "C#");
}
......@@ -6339,7 +6340,7 @@ public void foo()
$$
}
}";
VerifyItemExists(markup, "foo", "[deprecated] void Program.foo()");
VerifyItemExists(markup, "foo", $"[{CSharpFeaturesResources.Deprecated}] void Program.foo()");
}
[WorkItem(568986)]
......@@ -6639,7 +6640,7 @@ void foo()
</Project>
</Workspace>";
VerifyItemInLinkedFiles(markup, "x", "(field) int C.x");
VerifyItemInLinkedFiles(markup, "x", $"({FeaturesResources.Field}) int C.x");
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
......@@ -6665,7 +6666,7 @@ void foo()
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = "(field) int C.x\r\n\r\n Proj1 - Available\r\n Proj2 - Not Available\r\n\r\nYou can use the navigation bar to switch context.";
var expectedDescription = $"({FeaturesResources.Field}) int C.x\r\n\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}";
VerifyItemInLinkedFiles(markup, "x", expectedDescription);
}
......@@ -6696,7 +6697,7 @@ void foo()
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = "(field) int C.x\r\n\r\n Proj1 - Available\r\n Proj2 - Not Available\r\n Proj3 - Not Available\r\n\r\nYou can use the navigation bar to switch context.";
var expectedDescription = $"({FeaturesResources.Field}) int C.x\r\n\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.NotAvailable)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj3", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}";
VerifyItemInLinkedFiles(markup, "x", expectedDescription);
}
......@@ -6730,7 +6731,7 @@ void foo()
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = "(field) int C.x\r\n\r\n Proj1 - Available\r\n Proj3 - Not Available\r\n\r\nYou can use the navigation bar to switch context.";
var expectedDescription = $"({FeaturesResources.Field}) int C.x\r\n\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj3", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}";
VerifyItemInLinkedFiles(markup, "x", expectedDescription);
}
......@@ -6768,7 +6769,7 @@ void foo()
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = "void G.DoGStuff()\r\n\r\n Proj1 - Not Available\r\n Proj2 - Available\r\n Proj3 - Not Available\r\n\r\nYou can use the navigation bar to switch context.";
var expectedDescription = $"void G.DoGStuff()\r\n\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.NotAvailable)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj3", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}";
VerifyItemInLinkedFiles(markup, "DoGStuff", expectedDescription);
}
......@@ -6795,7 +6796,7 @@ void M()
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = "(local variable) int xyz";
var expectedDescription = $"({FeaturesResources.LocalVariable}) int xyz";
VerifyItemInLinkedFiles(markup, "xyz", expectedDescription);
}
......@@ -6823,7 +6824,7 @@ void M()
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = "(local variable) int xyz\r\n\r\n Proj1 - Available\r\n Proj2 - Not Available\r\n\r\nYou can use the navigation bar to switch context.";
var expectedDescription = $"({FeaturesResources.LocalVariable}) int xyz\r\n\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available)}\r\n{string.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}";
VerifyItemInLinkedFiles(markup, "xyz", expectedDescription);
}
......@@ -6849,7 +6850,7 @@ void M()
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = "(label) LABEL";
var expectedDescription = $"({FeaturesResources.Label}) LABEL";
VerifyItemInLinkedFiles(markup, "LABEL", expectedDescription);
}
......@@ -6875,7 +6876,7 @@ void M()
<Document IsLinkFile=""true"" LinkAssemblyName=""Proj1"" LinkFilePath=""CurrentDocument.cs""/>
</Project>
</Workspace>";
var expectedDescription = "(range variable) ? y";
var expectedDescription = $"({FeaturesResources.RangeVariable}) ? y";
VerifyItemInLinkedFiles(markup, "y", expectedDescription);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册