Skip to content

Commit

Permalink
Add regression tests for DotNetAnalyzers#1155
Browse files Browse the repository at this point in the history
  • Loading branch information
Noryoko committed Aug 8, 2015
1 parent 7f8855a commit 6bf74bd
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,29 @@ public class TestClass2 { }
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
}

/// <summary>
/// Verifies that the analyzer will properly handle static constructors.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact]
public async Task TestStaticConstructorsAsync()
{
var testCode = @"
class MyClass
{
static MyClass()
{
}
public MyClass()
{
}
}
";

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

/// <summary>
/// Verifies that the analyzer will properly handle incomplete members.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,42 @@ static class TestClass2 { }
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
}

/// <summary>
/// Verifies that the analyzer will properly handle static constructors.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact]
public async Task TestStaticConstructorsAsync()
{
var testCode = @"
class MyClass1
{
public MyClass1()
{
}
static MyClass1()
{
}
}
class MyClass2
{
static MyClass2()
{
}
public MyClass2()
{
}
}
";

var expected = this.CSharpDiagnostic().WithLocation(8, 12).WithArguments("public", "constructors");

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

/// <summary>
/// Verifies that the analyzer will properly incomplete members.
/// </summary>
Expand Down

0 comments on commit 6bf74bd

Please sign in to comment.