Skip to content

Commit

Permalink
add regression tests for DotNetAnalyzers#1301
Browse files Browse the repository at this point in the history
  • Loading branch information
Noryoko committed Aug 28, 2015
1 parent 9169f51 commit 1c3fcee
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,37 @@ public void Baz()
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
}

/// <summary>
/// Verifies the analyzer will properly handle an object initializer without assignment.
/// This is a regression test for <see href="https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1301">DotNetAnalyzers/StyleCopAnalyzers#1301</see>.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact]
public async Task TestObjectInitializerWithoutAssignmentAsync()
{
var testCode = @"using System.Collections.Generic;
public class TestClass
{
public int X { get; set; }
public void TestMethod()
{
new List<int>
{
1
};
new TestClass
{
X = 1
};
}
}
";

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

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

0 comments on commit 1c3fcee

Please sign in to comment.