Skip to content

Commit

Permalink
More FUSE test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwengier committed Oct 30, 2024
1 parent 819d965 commit 7240539
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public class CohostDocumentFormattingEndpointTest(HtmlFormattingFixture htmlForm
// and provide regression prevention. The tests here are not exhaustive, but they validate the the cohost endpoints
// call into the formatting engine at least, and handles C#, Html and Razor formatting changes correctly.

[Fact]
public Task Formatting()
[Theory]
[CombinatorialData]
public Task Formatting(bool fuse)
=> VerifyDocumentFormattingAsync(
input: """
@preservewhitespace true
Expand Down Expand Up @@ -104,10 +105,13 @@ private void M(string thisIsMyString)
}
}
""");
""",
fuse: fuse);

private async Task VerifyDocumentFormattingAsync(string input, string expected)
private async Task VerifyDocumentFormattingAsync(string input, string expected, bool fuse)
{
UpdateClientInitializationOptions(opt => opt with { ForceRuntimeCodeGeneration = fuse });

var document = await CreateProjectAndRazorDocumentAsync(input);
var inputText = await document.GetTextAsync(DisposalToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.LanguageServices.Razor.LanguageClient.Cohost;
using Microsoft.VisualStudio.LicenseManagement.Interop;
using Microsoft.VisualStudio.Razor.Settings;
using Roslyn.Test.Utilities;
using Xunit;
Expand Down Expand Up @@ -84,8 +85,9 @@ The end.
delegatedResponseText: "\"$0\"");
}

[Fact]
public async Task CSharp_OnForwardSlash()
[Theory]
[CombinatorialData]
public async Task CSharp_OnForwardSlash(bool fuse)
{
await VerifyOnAutoInsertAsync(
input: """
Expand All @@ -102,7 +104,8 @@ void TestMethod() {}
void TestMethod() {}
}
""",
triggerCharacter: "/");
triggerCharacter: "/",
fuse: fuse);
}

[Fact]
Expand Down Expand Up @@ -161,8 +164,9 @@ void TestMethod()
fuse: fuse);
}

[Fact]
public async Task CSharp_OnEnter_TwoSpaceIndent()
[Theory]
[CombinatorialData]
public async Task CSharp_OnEnter_TwoSpaceIndent(bool fuse)
{
await VerifyOnAutoInsertAsync(
input: """
Expand All @@ -180,11 +184,13 @@ void TestMethod()
}
""",
triggerCharacter: "\n",
tabSize: 2);
tabSize: 2,
fuse: fuse);
}

[Fact]
public async Task CSharp_OnEnter_UseTabs()
[Theory]
[CombinatorialData]
public async Task CSharp_OnEnter_UseTabs(bool fuse)
{
const char tab = '\t';
await VerifyOnAutoInsertAsync(
Expand All @@ -203,7 +209,8 @@ void TestMethod() {
}
""",
triggerCharacter: "\n",
insertSpaces: false);
insertSpaces: false,
fuse: fuse);
}

private async Task VerifyOnAutoInsertAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ await VerifyOnTypeFormattingAsync(
triggerCharacter: '\n');
}

[Fact]
public async Task CSharp()
[Theory]
[CombinatorialData]
public async Task CSharp(bool fuse)
{
await VerifyOnTypeFormattingAsync(
input: """
Expand All @@ -70,11 +71,13 @@ await VerifyOnTypeFormattingAsync(
if (true) { }
}
""",
triggerCharacter: '}');
triggerCharacter: '}',
fuse: fuse);
}

[Fact]
public async Task FormatsSimpleHtmlTag_OnType()
[Theory]
[CombinatorialData]
public async Task FormatsSimpleHtmlTag_OnType(bool fuse)
{
await VerifyOnTypeFormattingAsync(
input: """
Expand All @@ -98,11 +101,14 @@ await VerifyOnTypeFormattingAsync(
</html>
""",
triggerCharacter: ';',
html: true);
html: true,
fuse: fuse);
}

private async Task VerifyOnTypeFormattingAsync(TestCode input, string expected, char triggerCharacter, bool html = false)
private async Task VerifyOnTypeFormattingAsync(TestCode input, string expected, char triggerCharacter, bool html = false, bool fuse = false)
{
UpdateClientInitializationOptions(opt => opt with { ForceRuntimeCodeGeneration = fuse });

var document = await CreateProjectAndRazorDocumentAsync(input.Text);
var inputText = await document.GetTextAsync(DisposalToken);
var position = inputText.GetPosition(input.Position);
Expand Down

0 comments on commit 7240539

Please sign in to comment.