Skip to content

Commit 59fccc3

Browse files
committed
Add argument list tests
1 parent d94c666 commit 59fccc3

1 file changed

Lines changed: 96 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1137UnitTests.cs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,102 @@ int this[
929929
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
930930
}
931931

932+
[Fact]
933+
public async Task TestArgumentListAsync()
934+
{
935+
string testCode = @"
936+
class Container
937+
{
938+
int NonZeroAlignment(int x, int y, int z) => NonZeroAlignment(
939+
0,
940+
0,
941+
0);
942+
943+
int ZeroAlignment(int x, int y, int z) => ZeroAlignment(
944+
0,
945+
0,
946+
0);
947+
}
948+
";
949+
string fixedCode = @"
950+
class Container
951+
{
952+
int NonZeroAlignment(int x, int y, int z) => NonZeroAlignment(
953+
0,
954+
0,
955+
0);
956+
957+
int ZeroAlignment(int x, int y, int z) => ZeroAlignment(
958+
0,
959+
0,
960+
0);
961+
}
962+
";
963+
964+
DiagnosticResult[] expected =
965+
{
966+
this.CSharpDiagnostic().WithLocation(6, 1),
967+
this.CSharpDiagnostic().WithLocation(7, 1),
968+
this.CSharpDiagnostic().WithLocation(11, 1),
969+
this.CSharpDiagnostic().WithLocation(12, 1),
970+
};
971+
972+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
973+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
974+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
975+
}
976+
977+
[Fact]
978+
public async Task TestBracketedArgumentListAsync()
979+
{
980+
string testCode = @"
981+
class Container1
982+
{
983+
int this[int x, int y, int z] => this[
984+
0,
985+
0,
986+
0];
987+
}
988+
989+
class Container2
990+
{
991+
int this[int x, int y, int z] => this[
992+
0,
993+
0,
994+
0];
995+
}
996+
";
997+
string fixedCode = @"
998+
class Container1
999+
{
1000+
int this[int x, int y, int z] => this[
1001+
0,
1002+
0,
1003+
0];
1004+
}
1005+
1006+
class Container2
1007+
{
1008+
int this[int x, int y, int z] => this[
1009+
0,
1010+
0,
1011+
0];
1012+
}
1013+
";
1014+
1015+
DiagnosticResult[] expected =
1016+
{
1017+
this.CSharpDiagnostic().WithLocation(6, 1),
1018+
this.CSharpDiagnostic().WithLocation(7, 1),
1019+
this.CSharpDiagnostic().WithLocation(14, 1),
1020+
this.CSharpDiagnostic().WithLocation(15, 1),
1021+
};
1022+
1023+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
1024+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
1025+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
1026+
}
1027+
9321028
[Fact]
9331029
public async Task TestAttributeListAsync()
9341030
{

0 commit comments

Comments
 (0)