Skip to content

Commit d94c666

Browse files
committed
Add parameter list tests
1 parent c9506cf commit d94c666

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
@@ -833,6 +833,102 @@ class Container
833833
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
834834
}
835835

836+
[Fact]
837+
public async Task TestParameterListAsync()
838+
{
839+
string testCode = @"
840+
class Container
841+
{
842+
void NonZeroAlignment(
843+
int X,
844+
int Y,
845+
int Z) { }
846+
847+
void ZeroAlignment(
848+
int X,
849+
int Y,
850+
int Z) { }
851+
}
852+
";
853+
string fixedCode = @"
854+
class Container
855+
{
856+
void NonZeroAlignment(
857+
int X,
858+
int Y,
859+
int Z) { }
860+
861+
void ZeroAlignment(
862+
int X,
863+
int Y,
864+
int Z) { }
865+
}
866+
";
867+
868+
DiagnosticResult[] expected =
869+
{
870+
this.CSharpDiagnostic().WithLocation(6, 1),
871+
this.CSharpDiagnostic().WithLocation(7, 1),
872+
this.CSharpDiagnostic().WithLocation(11, 1),
873+
this.CSharpDiagnostic().WithLocation(12, 1),
874+
};
875+
876+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
877+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
878+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
879+
}
880+
881+
[Fact]
882+
public async Task TestBracketedParameterListAsync()
883+
{
884+
string testCode = @"
885+
class Container1
886+
{
887+
int this[
888+
int X,
889+
int Y,
890+
int Z] => 0;
891+
}
892+
893+
class Container2
894+
{
895+
int this[
896+
int X,
897+
int Y,
898+
int Z] => 0;
899+
}
900+
";
901+
string fixedCode = @"
902+
class Container1
903+
{
904+
int this[
905+
int X,
906+
int Y,
907+
int Z] => 0;
908+
}
909+
910+
class Container2
911+
{
912+
int this[
913+
int X,
914+
int Y,
915+
int Z] => 0;
916+
}
917+
";
918+
919+
DiagnosticResult[] expected =
920+
{
921+
this.CSharpDiagnostic().WithLocation(6, 1),
922+
this.CSharpDiagnostic().WithLocation(7, 1),
923+
this.CSharpDiagnostic().WithLocation(14, 1),
924+
this.CSharpDiagnostic().WithLocation(15, 1),
925+
};
926+
927+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
928+
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
929+
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
930+
}
931+
836932
[Fact]
837933
public async Task TestAttributeListAsync()
838934
{

0 commit comments

Comments
 (0)