Skip to content

Commit

Permalink
Add regression tests for DotNetAnalyzers#1132
Browse files Browse the repository at this point in the history
  • Loading branch information
Noryoko committed Aug 8, 2015
1 parent f66d9ab commit af860bd
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,48 @@ public class TestClass
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
}

/// <summary>
/// Verifies that documentation followed by comments are handled properly.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact]
public async Task TestDocumentationFollowedByCommentAsync()
{
var testCode = @"
/// <summary>some documentation</summary>
// some comment
public class TestClass
{
/// <summary>more documentation.</summary>
// another comment
public void TestMethod() { }
}
";

var fixedCode = @"
/// <summary>some documentation</summary>
// some comment
public class TestClass
{
/// <summary>more documentation.</summary>
// another comment
public void TestMethod() { }
}
";

DiagnosticResult[] expected =
{
this.CSharpDiagnostic().WithLocation(2, 1),
this.CSharpDiagnostic().WithLocation(7, 5),
};

await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
}

protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
{
yield return new SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,27 @@ public async Task TestPreprocessorInteractionAsync()
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

/// <summary>
/// Verifies the analyzer will properly handle documentation followed by a comment.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact]
public async Task TestDocumentationFollowedByCommentAsync()
{
var testCode = @"
/// <summary>some documentation</summary>
// some comment
public class TestClass
{
/// <summary>more documentation.</summary>
// another comment
public void TestMethod() { }
}
";

await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

/// <inheritdoc/>
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
{
Expand Down

0 comments on commit af860bd

Please sign in to comment.