Skip to content

Commit 6299cb9

Browse files
committed
Add a couple more missing tests
1 parent 76f78df commit 6299cb9

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostCodeActionsEndpointTest.cs

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,54 @@ private string GetDebuggerDisplay()
394394
await VerifyCodeActionAsync(input, expected, RazorPredefinedCodeRefactoringProviderNames.AddDebuggerDisplay);
395395
}
396396

397+
[Fact]
398+
public async Task FullyQualify()
399+
{
400+
var input = """
401+
@code
402+
{
403+
private [||]StringBuilder _x = new StringBuilder();
404+
}
405+
""";
406+
407+
var expected = """
408+
@code
409+
{
410+
private System.Text.StringBuilder _x = new StringBuilder();
411+
}
412+
""";
413+
414+
await VerifyCodeActionAsync(input, expected, "System.Text.StringBuilder");
415+
}
416+
417+
[Fact]
418+
public async Task FullyQualify_Multiple()
419+
{
420+
await VerifyCodeActionAsync(
421+
input: """
422+
@code
423+
{
424+
private [||]StringBuilder _x = new StringBuilder();
425+
}
426+
""",
427+
expected: """
428+
@code
429+
{
430+
private System.Text.StringBuilder _x = new StringBuilder();
431+
}
432+
""",
433+
additionalFiles: [
434+
(FilePath("StringBuilder.cs"), """
435+
namespace Not.Built.In;
436+
437+
public class StringBuilder
438+
{
439+
}
440+
""")],
441+
codeActionName: "Fully qualify 'StringBuilder'",
442+
childActionIndex: 0);
443+
}
444+
397445
[Fact]
398446
public async Task AddUsing()
399447
{
@@ -905,7 +953,12 @@ private async Task VerifyCodeActionAsync(TestCode input, string? expected, strin
905953
Assert.NotEmpty(result);
906954

907955
var codeActionToRun = (VSInternalCodeAction?)result.SingleOrDefault(e => ((RazorVSInternalCodeAction)e.Value!).Name == codeActionName || ((RazorVSInternalCodeAction)e.Value!).Title == codeActionName).Value;
908-
Assert.NotNull(codeActionToRun);
956+
AssertEx.NotNull(codeActionToRun, $"""
957+
Could not file code action with name or title '{codeActionName}'.
958+
959+
Available:
960+
{string.Join(Environment.NewLine + " ", result.Select(e => $"{((RazorVSInternalCodeAction)e.Value!).Name} or {((RazorVSInternalCodeAction)e.Value!).Title}"))}
961+
""");
909962

910963
if (codeActionToRun.Children?.Length > 0)
911964
{

0 commit comments

Comments
 (0)