Skip to content

Commit

Permalink
added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
retailcoder committed Apr 20, 2021
1 parent ad162f1 commit 16fb51c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Expand Up @@ -175,6 +175,27 @@ End Function
Assert.AreEqual(0, InspectionResultsForModules(modules, ReferenceLibrary.Excel, DefaultDocumentModuleSupertypeNames).Count());
}

[Test]
[Category("Inspections")]
public void ImplicitActiveSheetReference_NoResultForWorksheetProperty()
{
const string inputCode =
@"Sub foo()
Debug.Print GetSheet.Cells(1, 1)
End Sub
Private Property Get GetSheet() As Worksheet
End Property
";
var modules = new (string, string, ComponentType)[]
{
("ThisWorkbook", string.Empty, ComponentType.Document),
("Sheet1", string.Empty, ComponentType.Document),
("Module1", inputCode, ComponentType.StandardModule)
};
Assert.AreEqual(0, InspectionResultsForModules(modules, ReferenceLibrary.Excel, DefaultDocumentModuleSupertypeNames).Count());
}

[Test]
[Category("Inspections")]
public void ImplicitActiveSheetReference_Ignored_DoesNotReportRange()
Expand Down
Expand Up @@ -142,6 +142,22 @@ End Function
Assert.AreEqual(0, InspectionResultsInWorksheet(inputCode).Count());
}

[Test]
[Category("Inspections")]
public void ImplicitContainingSheetReference_NoResultForWorksheetProperty()
{
const string inputCode =
@"Sub foo()
Dim arr1 As Variant
arr1 = GetSheet.Range(""A1:B2"")
End Sub
Property Get GetSheet() As Worksheet
End Property
";
Assert.AreEqual(0, InspectionResultsInWorksheet(inputCode).Count());
}

[Test]
[Category("Inspections")]
public void InspectionName()
Expand Down

0 comments on commit 16fb51c

Please sign in to comment.