@@ -1576,6 +1576,68 @@ Private Sub abc_Foo(ByVal arg2 As String, ByVal arg1 As Integer)
1576
1576
Assert . AreEqual ( expectedCode2 , module2 . Lines ( ) ) ;
1577
1577
}
1578
1578
1579
+ [ TestMethod ]
1580
+ public void ReorderParametersRefactoring_EventParamsSwapped_EventImplementationSelected ( )
1581
+ {
1582
+ //Input
1583
+ const string inputCode1 =
1584
+ @"Private WithEvents abc As Class2
1585
+
1586
+ Private Sub abc_Foo(ByVal arg1 As Integer, ByVal arg2 As String)
1587
+ End Sub" ;
1588
+
1589
+ const string inputCode2 =
1590
+ @"Public Event Foo(ByVal arg1 As Integer, ByVal arg2 As String)" ;
1591
+
1592
+ var selection = new Selection ( 3 , 15 , 3 , 15 ) ;
1593
+
1594
+ //Expectation
1595
+ const string expectedCode1 =
1596
+ @"Private WithEvents abc As Class2
1597
+
1598
+ Private Sub abc_Foo(ByVal arg2 As String, ByVal arg1 As Integer)
1599
+ End Sub" ; // note: IDE removes excess spaces
1600
+
1601
+ const string expectedCode2 =
1602
+ @"Public Event Foo(ByVal arg2 As String, ByVal arg1 As Integer)" ;
1603
+
1604
+ //Arrange
1605
+ var builder = new MockVbeBuilder ( ) ;
1606
+ var project = builder . ProjectBuilder ( "TestProject1" , vbext_ProjectProtection . vbext_pp_none )
1607
+ . AddComponent ( "Class1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode1 )
1608
+ . AddComponent ( "Class2" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
1609
+ . Build ( ) ;
1610
+ var vbe = builder . AddProject ( project ) . Build ( ) ;
1611
+ var component = project . Object . VBComponents . Item ( 0 ) ;
1612
+
1613
+ var codePaneFactory = new CodePaneWrapperFactory ( ) ;
1614
+ var mockHost = new Mock < IHostApplication > ( ) ;
1615
+ mockHost . SetupAllProperties ( ) ;
1616
+ var parser = new RubberduckParser ( vbe . Object , new RubberduckParserState ( ) ) ;
1617
+
1618
+ parser . Parse ( ) ;
1619
+ if ( parser . State . Status == ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
1620
+
1621
+ var qualifiedSelection = new QualifiedSelection ( new QualifiedModuleName ( component ) , selection ) ;
1622
+ var module1 = project . Object . VBComponents . Item ( 0 ) . CodeModule ;
1623
+ var module2 = project . Object . VBComponents . Item ( 1 ) . CodeModule ;
1624
+
1625
+ //Specify Params to remove
1626
+ var model = new ReorderParametersModel ( parser . State , qualifiedSelection , null ) ;
1627
+ model . Parameters . Reverse ( ) ;
1628
+
1629
+ //SetupFactory
1630
+ var factory = SetupFactory ( model ) ;
1631
+
1632
+ //Act
1633
+ var refactoring = new ReorderParametersRefactoring ( factory . Object , new ActiveCodePaneEditor ( vbe . Object , codePaneFactory ) , null ) ;
1634
+ refactoring . Refactor ( qualifiedSelection ) ;
1635
+
1636
+ //Assert
1637
+ Assert . AreEqual ( expectedCode1 , module1 . Lines ( ) ) ;
1638
+ Assert . AreEqual ( expectedCode2 , module2 . Lines ( ) ) ;
1639
+ }
1640
+
1579
1641
[ TestMethod ]
1580
1642
public void ReorderParametersRefactoring_EventParamsSwapped_DifferentParamNames ( )
1581
1643
{
0 commit comments