@@ -34,7 +34,12 @@ public void Bar(int i)
3434 public async Task TestWithBlankLinesAtEndOfFileAsync ( )
3535 {
3636 var testCode = BaseCode + "\r \n \r \n " ;
37- await this . VerifyCSharpDiagnosticAsync ( testCode , this . GenerateExpectedWarning ( 9 , 1 ) , CancellationToken . None ) . ConfigureAwait ( false ) ;
37+ var fixedCode = BaseCode + "\r \n " ;
38+
39+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 2 ) ;
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 ) . ConfigureAwait ( false ) ;
3843 }
3944
4045 /// <summary>
@@ -45,7 +50,12 @@ public async Task TestWithBlankLinesAtEndOfFileAsync()
4550 public async Task TestWithLineFeedOnlyBlankLinesAtEndOfFileAsync ( )
4651 {
4752 var testCode = BaseCode + "\n \n " ;
48- await this . VerifyCSharpDiagnosticAsync ( testCode , this . GenerateExpectedWarning ( 9 , 1 ) , CancellationToken . None ) . ConfigureAwait ( false ) ;
53+ var fixedCode = BaseCode + "\r \n " ;
54+
55+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 2 ) ;
56+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
57+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
58+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
4959 }
5060
5161 /// <summary>
@@ -88,7 +98,12 @@ public async Task TestWithoutCarriageReturnLineFeedAtEndOfFileAsync()
8898 public async Task TestFileEndsWithSpacesAsync ( )
8999 {
90100 var testCode = BaseCode + "\r \n " ;
91- await this . VerifyCSharpDiagnosticAsync ( testCode , this . GenerateExpectedWarning ( 9 , 1 ) , CancellationToken . None ) . ConfigureAwait ( false ) ;
101+ var fixedCode = BaseCode + "\r \n " ;
102+
103+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 2 ) ;
104+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
105+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
106+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
92107 }
93108
94109 /// <summary>
@@ -110,7 +125,12 @@ public async Task TestFileEndingWithCommentAsync()
110125 public async Task TestFileEndingWithCommentAndSpuriousWhitespaceAsync ( )
111126 {
112127 var testCode = BaseCode + "\r \n // Test comment\r \n \r \n " ;
113- await this . VerifyCSharpDiagnosticAsync ( testCode , this . GenerateExpectedWarning ( 10 , 1 ) , CancellationToken . None ) . ConfigureAwait ( false ) ;
128+ var fixedCode = BaseCode + "\r \n // Test comment\r \n " ;
129+
130+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 9 , 16 ) ;
131+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
132+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
133+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
114134 }
115135
116136 /// <summary>
@@ -132,7 +152,12 @@ public async Task TestFileEndingWithEndIfAsync()
132152 public async Task TestFileEndingWithEndIfWithSpuriousWhitespaceAsync ( )
133153 {
134154 var testCode = "#if true\r \n " + BaseCode + "\r \n #endif\r \n \r \n " ;
135- await this . VerifyCSharpDiagnosticAsync ( testCode , this . GenerateExpectedWarning ( 11 , 1 ) , CancellationToken . None ) . ConfigureAwait ( false ) ;
155+ var fixedCode = "#if true\r \n " + BaseCode + "\r \n #endif\r \n " ;
156+
157+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 10 , 7 ) ;
158+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
159+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
160+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
136161 }
137162
138163 /// <summary>
@@ -144,9 +169,12 @@ public async Task TestFileEndingWithEndIfWithSpuriousWhitespaceAsync()
144169 public async Task TestCodeFixProviderStripsTrailingBlankLinesAsync ( )
145170 {
146171 var testCode = BaseCode + "\r \n \r \n " ;
147- var fixedTestCode = BaseCode + "\r \n " ;
172+ var fixedCode = BaseCode + "\r \n " ;
148173
149- await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
174+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 2 ) ;
175+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
176+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
177+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
150178 }
151179
152180 /// <summary>
@@ -158,9 +186,12 @@ public async Task TestCodeFixProviderStripsTrailingBlankLinesAsync()
158186 public async Task TestCodeFixProviderStripsTrailingBlankLinesIncludingWhitespaceAsync ( )
159187 {
160188 var testCode = BaseCode + "\r \n \r \n \r \n " ;
161- var fixedTestCode = BaseCode + "\r \n " ;
189+ var fixedCode = BaseCode + "\r \n " ;
162190
163- await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
191+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 2 ) ;
192+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
193+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
194+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
164195 }
165196
166197 /// <summary>
@@ -172,9 +203,12 @@ public async Task TestCodeFixProviderStripsTrailingBlankLinesIncludingWhitespace
172203 public async Task TestCodeFixProviderStripsTrailingLinefeedOnlyBlankLinesIncludingWhitespaceAsync ( )
173204 {
174205 var testCode = BaseCode + "\n \n \n " ;
175- var fixedTestCode = BaseCode + "\n " ;
206+ var fixedCode = BaseCode + "\r \n " ;
176207
177- await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
208+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 8 , 2 ) ;
209+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
210+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
211+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
178212 }
179213
180214 /// <summary>
@@ -186,9 +220,12 @@ public async Task TestCodeFixProviderStripsTrailingLinefeedOnlyBlankLinesIncludi
186220 public async Task TestCodeFixProviderOnlyStripsTrailingBlankLinesAsync ( )
187221 {
188222 var testCode = "#if true\r \n " + BaseCode + "\r \n #endif\r \n \r \n " ;
189- var fixedTestCode = "#if true\r \n " + BaseCode + "\r \n #endif\r \n " ;
223+ var fixedCode = "#if true\r \n " + BaseCode + "\r \n #endif\r \n " ;
190224
191- await this . VerifyCSharpFixAsync ( testCode , fixedTestCode ) . ConfigureAwait ( false ) ;
225+ var expected = this . CSharpDiagnostic ( ) . WithLocation ( 10 , 7 ) ;
226+ await this . VerifyCSharpDiagnosticAsync ( testCode , expected , CancellationToken . None ) . ConfigureAwait ( false ) ;
227+ await this . VerifyCSharpDiagnosticAsync ( fixedCode , EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
228+ await this . VerifyCSharpFixAsync ( testCode , fixedCode ) . ConfigureAwait ( false ) ;
192229 }
193230
194231 /// <inheritdoc/>
@@ -202,10 +239,5 @@ protected override CodeFixProvider GetCSharpCodeFixProvider()
202239 {
203240 return new SA1518CodeFixProvider ( ) ;
204241 }
205-
206- private DiagnosticResult GenerateExpectedWarning ( int line , int column )
207- {
208- return this . CSharpDiagnostic ( ) . WithLocation ( line , column ) ;
209- }
210242 }
211243}
0 commit comments