@@ -330,6 +330,46 @@ public void ProcedureShouldBeFunction_QuickFixWorks()
330
330
Assert . AreEqual ( expectedCode , module . Lines ( ) ) ;
331
331
}
332
332
333
+ [ TestMethod ]
334
+ [ TestCategory ( "Inspections" ) ]
335
+ public void ProcedureShouldBeFunction_QuickFixWorks_NoAsTypeClauseInParam ( )
336
+ {
337
+ const string inputCode =
338
+ @"Private Sub Foo(ByRef arg1)
339
+ End Sub" ;
340
+
341
+ const string expectedCode =
342
+ @"Private Function Foo(ByVal arg1) As Variant
343
+ Foo = arg1
344
+ End Function" ;
345
+
346
+ //Arrange
347
+ var settings = new Mock < IGeneralConfigService > ( ) ;
348
+ var config = GetTestConfig ( ) ;
349
+ settings . Setup ( x => x . LoadConfiguration ( ) ) . Returns ( config ) ;
350
+
351
+ var builder = new MockVbeBuilder ( ) ;
352
+ VBComponent component ;
353
+ var vbe = builder . BuildFromSingleStandardModule ( inputCode , out component ) ;
354
+ var project = vbe . Object . VBProjects . Item ( 0 ) ;
355
+ var module = project . VBComponents . Item ( 0 ) . CodeModule ;
356
+ var mockHost = new Mock < IHostApplication > ( ) ;
357
+ mockHost . SetupAllProperties ( ) ;
358
+ var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object , new Mock < ISinks > ( ) . Object ) ) ;
359
+
360
+ parser . Parse ( new CancellationTokenSource ( ) ) ;
361
+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
362
+
363
+ var inspection = new ProcedureCanBeWrittenAsFunctionInspection ( parser . State ) ;
364
+ var inspector = new Inspector ( settings . Object , new IInspection [ ] { inspection } ) ;
365
+
366
+ var inspectionResults = inspector . FindIssuesAsync ( parser . State , CancellationToken . None ) . Result ;
367
+
368
+ inspectionResults . First ( ) . QuickFixes . First ( ) . Fix ( ) ;
369
+
370
+ Assert . AreEqual ( expectedCode , module . Lines ( ) ) ;
371
+ }
372
+
333
373
[ TestMethod ]
334
374
[ TestCategory ( "Inspections" ) ]
335
375
public void ProcedureShouldBeFunction_QuickFixWorks_DoesNotInterfereWithBody ( )
0 commit comments