Skip to content

Commit 54eea38

Browse files
committed
Convert readability rules tests to the new helpers
1 parent 9c0e99b commit 54eea38

53 files changed

Lines changed: 1599 additions & 2502 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1101CSharp7UnitTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules
77
using System.Threading.Tasks;
88
using StyleCop.Analyzers.Test.ReadabilityRules;
99
using Xunit;
10+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
11+
StyleCop.Analyzers.ReadabilityRules.SA1101PrefixLocalCallsWithThis,
12+
StyleCop.Analyzers.ReadabilityRules.SA1101CodeFixProvider>;
1013

1114
public class SA1101CSharp7UnitTests : SA1101UnitTests
1215
{
@@ -27,7 +30,7 @@ public async Task TestValueTupleAsync()
2730
}
2831
";
2932

30-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
33+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
3134
}
3235
}
3336
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1110CSharp7UnitTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules
88
using StyleCop.Analyzers.Test.ReadabilityRules;
99
using TestHelper;
1010
using Xunit;
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
12+
StyleCop.Analyzers.ReadabilityRules.SA1110OpeningParenthesisMustBeOnDeclarationLine,
13+
StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>;
1114

1215
public class SA1110CSharp7UnitTests : SA1110UnitTests
1316
{
@@ -38,11 +41,8 @@ void Bar()
3841
}
3942
}";
4043

41-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(7, 25);
42-
43-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
44-
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
45-
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
44+
DiagnosticResult expected = Diagnostic().WithLocation(7, 25);
45+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
4646
}
4747

4848
[Fact]
@@ -61,7 +61,7 @@ public void Method()
6161
}
6262
}";
6363

64-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
64+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
6565
}
6666
}
6767
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1111CSharp7UnitTests.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules
88
using StyleCop.Analyzers.Test.ReadabilityRules;
99
using TestHelper;
1010
using Xunit;
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
12+
StyleCop.Analyzers.ReadabilityRules.SA1111ClosingParenthesisMustBeOnLineOfLastParameter,
13+
StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>;
1114

1215
public class SA1111CSharp7UnitTests : SA1111UnitTests
1316
{
@@ -38,11 +41,8 @@ void Bar(string s)
3841
}
3942
}";
4043

41-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(7, 1);
42-
43-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
44-
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
45-
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
44+
DiagnosticResult expected = Diagnostic().WithLocation(7, 1);
45+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
4646
}
4747

4848
[Fact]
@@ -76,11 +76,8 @@ void Bar(string s,
7676
}
7777
}";
7878

79-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(9, 1);
80-
81-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
82-
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
83-
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
79+
DiagnosticResult expected = Diagnostic().WithLocation(9, 1);
80+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
8481
}
8582

8683
[Fact]
@@ -99,7 +96,7 @@ void Bar(
9996
}
10097
}";
10198

102-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
99+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
103100
}
104101

105102
[Fact]
@@ -117,7 +114,7 @@ void Bar(string s)
117114
}
118115
}";
119116

120-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
117+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
121118
}
122119
}
123120
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1112CSharp7UnitTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules
88
using StyleCop.Analyzers.Test.ReadabilityRules;
99
using TestHelper;
1010
using Xunit;
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
12+
StyleCop.Analyzers.ReadabilityRules.SA1112ClosingParenthesisMustBeOnLineOfOpeningParenthesis,
13+
StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>;
1114

1215
public class SA1112CSharp7UnitTests : SA1112UnitTests
1316
{
@@ -38,11 +41,8 @@ void Bar()
3841
}
3942
}";
4043

41-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(7, 1);
42-
43-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
44-
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
45-
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
44+
DiagnosticResult expected = Diagnostic().WithLocation(7, 1);
45+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
4646
}
4747

4848
[Fact]
@@ -60,7 +60,7 @@ void Bar()
6060
}
6161
}";
6262

63-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
63+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
6464
}
6565

6666
[Fact]
@@ -79,7 +79,7 @@ void Bar(
7979
}
8080
}";
8181

82-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
82+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
8383
}
8484
}
8585
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1113CSharp7UnitTests.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules
88
using StyleCop.Analyzers.Test.ReadabilityRules;
99
using TestHelper;
1010
using Xunit;
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
12+
StyleCop.Analyzers.ReadabilityRules.SA1113CommaMustBeOnSameLineAsPreviousParameter,
13+
StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>;
1114

1215
public class SA1113CSharp7UnitTests : SA1113UnitTests
1316
{
@@ -35,11 +38,8 @@ void Bar(string s,
3538
}
3639
}";
3740

38-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(6, 18);
39-
40-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
41-
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
42-
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
41+
DiagnosticResult expected = Diagnostic().WithLocation(6, 18);
42+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
4343
}
4444

4545
[Fact]
@@ -70,13 +70,11 @@ void Bar(string s,
7070

7171
DiagnosticResult[] expected =
7272
{
73-
this.CSharpDiagnostic().WithLocation(6, 18),
74-
this.CSharpDiagnostic().WithLocation(7, 18),
73+
Diagnostic().WithLocation(6, 18),
74+
Diagnostic().WithLocation(7, 18),
7575
};
7676

77-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
78-
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
79-
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
77+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
8078
}
8179

8280
[Fact]
@@ -93,7 +91,7 @@ void Bar(string s,
9391
}
9492
}";
9593

96-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
94+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
9795
}
9896
}
9997
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1114CSharp7UnitTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules
88
using StyleCop.Analyzers.Test.ReadabilityRules;
99
using TestHelper;
1010
using Xunit;
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier<StyleCop.Analyzers.ReadabilityRules.SA1114ParameterListMustFollowDeclaration>;
1112

1213
public class SA1114CSharp7UnitTests : SA1114UnitTests
1314
{
@@ -28,9 +29,9 @@ void Bar(
2829
}
2930
}";
3031

31-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(8, 1);
32+
DiagnosticResult expected = Diagnostic().WithLocation(8, 1);
3233

33-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
34+
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
3435
}
3536

3637
[Fact]
@@ -49,7 +50,7 @@ void Bar(
4950
}
5051
}";
5152

52-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
53+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
5354
}
5455

5556
[Fact]
@@ -67,7 +68,7 @@ void Bar(string s)
6768
}
6869
}";
6970

70-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
71+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
7172
}
7273

7374
[Fact]
@@ -87,7 +88,7 @@ void Bar(
8788
}
8889
}";
8990

90-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
91+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
9192
}
9293
}
9394
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1115CSharp7UnitTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules
88
using StyleCop.Analyzers.Test.ReadabilityRules;
99
using TestHelper;
1010
using Xunit;
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier<StyleCop.Analyzers.ReadabilityRules.SA1115ParameterMustFollowComma>;
1112

1213
public class SA1115CSharp7UnitTests : SA1115UnitTests
1314
{
@@ -30,10 +31,10 @@ void Bar(int i, int z,
3031
}
3132
}";
3233

33-
DiagnosticResult expected1 = this.CSharpDiagnostic().WithLocation(8, 1);
34-
DiagnosticResult expected2 = this.CSharpDiagnostic().WithLocation(10, 1);
34+
DiagnosticResult expected1 = Diagnostic().WithLocation(8, 1);
35+
DiagnosticResult expected2 = Diagnostic().WithLocation(10, 1);
3536

36-
await this.VerifyCSharpDiagnosticAsync(testCode, new[] { expected1, expected2 }, CancellationToken.None).ConfigureAwait(false);
37+
await VerifyCSharpDiagnosticAsync(testCode, new[] { expected1, expected2 }, CancellationToken.None).ConfigureAwait(false);
3738
}
3839

3940
[Fact]
@@ -51,7 +52,7 @@ void Bar(int i,
5152
}
5253
}";
5354

54-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
55+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
5556
}
5657

5758
[Fact]
@@ -68,7 +69,7 @@ void Bar(int i, string s)
6869
}
6970
}";
7071

71-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
72+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
7273
}
7374
}
7475
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1116CSharp7UnitTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules
88
using StyleCop.Analyzers.Test.ReadabilityRules;
99
using TestHelper;
1010
using Xunit;
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
12+
StyleCop.Analyzers.ReadabilityRules.SA1116SplitParametersMustStartOnLineAfterDeclaration,
13+
StyleCop.Analyzers.ReadabilityRules.SA1116CodeFixProvider>;
1114

1215
public class SA1116CSharp7UnitTests : SA1116UnitTests
1316
{
@@ -22,7 +25,7 @@ public void Method()
2225
object LocalFunction(int a, string s) => null;
2326
}
2427
}";
25-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
28+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
2629
}
2730

2831
[Fact]
@@ -47,10 +50,8 @@ object LocalFunction(
4750
string s) => null;
4851
}
4952
}";
50-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(6, 30);
51-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
52-
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
53-
await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
53+
DiagnosticResult expected = Diagnostic().WithLocation(6, 30);
54+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
5455
}
5556
}
5657
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1117CSharp7UnitTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules
88
using StyleCop.Analyzers.Test.ReadabilityRules;
99
using TestHelper;
1010
using Xunit;
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier<StyleCop.Analyzers.ReadabilityRules.SA1117ParametersMustBeOnSameLineOrSeparateLines>;
1112

1213
public class SA1117CSharp7UnitTests : SA1117UnitTests
1314
{
@@ -30,7 +31,7 @@ void LocalFunction2(
3031
object LocalFunction3(int a, int b, string s) => null;
3132
}
3233
}";
33-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
34+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
3435
}
3536

3637
[Fact]
@@ -56,10 +57,10 @@ object LocalFunction(
5657
string s) => null;
5758
}
5859
}";
59-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(7, 2);
60-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
61-
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
62-
////await this.VerifyCSharpFixAsync(testCode, fixedCode, cancellationToken: CancellationToken.None).ConfigureAwait(false);
60+
DiagnosticResult expected = Diagnostic().WithLocation(7, 2);
61+
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
62+
await VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
63+
////await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
6364
}
6465
}
6566
}

0 commit comments

Comments
 (0)