@@ -4842,8 +4842,34 @@ public void ShadowedDeclaration_DoesNotReturnResult_DeclarationsInsideClassModul
4842
4842
4843
4843
[ TestMethod ]
4844
4844
[ TestCategory ( "Inspections" ) ]
4845
- public void ShadowedDeclaration_DoesNotReturnResult_DeclarationsInsideClassModuleInContainingProject ( )
4845
+ public void ShadowedDeclaration_ReturnsCorrectResult_DeclarationsInsideClassModuleInContainingProject ( )
4846
4846
{
4847
+ var expectedResultCountsByDeclarationIdentifierName = new Dictionary < string , int >
4848
+ {
4849
+ [ ProjectName ] = 0 ,
4850
+ [ ProceduralModuleName ] = 0 ,
4851
+ [ ClassModuleName ] = 0 ,
4852
+ [ UserFormName ] = 0 ,
4853
+ [ DocumentName ] = 0 ,
4854
+ [ ProcedureName ] = 1 ,
4855
+ [ FunctionName ] = 1 ,
4856
+ [ PropertyGetName ] = 1 ,
4857
+ [ PropertySetName ] = 1 ,
4858
+ [ PropertyLetName ] = 1 ,
4859
+ [ ParameterName ] = 0 ,
4860
+ [ VariableName ] = 1 ,
4861
+ [ LocalVariableName ] = 0 ,
4862
+ [ ConstantName ] = 0 ,
4863
+ [ LocalConstantName ] = 0 ,
4864
+ [ EnumerationName ] = 1 ,
4865
+ [ EnumerationMemberName ] = 1 ,
4866
+ [ UserDefinedTypeName ] = 0 ,
4867
+ [ UserDefinedTypeMemberName ] = 0 ,
4868
+ [ LibraryProcedureName ] = 0 ,
4869
+ [ LibraryFunctionName ] = 0 ,
4870
+ [ LineLabelName ] = 0
4871
+ } ;
4872
+
4847
4873
var builder = TestVbeWithUserProjectWithAdditionalComponent (
4848
4874
additionalComponentName : "Foo" ,
4849
4875
additionalComponentComponentType : ComponentType . ClassModule ,
@@ -4854,10 +4880,13 @@ public void ShadowedDeclaration_DoesNotReturnResult_DeclarationsInsideClassModul
4854
4880
using ( var state = MockParser . CreateAndParse ( vbe . Object ) )
4855
4881
{
4856
4882
var inspection = new ShadowedDeclarationInspection ( state ) ;
4857
- inspectionResults = inspection . GetInspectionResults ( ) ;
4883
+ inspectionResults = inspection . GetInspectionResults ( ) . ToList ( ) ;
4858
4884
}
4885
+ var inspectionResultCounts = InspectionResultCountsByTargetIdentifierName ( inspectionResults ) ;
4859
4886
4860
- Assert . IsFalse ( inspectionResults . Any ( ) ) ;
4887
+ AssertResultCountsEqualForThoseWithExpectation ( expectedResultCountsByDeclarationIdentifierName , inspectionResultCounts ) ;
4888
+ //All shadowing happens inside the class module.
4889
+ Assert . IsTrue ( inspectionResults . All ( result => result . Target . QualifiedName . QualifiedModuleName . ComponentName == "Foo" ) ) ;
4861
4890
}
4862
4891
4863
4892
[ TestMethod ]
@@ -4883,8 +4912,34 @@ public void ShadowedDeclaration_DoesNotReturnResult_DeclarationsInsideUserFormIn
4883
4912
4884
4913
[ TestMethod ]
4885
4914
[ TestCategory ( "Inspections" ) ]
4886
- public void ShadowedDeclaration_DoesNotReturnResult_DeclarationsInsideUserFormInContainingProject ( )
4915
+ public void ShadowedDeclaration_ReturnsCorrectResult_DeclarationsInsideUserFormInContainingProject ( )
4887
4916
{
4917
+ var expectedResultCountsByDeclarationIdentifierName = new Dictionary < string , int >
4918
+ {
4919
+ [ ProjectName ] = 0 ,
4920
+ [ ProceduralModuleName ] = 0 ,
4921
+ [ ClassModuleName ] = 0 ,
4922
+ [ UserFormName ] = 0 ,
4923
+ [ DocumentName ] = 0 ,
4924
+ [ ProcedureName ] = 1 ,
4925
+ [ FunctionName ] = 1 ,
4926
+ [ PropertyGetName ] = 1 ,
4927
+ [ PropertySetName ] = 1 ,
4928
+ [ PropertyLetName ] = 1 ,
4929
+ [ ParameterName ] = 0 ,
4930
+ [ VariableName ] = 1 ,
4931
+ [ LocalVariableName ] = 0 ,
4932
+ [ ConstantName ] = 0 ,
4933
+ [ LocalConstantName ] = 0 ,
4934
+ [ EnumerationName ] = 1 ,
4935
+ [ EnumerationMemberName ] = 1 ,
4936
+ [ UserDefinedTypeName ] = 0 ,
4937
+ [ UserDefinedTypeMemberName ] = 0 ,
4938
+ [ LibraryProcedureName ] = 0 ,
4939
+ [ LibraryFunctionName ] = 0 ,
4940
+ [ LineLabelName ] = 0
4941
+ } ;
4942
+
4888
4943
var builder = TestVbeWithUserProjectWithAdditionalComponent (
4889
4944
additionalComponentName : "Foo" ,
4890
4945
additionalComponentComponentType : ComponentType . UserForm ,
@@ -4895,10 +4950,13 @@ public void ShadowedDeclaration_DoesNotReturnResult_DeclarationsInsideUserFormIn
4895
4950
using ( var state = MockParser . CreateAndParse ( vbe . Object ) )
4896
4951
{
4897
4952
var inspection = new ShadowedDeclarationInspection ( state ) ;
4898
- inspectionResults = inspection . GetInspectionResults ( ) ;
4953
+ inspectionResults = inspection . GetInspectionResults ( ) . ToList ( ) ;
4899
4954
}
4955
+ var inspectionResultCounts = InspectionResultCountsByTargetIdentifierName ( inspectionResults ) ;
4900
4956
4901
- Assert . IsFalse ( inspectionResults . Any ( ) ) ;
4957
+ AssertResultCountsEqualForThoseWithExpectation ( expectedResultCountsByDeclarationIdentifierName , inspectionResultCounts ) ;
4958
+ //All shadowing happens inside the user form.
4959
+ Assert . IsTrue ( inspectionResults . All ( result => result . Target . QualifiedName . QualifiedModuleName . ComponentName == "Foo" ) ) ;
4902
4960
}
4903
4961
4904
4962
[ TestMethod ]
@@ -4924,8 +4982,34 @@ public void ShadowedDeclaration_DoesNotReturnResult_DeclarationsInsideDocumentIn
4924
4982
4925
4983
[ TestMethod ]
4926
4984
[ TestCategory ( "Inspections" ) ]
4927
- public void ShadowedDeclaration_DoesNotReturnResult_DeclarationsInsideDocumentInContainingProject ( )
4985
+ public void ShadowedDeclaration_ReturnsCorrectResult_DeclarationsInsideDocumentInContainingProject ( )
4928
4986
{
4987
+ var expectedResultCountsByDeclarationIdentifierName = new Dictionary < string , int >
4988
+ {
4989
+ [ ProjectName ] = 0 ,
4990
+ [ ProceduralModuleName ] = 0 ,
4991
+ [ ClassModuleName ] = 0 ,
4992
+ [ UserFormName ] = 0 ,
4993
+ [ DocumentName ] = 0 ,
4994
+ [ ProcedureName ] = 1 ,
4995
+ [ FunctionName ] = 1 ,
4996
+ [ PropertyGetName ] = 1 ,
4997
+ [ PropertySetName ] = 1 ,
4998
+ [ PropertyLetName ] = 1 ,
4999
+ [ ParameterName ] = 0 ,
5000
+ [ VariableName ] = 1 ,
5001
+ [ LocalVariableName ] = 0 ,
5002
+ [ ConstantName ] = 0 ,
5003
+ [ LocalConstantName ] = 0 ,
5004
+ [ EnumerationName ] = 1 ,
5005
+ [ EnumerationMemberName ] = 1 ,
5006
+ [ UserDefinedTypeName ] = 0 ,
5007
+ [ UserDefinedTypeMemberName ] = 0 ,
5008
+ [ LibraryProcedureName ] = 0 ,
5009
+ [ LibraryFunctionName ] = 0 ,
5010
+ [ LineLabelName ] = 0
5011
+ } ;
5012
+
4929
5013
var builder = TestVbeWithUserProjectWithAdditionalComponent (
4930
5014
additionalComponentName : "Foo" ,
4931
5015
additionalComponentComponentType : ComponentType . Document ,
@@ -4936,10 +5020,13 @@ public void ShadowedDeclaration_DoesNotReturnResult_DeclarationsInsideDocumentIn
4936
5020
using ( var state = MockParser . CreateAndParse ( vbe . Object ) )
4937
5021
{
4938
5022
var inspection = new ShadowedDeclarationInspection ( state ) ;
4939
- inspectionResults = inspection . GetInspectionResults ( ) ;
5023
+ inspectionResults = inspection . GetInspectionResults ( ) . ToList ( ) ;
4940
5024
}
5025
+ var inspectionResultCounts = InspectionResultCountsByTargetIdentifierName ( inspectionResults ) ;
4941
5026
4942
- Assert . IsFalse ( inspectionResults . Any ( ) ) ;
5027
+ AssertResultCountsEqualForThoseWithExpectation ( expectedResultCountsByDeclarationIdentifierName , inspectionResultCounts ) ;
5028
+ //All shadowing happens inside the document module.
5029
+ Assert . IsTrue ( inspectionResults . All ( result => result . Target . QualifiedName . QualifiedModuleName . ComponentName == "Foo" ) ) ;
4943
5030
}
4944
5031
4945
5032
[ TestMethod ]
0 commit comments