@@ -8,6 +8,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules
88 using StyleCop . Analyzers . Test . SpacingRules ;
99 using TestHelper ;
1010 using Xunit ;
11+ using static StyleCop . Analyzers . Test . Verifiers . StyleCopCodeFixVerifier < StyleCop . Analyzers . SpacingRules . SA1000KeywordsMustBeSpacedCorrectly , StyleCop . Analyzers . SpacingRules . TokenSpacingCodeFixProvider > ;
1112
1213 public class SA1000CSharp7UnitTests : SA1000UnitTests
1314 {
@@ -20,7 +21,7 @@ public async Task TestOutVariableDeclarationAsync()
2021
2122 await this . TestKeywordStatementAsync ( statementWithSpace , EmptyDiagnosticResults , statementWithSpace ) . ConfigureAwait ( false ) ;
2223
23- DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithArguments ( "out" , string . Empty , "followed" ) . WithLocation ( 12 , 31 ) ;
24+ DiagnosticResult expected = Diagnostic ( ) . WithArguments ( "out" , string . Empty , "followed" ) . WithLocation ( 12 , 31 ) ;
2425
2526 await this . TestKeywordStatementAsync ( statementWithoutSpace , expected , statementWithSpace ) . ConfigureAwait ( false ) ;
2627 }
@@ -52,7 +53,7 @@ public async Task TestVarKeywordTupleTypeAsync()
5253
5354 await this . TestKeywordStatementAsync ( statementWithSpace , EmptyDiagnosticResults , statementWithSpace ) . ConfigureAwait ( false ) ;
5455
55- DiagnosticResult expected = this . CSharpDiagnostic ( ) . WithArguments ( "var" , string . Empty , "followed" ) . WithLocation ( 12 , 13 ) ;
56+ DiagnosticResult expected = Diagnostic ( ) . WithArguments ( "var" , string . Empty , "followed" ) . WithLocation ( 12 , 13 ) ;
5657
5758 await this . TestKeywordStatementAsync ( statementWithoutSpace , expected , statementWithSpace ) . ConfigureAwait ( false ) ;
5859 }
@@ -80,12 +81,12 @@ ref @Int32 Call(ref @Int32 p)
8081
8182 DiagnosticResult [ ] expected =
8283 {
83- this . CSharpDiagnostic ( ) . WithArguments ( "ref" , string . Empty , "followed" ) . WithLocation ( 14 , 1 ) ,
84- this . CSharpDiagnostic ( ) . WithArguments ( "ref" , string . Empty , "followed" ) . WithLocation ( 14 , 15 ) ,
85- this . CSharpDiagnostic ( ) . WithArguments ( "ref" , string . Empty , "followed" ) . WithLocation ( 14 , 24 ) ,
86- this . CSharpDiagnostic ( ) . WithArguments ( "ref" , string . Empty , "followed" ) . WithLocation ( 16 , 1 ) ,
87- this . CSharpDiagnostic ( ) . WithArguments ( "ref" , string . Empty , "followed" ) . WithLocation ( 16 , 16 ) ,
88- this . CSharpDiagnostic ( ) . WithArguments ( "ref" , string . Empty , "followed" ) . WithLocation ( 17 , 8 ) ,
84+ Diagnostic ( ) . WithArguments ( "ref" , string . Empty , "followed" ) . WithLocation ( 14 , 1 ) ,
85+ Diagnostic ( ) . WithArguments ( "ref" , string . Empty , "followed" ) . WithLocation ( 14 , 15 ) ,
86+ Diagnostic ( ) . WithArguments ( "ref" , string . Empty , "followed" ) . WithLocation ( 14 , 24 ) ,
87+ Diagnostic ( ) . WithArguments ( "ref" , string . Empty , "followed" ) . WithLocation ( 16 , 1 ) ,
88+ Diagnostic ( ) . WithArguments ( "ref" , string . Empty , "followed" ) . WithLocation ( 16 , 16 ) ,
89+ Diagnostic ( ) . WithArguments ( "ref" , string . Empty , "followed" ) . WithLocation ( 17 , 8 ) ,
8990 } ;
9091
9192 await this . TestKeywordStatementAsync ( statementWithoutSpace , expected , statementWithSpace ) . ConfigureAwait ( false ) ;
@@ -133,16 +134,17 @@ public void TestMethod()
133134}
134135" ;
135136
136- DiagnosticResult [ ] expectedDiagnostics =
137+ await new CSharpTest
137138 {
138- // Returns
139- this . CSharpDiagnostic ( ) . WithArguments ( "return" , string . Empty , "followed" ) . WithLocation ( 10 , 43 ) ,
140- this . CSharpDiagnostic ( ) . WithArguments ( "return" , string . Empty , "followed" ) . WithLocation ( 11 , 43 ) ,
141- } ;
142-
143- await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostics , CancellationToken . None ) . ConfigureAwait ( false ) ;
144- await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
145- await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
139+ TestCode = testCode ,
140+ FixedCode = fixedCode ,
141+ ExpectedDiagnostics =
142+ {
143+ // Returns
144+ Diagnostic ( ) . WithArguments ( "return" , string . Empty , "followed" ) . WithLocation ( 10 , 43 ) ,
145+ Diagnostic ( ) . WithArguments ( "return" , string . Empty , "followed" ) . WithLocation ( 11 , 43 ) ,
146+ } ,
147+ } . RunAsync ( CancellationToken . None ) . ConfigureAwait ( false ) ;
146148 }
147149
148150 /// <summary>
@@ -181,15 +183,16 @@ public void TestMethod()
181183}
182184" ;
183185
184- DiagnosticResult [ ] expectedDiagnostics =
186+ await new CSharpTest
185187 {
186- this . CSharpDiagnostic ( ) . WithArguments ( "new" , string . Empty , "followed" ) . WithLocation ( 7 , 21 ) ,
187- this . CSharpDiagnostic ( ) . WithArguments ( "new" , string . Empty , "followed" ) . WithLocation ( 8 , 21 ) ,
188- } ;
189-
190- await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostics , CancellationToken . None ) . ConfigureAwait ( false ) ;
191- await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
192- await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
188+ TestCode = testCode ,
189+ FixedCode = fixedCode ,
190+ ExpectedDiagnostics =
191+ {
192+ Diagnostic ( ) . WithArguments ( "new" , string . Empty , "followed" ) . WithLocation ( 7 , 21 ) ,
193+ Diagnostic ( ) . WithArguments ( "new" , string . Empty , "followed" ) . WithLocation ( 8 , 21 ) ,
194+ } ,
195+ } . RunAsync ( CancellationToken . None ) . ConfigureAwait ( false ) ;
193196 }
194197
195198 /// <summary>
@@ -228,15 +231,16 @@ public void TestMethod()
228231}
229232" ;
230233
231- DiagnosticResult [ ] expectedDiagnostics =
234+ await new CSharpTest
232235 {
233- this . CSharpDiagnostic ( ) . WithArguments ( "foreach" , string . Empty , "followed" ) . WithLocation ( 7 , 13 ) ,
234- this . CSharpDiagnostic ( ) . WithArguments ( "foreach" , string . Empty , "followed" ) . WithLocation ( 8 , 13 ) ,
235- } ;
236-
237- await this . VerifyCSharpDiagnosticAsync ( testCode , expectedDiagnostics , CancellationToken . None ) . ConfigureAwait ( false ) ;
238- await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
239- await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
236+ TestCode = testCode ,
237+ FixedCode = fixedCode ,
238+ ExpectedDiagnostics =
239+ {
240+ Diagnostic ( ) . WithArguments ( "foreach" , string . Empty , "followed" ) . WithLocation ( 7 , 13 ) ,
241+ Diagnostic ( ) . WithArguments ( "foreach" , string . Empty , "followed" ) . WithLocation ( 8 , 13 ) ,
242+ } ,
243+ } . RunAsync ( CancellationToken . None ) . ConfigureAwait ( false ) ;
240244 }
241245 }
242246}
0 commit comments