@@ -286,6 +286,68 @@ Dim var1 As Variant
286
286
Assert . AreEqual ( expectedCode , module . Lines ( ) ) ;
287
287
}
288
288
289
+ [ TestMethod ]
290
+ [ TestCategory ( "Inspections" ) ]
291
+ public void VariableTypeNotDeclared_ReturnsResult_QuickFixWorks_ParameterWithoutDefaultValue ( )
292
+ {
293
+ const string inputCode =
294
+ @"Sub Foo(ByVal Fizz)
295
+ End Sub" ;
296
+
297
+ const string expectedCode =
298
+ @"Sub Foo(ByVal Fizz As Variant)
299
+ End Sub" ;
300
+
301
+ //Arrange
302
+ var builder = new MockVbeBuilder ( ) ;
303
+ VBComponent component ;
304
+ var vbe = builder . BuildFromSingleStandardModule ( inputCode , out component ) ;
305
+ var project = vbe . Object . VBProjects . Item ( 0 ) ;
306
+ var module = project . VBComponents . Item ( 0 ) . CodeModule ;
307
+ var mockHost = new Mock < IHostApplication > ( ) ;
308
+ mockHost . SetupAllProperties ( ) ;
309
+ var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object , new Mock < ISinks > ( ) . Object ) ) ;
310
+
311
+ parser . Parse ( new CancellationTokenSource ( ) ) ;
312
+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
313
+
314
+ var inspection = new VariableTypeNotDeclaredInspection ( parser . State ) ;
315
+ inspection . GetInspectionResults ( ) . First ( ) . QuickFixes . First ( ) . Fix ( ) ;
316
+
317
+ Assert . AreEqual ( expectedCode , module . Lines ( ) ) ;
318
+ }
319
+
320
+ [ TestMethod ]
321
+ [ TestCategory ( "Inspections" ) ]
322
+ public void VariableTypeNotDeclared_ReturnsResult_QuickFixWorks_ParameterWithDefaultValue ( )
323
+ {
324
+ const string inputCode =
325
+ @"Sub Foo(ByVal Fizz = False)
326
+ End Sub" ;
327
+
328
+ const string expectedCode =
329
+ @"Sub Foo(ByVal Fizz As Variant = False)
330
+ End Sub" ;
331
+
332
+ //Arrange
333
+ var builder = new MockVbeBuilder ( ) ;
334
+ VBComponent component ;
335
+ var vbe = builder . BuildFromSingleStandardModule ( inputCode , out component ) ;
336
+ var project = vbe . Object . VBProjects . Item ( 0 ) ;
337
+ var module = project . VBComponents . Item ( 0 ) . CodeModule ;
338
+ var mockHost = new Mock < IHostApplication > ( ) ;
339
+ mockHost . SetupAllProperties ( ) ;
340
+ var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object , new Mock < ISinks > ( ) . Object ) ) ;
341
+
342
+ parser . Parse ( new CancellationTokenSource ( ) ) ;
343
+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
344
+
345
+ var inspection = new VariableTypeNotDeclaredInspection ( parser . State ) ;
346
+ inspection . GetInspectionResults ( ) . First ( ) . QuickFixes . First ( ) . Fix ( ) ;
347
+
348
+ Assert . AreEqual ( expectedCode , module . Lines ( ) ) ;
349
+ }
350
+
289
351
[ TestMethod ]
290
352
[ TestCategory ( "Inspections" ) ]
291
353
public void InspectionType ( )
0 commit comments