Skip to content

Commit 16fb51c

Browse files
committed
added more tests
1 parent ad162f1 commit 16fb51c

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

RubberduckTests/Inspections/ImplicitActiveSheetReferenceInspectionTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,27 @@ End Function
175175
Assert.AreEqual(0, InspectionResultsForModules(modules, ReferenceLibrary.Excel, DefaultDocumentModuleSupertypeNames).Count());
176176
}
177177

178+
[Test]
179+
[Category("Inspections")]
180+
public void ImplicitActiveSheetReference_NoResultForWorksheetProperty()
181+
{
182+
const string inputCode =
183+
@"Sub foo()
184+
Debug.Print GetSheet.Cells(1, 1)
185+
End Sub
186+
187+
Private Property Get GetSheet() As Worksheet
188+
End Property
189+
";
190+
var modules = new (string, string, ComponentType)[]
191+
{
192+
("ThisWorkbook", string.Empty, ComponentType.Document),
193+
("Sheet1", string.Empty, ComponentType.Document),
194+
("Module1", inputCode, ComponentType.StandardModule)
195+
};
196+
Assert.AreEqual(0, InspectionResultsForModules(modules, ReferenceLibrary.Excel, DefaultDocumentModuleSupertypeNames).Count());
197+
}
198+
178199
[Test]
179200
[Category("Inspections")]
180201
public void ImplicitActiveSheetReference_Ignored_DoesNotReportRange()

RubberduckTests/Inspections/ImplicitContainingSheetreferenceInspectionTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,22 @@ End Function
142142
Assert.AreEqual(0, InspectionResultsInWorksheet(inputCode).Count());
143143
}
144144

145+
[Test]
146+
[Category("Inspections")]
147+
public void ImplicitContainingSheetReference_NoResultForWorksheetProperty()
148+
{
149+
const string inputCode =
150+
@"Sub foo()
151+
Dim arr1 As Variant
152+
arr1 = GetSheet.Range(""A1:B2"")
153+
End Sub
154+
155+
Property Get GetSheet() As Worksheet
156+
End Property
157+
";
158+
Assert.AreEqual(0, InspectionResultsInWorksheet(inputCode).Count());
159+
}
160+
145161
[Test]
146162
[Category("Inspections")]
147163
public void InspectionName()

0 commit comments

Comments
 (0)