Skip to content

Commit

Permalink
Add a regression test for DotNetAnalyzers#1448
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelvo committed Sep 10, 2015
1 parent 526ebb0 commit cd7961c
Showing 1 changed file with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,64 @@ public class Foo
await this.VerifyCSharpFixAsync(testCode, fixedTestCodeMultiple, codeFixIndex: 1).ConfigureAwait(false);
}

[Theory]
[InlineData("int Prop")]
[InlineData("int this[int index]")]
public async Task TestPropertyGetInOneLineSetInMultipleLinesWithMultipleStatementsAsync(string propertyDeclaration)
{
var testCode = $@"
public class Foo
{{
public {propertyDeclaration}
{{
get {{ return backingField; }}
set
{{
this.backingField = value;
this.OnPropertyChanged();
}}
}}
private int backingField;
private void OnPropertyChanged()
{{
}}
}}";
var fixedTestCodeMultiple = $@"
public class Foo
{{
public {propertyDeclaration}
{{
get
{{
return backingField;
}}
set
{{
this.backingField = value;
this.OnPropertyChanged();
}}
}}
private int backingField;
private void OnPropertyChanged()
{{
}}
}}";

DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(6, 9);

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

await this.VerifyCSharpFixAsync(testCode, fixedTestCodeMultiple).ConfigureAwait(false);
}

[Theory]
[InlineData("int Prop")]
[InlineData("int this[int index]")]
Expand Down

0 comments on commit cd7961c

Please sign in to comment.