Skip to content

Commit 6c0f6d9

Browse files
committed
Convert layout rules to the new test helpers
1 parent 07a6f35 commit 6c0f6d9

63 files changed

Lines changed: 1736 additions & 1926 deletions

File tree

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/LayoutRules/SA1500CSharp7UnitTests.cs

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

1215
public class SA1500CSharp7UnitTests : SA1500UnitTests
1316
{
@@ -50,7 +53,7 @@ void LocalFunction5()
5053
}
5154
}";
5255

53-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
56+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
5457
}
5558

5659
/// <summary>
@@ -141,28 +144,26 @@ void LocalFunction6()
141144
DiagnosticResult[] expectedDiagnostics =
142145
{
143146
// Invalid local function #1
144-
this.CSharpDiagnostic().WithLocation(8, 31),
147+
Diagnostic().WithLocation(8, 31),
145148

146149
// Invalid local function #2
147-
this.CSharpDiagnostic().WithLocation(12, 31),
150+
Diagnostic().WithLocation(12, 31),
148151

149152
// Invalid local function #3
150-
this.CSharpDiagnostic().WithLocation(17, 31),
151-
this.CSharpDiagnostic().WithLocation(18, 29),
153+
Diagnostic().WithLocation(17, 31),
154+
Diagnostic().WithLocation(18, 29),
152155

153156
// Invalid local function #4
154-
this.CSharpDiagnostic().WithLocation(21, 31),
157+
Diagnostic().WithLocation(21, 31),
155158

156159
// Invalid local function #5
157-
this.CSharpDiagnostic().WithLocation(27, 29),
160+
Diagnostic().WithLocation(27, 29),
158161

159162
// Invalid local function #6
160-
this.CSharpDiagnostic().WithLocation(31, 9),
163+
Diagnostic().WithLocation(31, 9),
161164
};
162165

163-
await this.VerifyCSharpDiagnosticAsync(testCode, expectedDiagnostics, CancellationToken.None).ConfigureAwait(false);
164-
await this.VerifyCSharpDiagnosticAsync(fixedTestCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
165-
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
166+
await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false);
166167
}
167168
}
168169
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1502CSharp7UnitTests.cs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules
77
using System.Threading.Tasks;
88
using StyleCop.Analyzers.Test.LayoutRules;
99
using Xunit;
10+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
11+
StyleCop.Analyzers.LayoutRules.SA1502ElementMustNotBeOnASingleLine,
12+
StyleCop.Analyzers.LayoutRules.SA1502CodeFixProvider>;
1013

1114
public class SA1502CSharp7UnitTests : SA1502UnitTests
1215
{
@@ -27,7 +30,7 @@ void Bar()
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
/// <summary>
@@ -45,8 +48,8 @@ void Bar() { }
4548
}
4649
}";
4750

48-
var expected = this.CSharpDiagnostic().WithLocation(5, 20);
49-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
51+
var expected = Diagnostic().WithLocation(5, 20);
52+
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
5053
}
5154

5255
/// <summary>
@@ -64,8 +67,8 @@ public void Method()
6467
}
6568
}";
6669

67-
var expected = this.CSharpDiagnostic().WithLocation(5, 19);
68-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
70+
var expected = Diagnostic().WithLocation(5, 19);
71+
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
6972
}
7073

7174
/// <summary>
@@ -84,8 +87,8 @@ int Bar()
8487
}
8588
}";
8689

87-
var expected = this.CSharpDiagnostic().WithLocation(6, 9);
88-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
90+
var expected = Diagnostic().WithLocation(6, 9);
91+
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
8992
}
9093

9194
/// <summary>
@@ -104,7 +107,7 @@ int Bar() {
104107
}
105108
}";
106109

107-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
110+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
108111
}
109112

110113
/// <summary>
@@ -122,7 +125,7 @@ public void Method()
122125
}
123126
}";
124127

125-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
128+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
126129
}
127130

128131
/// <summary>
@@ -149,7 +152,8 @@ void Bar()
149152
}
150153
}";
151154

152-
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
155+
var expected = Diagnostic().WithLocation(5, 20);
156+
await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false);
153157
}
154158

155159
/// <summary>
@@ -177,7 +181,8 @@ int Bar()
177181
}
178182
}";
179183

180-
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
184+
var expected = Diagnostic().WithLocation(5, 19);
185+
await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false);
181186
}
182187

183188
/// <summary>
@@ -206,7 +211,8 @@ int Bar()
206211
}
207212
}";
208213

209-
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
214+
var expected = Diagnostic().WithLocation(6, 9);
215+
await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false);
210216
}
211217

212218
/// <summary>
@@ -234,7 +240,8 @@ int Bar() /* TR1 */
234240
}
235241
}";
236242

237-
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
243+
var expected = Diagnostic().WithLocation(5, 29);
244+
await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false);
238245
}
239246
}
240247
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1505CSharp7UnitTests.cs

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

1114
public class SA1505CSharp7UnitTests : SA1505UnitTests
1215
{
@@ -34,7 +37,7 @@ void LocalFunction()
3437
}
3538
";
3639

37-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
40+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
3841
}
3942

4043
/// <summary>
@@ -79,11 +82,8 @@ void LocalFunction()
7982
}
8083
";
8184

82-
var expectedDiagnostic = this.CSharpDiagnostic().WithLocation(10, 13);
83-
84-
await this.VerifyCSharpDiagnosticAsync(testCode, expectedDiagnostic, CancellationToken.None).ConfigureAwait(false);
85-
await this.VerifyCSharpDiagnosticAsync(fixedTestCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
86-
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
85+
var expectedDiagnostic = Diagnostic().WithLocation(10, 13);
86+
await VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false);
8787
}
8888
}
8989
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1508CSharp7UnitTests.cs

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

1114
public class SA1508CSharp7UnitTests : SA1508UnitTests
1215
{
@@ -34,7 +37,7 @@ void LocalFunction()
3437
}
3538
";
3639

37-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
40+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
3841
}
3942

4043
/// <summary>
@@ -79,11 +82,8 @@ void LocalFunction()
7982
}
8083
";
8184

82-
var expectedDiagnostic = this.CSharpDiagnostic().WithLocation(13, 13);
83-
84-
await this.VerifyCSharpDiagnosticAsync(testCode, expectedDiagnostic, CancellationToken.None).ConfigureAwait(false);
85-
await this.VerifyCSharpDiagnosticAsync(fixedTestCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
86-
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
85+
var expectedDiagnostic = Diagnostic().WithLocation(13, 13);
86+
await VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false);
8787
}
8888
}
8989
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1509CSharp7UnitTests.cs

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

1215
public class SA1509CSharp7UnitTests : SA1509UnitTests
1316
{
@@ -36,11 +39,8 @@ void Bar()
3639
}
3740
}";
3841

39-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(8, 9);
40-
41-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
42-
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
43-
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
42+
DiagnosticResult expected = Diagnostic().WithLocation(8, 9);
43+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
4444
}
4545

4646
[Fact]
@@ -70,11 +70,8 @@ void Bar()
7070
}
7171
}";
7272

73-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(9, 9);
74-
75-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
76-
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
77-
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
73+
DiagnosticResult expected = Diagnostic().WithLocation(9, 9);
74+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
7875
}
7976
}
8077
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1513CSharp7UnitTests.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules
77
using System.Threading.Tasks;
88
using StyleCop.Analyzers.Test.LayoutRules;
99
using Xunit;
10+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
11+
StyleCop.Analyzers.LayoutRules.SA1513ClosingBraceMustBeFollowedByBlankLine,
12+
StyleCop.Analyzers.LayoutRules.SA1513CodeFixProvider>;
1013

1114
public class SA1513CSharp7UnitTests : SA1513UnitTests
1215
{
@@ -48,7 +51,7 @@ int LocalFunction(int value)
4851
}
4952
";
5053

51-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
54+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
5255
}
5356

5457
/// <summary>
@@ -128,16 +131,14 @@ void LocalFunction2()
128131
var expected = new[]
129132
{
130133
// Invalid #1
131-
this.CSharpDiagnostic().WithLocation(15, 14),
134+
Diagnostic().WithLocation(15, 14),
132135

133136
// Invalid #2, #3
134-
this.CSharpDiagnostic().WithLocation(24, 10),
135-
this.CSharpDiagnostic().WithLocation(27, 10),
137+
Diagnostic().WithLocation(24, 10),
138+
Diagnostic().WithLocation(27, 10),
136139
};
137140

138-
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
139-
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
140-
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
141+
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
141142
}
142143
}
143144
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1515CSharp7UnitTests.cs

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

1114
public class SA1515CSharp7UnitTests : SA1515UnitTests
1215
{
@@ -28,7 +31,7 @@ public void Method()
2831
}
2932
";
3033

31-
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
34+
await VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
3235
}
3336
}
3437
}

0 commit comments

Comments
 (0)