Skip to content

Commit 9229fba

Browse files
committed
Add failing test, reproducing #3284
1 parent a2261ef commit 9229fba

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

RubberduckTests/Refactoring/RenameTests.cs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,67 @@ End Sub"
17931793
tdo.MsgBox.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxButtons>(), It.IsAny<MessageBoxIcon>()), Times.Never);
17941794
}
17951795
#endregion
1796+
#region Property Tests
1797+
[Test]
1798+
[Category("Refactorings")]
1799+
[Category("Rename")]
1800+
public void RenameRefactoring_RefactorProperties_UpdatesReferences()
1801+
{
1802+
var oldName = "Column";
1803+
var refactoredName = "Rank";
1804+
1805+
var tdo = new RenameTestsDataObject(oldName, refactoredName );
1806+
var classInputOutput = new RenameTestModuleDefinition("MyClass", ComponentType.ClassModule)
1807+
{
1808+
Input = $@"Option Explicit
1809+
1810+
Private colValue As Long
1811+
1812+
Public Property Get {oldName}() As Long
1813+
{oldName} = colValue
1814+
End Property
1815+
Public Property Let |{oldName}(value As Long)
1816+
colValue = value
1817+
End Property
1818+
",
1819+
Expected = $@"Option Explicit
1820+
1821+
Private colValue As Long
1822+
1823+
Public Property Get {refactoredName}() As Long
1824+
{refactoredName} = colValue
1825+
End Property
1826+
Public Property Let {refactoredName}(value As Long)
1827+
colValue = value
1828+
End Property
1829+
"
1830+
};
1831+
var usageInputOutput = new RenameTestModuleDefinition("Usage", ComponentType.StandardModule)
1832+
{
1833+
Input = $@"Option Explicit
1834+
1835+
Public Sub useColValue()
1836+
Dim instance As MyClass
1837+
Set instance = New MyClass
1838+
instance.{oldName} = 97521
1839+
Debug.Print instance.{oldName};""is the value""
1840+
End Sub
1841+
", Expected = $@"Option Explicit
1842+
1843+
Public Sub useColValue()
1844+
Dim instance As MyClass
1845+
Set instance = New MyClass
1846+
instance.{refactoredName} = 97521
1847+
Debug.Print instance.{refactoredName};""is the value""
1848+
End Sub
1849+
"
1850+
};
1851+
tdo.RefactorParamType = RefactorParams.Declaration;
1852+
PerformExpectedVersusActualRenameTests(tdo, classInputOutput, usageInputOutput);
1853+
tdo.MsgBox.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxButtons>(), It.IsAny<MessageBoxIcon>()), Times.Never);
1854+
}
1855+
#endregion
1856+
17961857
#region Other Tests
17971858

17981859
[Test]

0 commit comments

Comments
 (0)