@@ -416,6 +416,8 @@ End Sub"
416
416
//below can only be tested if implemented (and tested) within Excel.
417
417
418
418
[ Test , Ignore ( "" ) ]
419
+ [ Category ( "Refactorings" ) ]
420
+ [ Category ( "Rename" ) ]
419
421
public void RenameRefactoring_RenameControlFromEventHandler ( )
420
422
{
421
423
var tdo = new RenameTestsDataObject ( selection : "cmdBtn1" , newName : "cmdBigButton" ) ;
@@ -449,6 +451,8 @@ End Sub"
449
451
}
450
452
451
453
[ Test , Ignore ( "" ) ]
454
+ [ Category ( "Refactorings" ) ]
455
+ [ Category ( "Rename" ) ]
452
456
public void RenameRefactoring_RenameControlFromEventHandlerNameCollision ( )
453
457
{
454
458
var tdo = new RenameTestsDataObject ( selection : "cmdBtn1" , newName : "cmdBigButton" ) ;
@@ -484,6 +488,8 @@ End Sub"
484
488
}
485
489
486
490
[ Test , Ignore ( "" ) ]
491
+ [ Category ( "Refactorings" ) ]
492
+ [ Category ( "Rename" ) ]
487
493
public void RenameRefactoring_RenameControlRenameInReference ( )
488
494
{
489
495
var tdo = new RenameTestsDataObject ( selection : "cmdBtn1" , newName : "cmdBigButton" ) ;
@@ -519,6 +525,8 @@ End Sub"
519
525
}
520
526
521
527
[ Test , Ignore ( "" ) ]
528
+ [ Category ( "Refactorings" ) ]
529
+ [ Category ( "Rename" ) ]
522
530
public void RenameRefactoring_RenameControlFromEventHandlerReference ( )
523
531
{
524
532
var tdo = new RenameTestsDataObject ( selection : "cmdBtn1" , newName : "cmdBigButton" ) ;
@@ -554,6 +562,8 @@ End Sub"
554
562
}
555
563
556
564
[ Test , Ignore ( "" ) ]
565
+ [ Category ( "Refactorings" ) ]
566
+ [ Category ( "Rename" ) ]
557
567
public void RenameRefactoring_RenameControlHandlesUnderscoresInNewName ( )
558
568
{
559
569
var tdo = new RenameTestsDataObject ( selection : "bigButton_ClickAgain" , newName : "bigButton_ClickAgain_AndAgain" ) ;
@@ -571,6 +581,8 @@ End Sub"
571
581
}
572
582
573
583
[ Test , Ignore ( "" ) ]
584
+ [ Category ( "Refactorings" ) ]
585
+ [ Category ( "Rename" ) ]
574
586
public void RenameRefactoring_RenameControlSimilarNames ( )
575
587
{
576
588
var tdo = new RenameTestsDataObject ( selection : "bigButton" , newName : "smallButton" ) ;
@@ -1793,6 +1805,83 @@ End Sub"
1793
1805
tdo . MsgBox . Verify ( m => m . Show ( It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < MessageBoxButtons > ( ) , It . IsAny < MessageBoxIcon > ( ) ) , Times . Never ) ;
1794
1806
}
1795
1807
#endregion
1808
+ #region Property Tests
1809
+ [ Test ]
1810
+ [ Category ( "Refactorings" ) ]
1811
+ [ Category ( "Rename" ) ]
1812
+ public void RenameRefactoring_RefactorProperties_UpdatesReferences ( )
1813
+ {
1814
+ var oldName = "Column" ;
1815
+ var refactoredName = "Rank" ;
1816
+
1817
+ var classInputOutput = new RenameTestModuleDefinition ( "MyClass" , ComponentType . ClassModule )
1818
+ {
1819
+ Input = $@ "Option Explicit
1820
+
1821
+ Private colValue As Long
1822
+
1823
+ Public Property Get { oldName } () As Long
1824
+ { oldName } = colValue
1825
+ End Property
1826
+ Public Property Let { FAUX_CURSOR } { oldName } (value As Long)
1827
+ colValue = value
1828
+ End Property
1829
+ " ,
1830
+ Expected = $@ "Option Explicit
1831
+
1832
+ Private colValue As Long
1833
+
1834
+ Public Property Get { refactoredName } () As Long
1835
+ { refactoredName } = colValue
1836
+ End Property
1837
+ Public Property Let { refactoredName } (value As Long)
1838
+ colValue = value
1839
+ End Property
1840
+ "
1841
+ } ;
1842
+ var usageInputOutput = new RenameTestModuleDefinition ( "Usage" , ComponentType . StandardModule )
1843
+ {
1844
+ Input = $@ "Option Explicit
1845
+
1846
+ Public Sub useColValue()
1847
+ Dim instance As MyClass
1848
+ Set instance = New MyClass
1849
+ instance.{ oldName } = 97521
1850
+ Debug.Print instance.{ oldName } ;""is the value""
1851
+ End Sub
1852
+ " ,
1853
+ Expected = $@ "Option Explicit
1854
+
1855
+ Public Sub useColValue()
1856
+ Dim instance As MyClass
1857
+ Set instance = New MyClass
1858
+ instance.{ refactoredName } = 97521
1859
+ Debug.Print instance.{ refactoredName } ;""is the value""
1860
+ End Sub
1861
+ "
1862
+ } ;
1863
+
1864
+ var builder = new MockVbeBuilder ( ) ;
1865
+ var projectName = "Test" ;
1866
+ var vbe = builder . ProjectBuilder ( projectName , ProjectProtection . Unprotected )
1867
+ . AddReference ( "VBA" , MockVbeBuilder . LibraryPathVBA , major : 4 , minor : 1 , isBuiltIn : true )
1868
+ . AddComponent ( "MyClass" , ComponentType . ClassModule , classInputOutput . Input . Replace ( FAUX_CURSOR , "" ) )
1869
+ . AddComponent ( "Usage" , ComponentType . StandardModule , usageInputOutput . Input )
1870
+ . AddProjectToVbeBuilder ( )
1871
+ . Build ( ) ;
1872
+
1873
+ var tdo = new RenameTestsDataObject ( oldName , refactoredName )
1874
+ {
1875
+ VBE = vbe . Object ,
1876
+ RefactorParamType = RefactorParams . Declaration ,
1877
+ SelectionModuleName = "MyClass" ,
1878
+ ProjectName = projectName
1879
+ } ;
1880
+ PerformExpectedVersusActualRenameTests ( tdo , classInputOutput , usageInputOutput , testLibraries : new [ ] { "VBA.4.2.xml" } ) ;
1881
+ tdo . MsgBox . Verify ( m => m . Show ( It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < MessageBoxButtons > ( ) , It . IsAny < MessageBoxIcon > ( ) ) , Times . Never ) ;
1882
+ }
1883
+ #endregion
1884
+
1796
1885
#region Other Tests
1797
1886
1798
1887
[ Test ]
@@ -2012,11 +2101,12 @@ private static void PerformExpectedVersusActualRenameTests(RenameTestsDataObject
2012
2101
, RenameTestModuleDefinition ? inputOutput1
2013
2102
, RenameTestModuleDefinition ? inputOutput2 = null
2014
2103
, RenameTestModuleDefinition ? inputOutput3 = null
2015
- , RenameTestModuleDefinition ? inputOutput4 = null )
2104
+ , RenameTestModuleDefinition ? inputOutput4 = null
2105
+ , IEnumerable < string > testLibraries = null )
2016
2106
{
2017
2107
try
2018
2108
{
2019
- InitializeTestDataObject ( tdo , inputOutput1 , inputOutput2 , inputOutput3 , inputOutput4 ) ;
2109
+ InitializeTestDataObject ( tdo , inputOutput1 , inputOutput2 , inputOutput3 , inputOutput4 , testLibraries ) ;
2020
2110
RunRenameRefactorScenario ( tdo ) ;
2021
2111
CheckRenameRefactorTestResults ( tdo ) ;
2022
2112
}
@@ -2030,7 +2120,8 @@ private static void InitializeTestDataObject(RenameTestsDataObject tdo
2030
2120
, RenameTestModuleDefinition ? inputOutput1
2031
2121
, RenameTestModuleDefinition ? inputOutput2 = null
2032
2122
, RenameTestModuleDefinition ? inputOutput3 = null
2033
- , RenameTestModuleDefinition ? inputOutput4 = null )
2123
+ , RenameTestModuleDefinition ? inputOutput4 = null
2124
+ , IEnumerable < string > testLibraries = null )
2034
2125
{
2035
2126
var renameTMDs = new List < RenameTestModuleDefinition > ( ) ;
2036
2127
bool cursorFound = false ;
@@ -2071,7 +2162,7 @@ private static void InitializeTestDataObject(RenameTestsDataObject tdo
2071
2162
. Returns ( tdo . MsgBoxReturn ) ;
2072
2163
2073
2164
tdo . VBE = tdo . VBE ?? BuildProject ( tdo . ProjectName , tdo . ModuleTestSetupDefs ) ;
2074
- tdo . ParserState = MockParser . CreateAndParse ( tdo . VBE ) ;
2165
+ tdo . ParserState = MockParser . CreateAndParse ( tdo . VBE , testLibraries : testLibraries ) ;
2075
2166
2076
2167
CreateQualifiedSelectionForTestCase ( tdo ) ;
2077
2168
tdo . RenameModel = new RenameModel ( tdo . VBE , tdo . ParserState , tdo . QualifiedSelection ) { NewName = tdo . NewName } ;
@@ -2196,7 +2287,6 @@ private static IVBE BuildProject(string projectName, List<RenameTestModuleDefini
2196
2287
{
2197
2288
var builder = new MockVbeBuilder ( ) ;
2198
2289
var enclosingProjectBuilder = builder . ProjectBuilder ( projectName , ProjectProtection . Unprotected ) ;
2199
-
2200
2290
foreach ( var comp in testComponents )
2201
2291
{
2202
2292
if ( comp . ModuleType == ComponentType . UserForm )
0 commit comments