Skip to content

Commit c1e0d57

Browse files
committed
Added missing test
1 parent fae34cb commit c1e0d57

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1106UnitTests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,37 @@ public void TestMethod2()
386386
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
387387
}
388388

389+
/// <summary>
390+
/// Verifies that the code fix will not remove relevant trivia.
391+
/// </summary>
392+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
393+
[Fact]
394+
public async Task VerifyCodeFixWillNotRemoveTriviaAsync()
395+
{
396+
var testCode = @"
397+
class TestClass
398+
{
399+
public void TestMethod()
400+
{
401+
/* do nothing */ ;
402+
}
403+
}";
404+
var fixedCode = @"
405+
class TestClass
406+
{
407+
public void TestMethod()
408+
{
409+
/* do nothing */
410+
}
411+
}";
412+
413+
var expected = this.CSharpDiagnostic().WithLocation(6, 26);
414+
415+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
416+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
417+
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
418+
}
419+
389420
/// <inheritdoc/>
390421
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
391422
{

0 commit comments

Comments
 (0)