@@ -61,6 +61,33 @@ public void ObsoleteCommentSyntax_DoesNotReturnResult()
61
61
Assert . AreEqual ( 0 , inspectionResults . Count ( ) ) ;
62
62
}
63
63
64
+ [ TestMethod ]
65
+ [ TestCategory ( "Inspections" ) ]
66
+ public void ObsoleteCommentSyntax_DoesNotReturnResult_RemInStringLiteral ( )
67
+ {
68
+ const string inputCode =
69
+ @"Sub Foo()
70
+ Dim bar As String
71
+ bar = ""iejo rem oernp"" ' test
72
+ End Sub" ;
73
+
74
+ //Arrange
75
+ var builder = new MockVbeBuilder ( ) ;
76
+ VBComponent component ;
77
+ var vbe = builder . BuildFromSingleStandardModule ( inputCode , out component ) ;
78
+ var mockHost = new Mock < IHostApplication > ( ) ;
79
+ mockHost . SetupAllProperties ( ) ;
80
+ var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object , new Mock < ISinks > ( ) . Object ) ) ;
81
+
82
+ parser . Parse ( new CancellationTokenSource ( ) ) ;
83
+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
84
+
85
+ var inspection = new ObsoleteCommentSyntaxInspection ( parser . State ) ;
86
+ var inspectionResults = inspection . GetInspectionResults ( ) ;
87
+
88
+ Assert . AreEqual ( 0 , inspectionResults . Count ( ) ) ;
89
+ }
90
+
64
91
[ TestMethod ]
65
92
[ TestCategory ( "Inspections" ) ]
66
93
public void ObsoleteCommentSyntax_ReturnsMultipleResults ( )
@@ -198,6 +225,68 @@ public void ObsoleteCommentSyntax_QuickFixWorks_RemoveComment()
198
225
Assert . AreEqual ( expectedCode , module . Lines ( ) ) ;
199
226
}
200
227
228
+ [ TestMethod ]
229
+ [ TestCategory ( "Inspections" ) ]
230
+ public void ObsoleteCommentSyntax_QuickFixWorks_UpdateComment_LineHasCode ( )
231
+ {
232
+ const string inputCode =
233
+ @"Dim Foo As Integer: Rem This is a comment" ;
234
+
235
+ const string expectedCode =
236
+ @"Dim Foo As Integer: ' This is a comment" ;
237
+
238
+ //Arrange
239
+ var builder = new MockVbeBuilder ( ) ;
240
+ VBComponent component ;
241
+ var vbe = builder . BuildFromSingleStandardModule ( inputCode , out component ) ;
242
+ var project = vbe . Object . VBProjects . Item ( 0 ) ;
243
+ var module = project . VBComponents . Item ( 0 ) . CodeModule ;
244
+ var mockHost = new Mock < IHostApplication > ( ) ;
245
+ mockHost . SetupAllProperties ( ) ;
246
+ var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object , new Mock < ISinks > ( ) . Object ) ) ;
247
+
248
+ parser . Parse ( new CancellationTokenSource ( ) ) ;
249
+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
250
+
251
+ var inspection = new ObsoleteCommentSyntaxInspection ( parser . State ) ;
252
+ var inspectionResults = inspection . GetInspectionResults ( ) ;
253
+
254
+ inspectionResults . First ( ) . QuickFixes . First ( ) . Fix ( ) ;
255
+
256
+ Assert . AreEqual ( expectedCode , module . Lines ( ) ) ;
257
+ }
258
+
259
+ [ TestMethod ]
260
+ [ TestCategory ( "Inspections" ) ]
261
+ public void ObsoleteCommentSyntax_QuickFixWorks_RemoveComment_LineHasCode ( )
262
+ {
263
+ const string inputCode =
264
+ @"Dim Foo As Integer: Rem This is a comment" ;
265
+
266
+ const string expectedCode =
267
+ @"Dim Foo As Integer:" ;
268
+
269
+ //Arrange
270
+ var builder = new MockVbeBuilder ( ) ;
271
+ VBComponent component ;
272
+ var vbe = builder . BuildFromSingleStandardModule ( inputCode , out component ) ;
273
+ var project = vbe . Object . VBProjects . Item ( 0 ) ;
274
+ var module = project . VBComponents . Item ( 0 ) . CodeModule ;
275
+ var mockHost = new Mock < IHostApplication > ( ) ;
276
+ mockHost . SetupAllProperties ( ) ;
277
+ var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object , new Mock < ISinks > ( ) . Object ) ) ;
278
+
279
+ parser . Parse ( new CancellationTokenSource ( ) ) ;
280
+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
281
+
282
+ var inspection = new ObsoleteCommentSyntaxInspection ( parser . State ) ;
283
+ var inspectionResults = inspection . GetInspectionResults ( ) ;
284
+
285
+ inspectionResults . First ( ) . QuickFixes . ElementAt ( 1 ) . Fix ( ) ;
286
+
287
+ Assert . AreEqual ( expectedCode , module . Lines ( ) ) ;
288
+ }
289
+
201
290
[ TestMethod ]
202
291
[ TestCategory ( "Inspections" ) ]
203
292
public void ObsoleteCommentSyntax_IgnoreQuickFixWorks ( )
0 commit comments