@@ -352,6 +352,67 @@ End Sub
352
352
Assert . AreEqual ( expectedCode , module . Lines ( ) ) ;
353
353
}
354
354
355
+ [ TestMethod ]
356
+ public void RemoveParametersRefactoring_ClientReferencesAreUpdated_ParensAroundCall ( )
357
+ {
358
+ //Input
359
+ const string inputCode =
360
+ @"Private Sub bar()
361
+ Dim x As Integer
362
+ Dim y As Integer
363
+ y = foo(x, 42)
364
+ Debug.Print y, x
365
+ End Sub
366
+
367
+ Private Function foo(ByRef a As Integer, ByVal b As Integer) As Integer
368
+ a = b
369
+ foo = a + b
370
+ End Function" ;
371
+ var selection = new Selection ( 8 , 20 , 8 , 20 ) ;
372
+
373
+ //Expectation
374
+ const string expectedCode =
375
+ @"Private Sub bar()
376
+ Dim x As Integer
377
+ Dim y As Integer
378
+ y = foo(42, x)
379
+ Debug.Print y, x
380
+ End Sub
381
+
382
+ Private Function foo(ByVal b As Integer, ByRef a As Integer) As Integer
383
+ a = b
384
+ foo = a + b
385
+ End Function" ;
386
+
387
+ //Arrange
388
+ var builder = new MockVbeBuilder ( ) ;
389
+ VBComponent component ;
390
+ var vbe = builder . BuildFromSingleStandardModule ( inputCode , out component , selection ) ;
391
+ var project = vbe . Object . VBProjects . Item ( 0 ) ;
392
+ var module = project . VBComponents . Item ( 0 ) . CodeModule ;
393
+ var mockHost = new Mock < IHostApplication > ( ) ;
394
+ mockHost . SetupAllProperties ( ) ;
395
+ var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( new Mock < ISinks > ( ) . Object ) ) ;
396
+
397
+ parser . Parse ( new CancellationTokenSource ( ) ) ;
398
+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
399
+
400
+ var qualifiedSelection = new QualifiedSelection ( new QualifiedModuleName ( component ) , selection ) ;
401
+
402
+ //set up model
403
+ var model = new ReorderParametersModel ( parser . State , qualifiedSelection , null ) ;
404
+ model . Parameters . Reverse ( ) ;
405
+
406
+ var factory = SetupFactory ( model ) ;
407
+
408
+ //act
409
+ var refactoring = new ReorderParametersRefactoring ( vbe . Object , factory . Object , null ) ;
410
+ refactoring . Refactor ( qualifiedSelection ) ;
411
+
412
+ //assert
413
+ Assert . AreEqual ( expectedCode , module . Lines ( ) ) ;
414
+ }
415
+
355
416
[ TestMethod ]
356
417
public void ReorderParametersRefactoring_ReorderNamedParams ( )
357
418
{
0 commit comments