Skip to content

Commit

Permalink
Add regression tests for DotNetAnalyzers#1131
Browse files Browse the repository at this point in the history
  • Loading branch information
Noryoko committed Aug 8, 2015
1 parent cedc7e8 commit 960e6b6
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,55 @@ public class TestClass
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
}

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

DiagnosticResult[] expected =
{
this.CSharpDiagnostic().WithLocation(4, 9),
this.CSharpDiagnostic().WithLocation(9, 10)
};

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 SA1514ElementDocumentationHeaderMustBePrecededByBlankLine();
Expand Down

0 comments on commit 960e6b6

Please sign in to comment.