@@ -1419,6 +1419,68 @@ Private Sub abc_Foo(ByVal arg1 As Integer )
1419
1419
Assert . AreEqual ( expectedCode2 , module2 . Lines ( ) ) ;
1420
1420
}
1421
1421
1422
+ [ TestMethod ]
1423
+ public void ReorderParametersRefactoring_LastEventParamRemoved_EventImplementationSelected ( )
1424
+ {
1425
+ //Input
1426
+ const string inputCode1 =
1427
+ @"Private WithEvents abc As Class2
1428
+
1429
+ Private Sub abc_Foo(ByVal arg1 As Integer, ByVal arg2 As String)
1430
+ End Sub" ;
1431
+
1432
+ const string inputCode2 =
1433
+ @"Public Event Foo(ByVal arg1 As Integer, ByVal arg2 As String)" ;
1434
+
1435
+ var selection = new Selection ( 3 , 15 , 3 , 15 ) ;
1436
+
1437
+ //Expectation
1438
+ const string expectedCode1 =
1439
+ @"Private WithEvents abc As Class2
1440
+
1441
+ Private Sub abc_Foo(ByVal arg1 As Integer )
1442
+ End Sub" ; // note: IDE removes excess spaces
1443
+
1444
+ const string expectedCode2 =
1445
+ @"Public Event Foo(ByVal arg1 As Integer )" ;
1446
+
1447
+ //Arrange
1448
+ var builder = new MockVbeBuilder ( ) ;
1449
+ var project = builder . ProjectBuilder ( "TestProject1" , vbext_ProjectProtection . vbext_pp_none )
1450
+ . AddComponent ( "Class1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode1 )
1451
+ . AddComponent ( "Class2" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
1452
+ . Build ( ) ;
1453
+ var vbe = builder . AddProject ( project ) . Build ( ) ;
1454
+ var component = project . Object . VBComponents . Item ( 0 ) ;
1455
+
1456
+ var codePaneFactory = new CodePaneWrapperFactory ( ) ;
1457
+ var mockHost = new Mock < IHostApplication > ( ) ;
1458
+ mockHost . SetupAllProperties ( ) ;
1459
+ var parser = new RubberduckParser ( vbe . Object , new RubberduckParserState ( ) ) ;
1460
+
1461
+ parser . Parse ( ) ;
1462
+ if ( parser . State . Status == ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
1463
+
1464
+ var qualifiedSelection = new QualifiedSelection ( new QualifiedModuleName ( component ) , selection ) ;
1465
+ var module1 = project . Object . VBComponents . Item ( 0 ) . CodeModule ;
1466
+ var module2 = project . Object . VBComponents . Item ( 1 ) . CodeModule ;
1467
+
1468
+ //Specify Params to remove
1469
+ var model = new RemoveParametersModel ( parser . State , qualifiedSelection , null ) ;
1470
+ model . Parameters . Last ( ) . IsRemoved = true ;
1471
+
1472
+ //SetupFactory
1473
+ var factory = SetupFactory ( model ) ;
1474
+
1475
+ //Act
1476
+ var refactoring = new RemoveParametersRefactoring ( factory . Object , new ActiveCodePaneEditor ( vbe . Object , codePaneFactory ) ) ;
1477
+ refactoring . Refactor ( qualifiedSelection ) ;
1478
+
1479
+ //Assert
1480
+ Assert . AreEqual ( expectedCode1 , module1 . Lines ( ) ) ;
1481
+ Assert . AreEqual ( expectedCode2 , module2 . Lines ( ) ) ;
1482
+ }
1483
+
1422
1484
[ TestMethod ]
1423
1485
public void RemoveParametersRefactoring_LastEventParamRemoved_ParamsHaveDifferentNames ( )
1424
1486
{
0 commit comments