@@ -199,5 +199,76 @@ If True Then
199
199
200
200
Assert . IsFalse ( results . Any ( ) ) ;
201
201
}
202
+
203
+ [ TestMethod ]
204
+ [ TestCategory ( "Inspections" ) ]
205
+ public void BlockContainsPrefixComment ( )
206
+ {
207
+ const string inputcode =
208
+ @"Sub Foo()
209
+ Dim d
210
+ If True Then
211
+ ' test
212
+ d = True
213
+ Else
214
+ d = False
215
+ EndIf
216
+ End Sub" ;
217
+ var vbe = MockVbeBuilder . BuildFromSingleStandardModule ( inputcode , out _ ) ;
218
+ var state = MockParser . CreateAndParse ( vbe . Object ) ;
219
+
220
+ var inspection = new BooleanAssignedInIfElseInspection ( state ) ;
221
+ var inspector = InspectionsHelper . GetInspector ( inspection ) ;
222
+ var results = inspector . FindIssuesAsync ( state , CancellationToken . None ) . Result ;
223
+
224
+ Assert . AreEqual ( 1 , results . Count ( ) ) ;
225
+ }
226
+
227
+ [ TestMethod ]
228
+ [ TestCategory ( "Inspections" ) ]
229
+ public void BlockContainsPostfixComment ( )
230
+ {
231
+ const string inputcode =
232
+ @"Sub Foo()
233
+ Dim d
234
+ If True Then
235
+ d = True
236
+ ' test
237
+ Else
238
+ d = False
239
+ EndIf
240
+ End Sub" ;
241
+ var vbe = MockVbeBuilder . BuildFromSingleStandardModule ( inputcode , out _ ) ;
242
+ var state = MockParser . CreateAndParse ( vbe . Object ) ;
243
+
244
+ var inspection = new BooleanAssignedInIfElseInspection ( state ) ;
245
+ var inspector = InspectionsHelper . GetInspector ( inspection ) ;
246
+ var results = inspector . FindIssuesAsync ( state , CancellationToken . None ) . Result ;
247
+
248
+ Assert . AreEqual ( 1 , results . Count ( ) ) ;
249
+ }
250
+
251
+ [ TestMethod ]
252
+ [ TestCategory ( "Inspections" ) ]
253
+ public void BlockContainsEOLComment ( )
254
+ {
255
+ const string inputcode =
256
+ @"Sub Foo()
257
+ Dim d
258
+ If True Then
259
+ d = True ' test
260
+ Else
261
+ d = False
262
+ EndIf
263
+ End Sub" ;
264
+ var vbe = MockVbeBuilder . BuildFromSingleStandardModule ( inputcode , out _ ) ;
265
+ var state = MockParser . CreateAndParse ( vbe . Object ) ;
266
+
267
+ var inspection = new BooleanAssignedInIfElseInspection ( state ) ;
268
+ var inspector = InspectionsHelper . GetInspector ( inspection ) ;
269
+ var results = inspector . FindIssuesAsync ( state , CancellationToken . None ) . Result ;
270
+
271
+ Assert . AreEqual ( 1 , results . Count ( ) ) ;
272
+ }
202
273
}
203
274
}
0 commit comments