@@ -5109,6 +5109,157 @@ public void ShadowedDeclaration_DoesNotReturnResult_EventParameterWithSameNameAs
5109
5109
Assert . IsFalse ( inspectionResults . Any ( ) ) ;
5110
5110
}
5111
5111
5112
+ [ Test ]
5113
+ [ Category ( "Inspections" ) ]
5114
+ [ TestCase ( "" , "As Object" , "" ) ] //Variable
5115
+ [ TestCase ( "Function" , "As Object" , "End Function" ) ]
5116
+ [ TestCase ( "Sub" , "" , "End Sub" ) ]
5117
+ [ TestCase ( "Property Get" , "As Object" , "End Property" ) ]
5118
+ [ TestCase ( "Property Let" , "" , "End Property" ) ]
5119
+ [ TestCase ( "Property Set" , "" , "End Property" ) ]
5120
+ public void ShadowedDeclaration_DoesNotReturnResult_AssertBecauseOfDebugAssert ( string memberType , string asTypeClause , string endTag )
5121
+ {
5122
+ var code =
5123
+ $@ "Public { memberType } Assert() { asTypeClause }
5124
+ { endTag } ";
5125
+
5126
+ var vbe = new MockVbeBuilder ( )
5127
+ . ProjectBuilder ( "TestProject" , ProjectProtection . Unprotected )
5128
+ . AddComponent ( "TestClass" , ComponentType . ClassModule , code )
5129
+ . AddReference ( "VBA" , MockVbeBuilder . LibraryPathVBA , 4 , 2 , true )
5130
+ . AddProjectToVbeBuilder ( )
5131
+ . Build ( ) ;
5132
+
5133
+ IEnumerable < IInspectionResult > inspectionResults ;
5134
+ using ( var state = MockParser . CreateAndParse ( vbe . Object ) )
5135
+ {
5136
+ var inspection = new ShadowedDeclarationInspection ( state ) ;
5137
+ inspectionResults = inspection . GetInspectionResults ( CancellationToken . None ) ;
5138
+ }
5139
+
5140
+ Assert . IsFalse ( inspectionResults . Any ( ) ) ;
5141
+ }
5142
+
5143
+ [ Test ]
5144
+ [ Category ( "Inspections" ) ]
5145
+ public void ShadowedDeclaration_DoesNotReturnResult_LocalAssertVariableAssertBecauseOfDebugAssert ( )
5146
+ {
5147
+ var code =
5148
+ @"Public Sub Foo()
5149
+ Dim Assert As Long
5150
+ End Sub" ;
5151
+
5152
+ var vbe = new MockVbeBuilder ( )
5153
+ . ProjectBuilder ( "TestProject" , ProjectProtection . Unprotected )
5154
+ . AddComponent ( "TestClass" , ComponentType . ClassModule , code )
5155
+ . AddReference ( "VBA" , MockVbeBuilder . LibraryPathVBA , 4 , 2 , true )
5156
+ . AddProjectToVbeBuilder ( )
5157
+ . Build ( ) ;
5158
+
5159
+ IEnumerable < IInspectionResult > inspectionResults ;
5160
+ using ( var state = MockParser . CreateAndParse ( vbe . Object ) )
5161
+ {
5162
+ var inspection = new ShadowedDeclarationInspection ( state ) ;
5163
+ inspectionResults = inspection . GetInspectionResults ( CancellationToken . None ) ;
5164
+ }
5165
+
5166
+ Assert . IsFalse ( inspectionResults . Any ( ) ) ;
5167
+ }
5168
+
5169
+ [ Test ]
5170
+ [ Category ( "Inspections" ) ]
5171
+ public void ShadowedDeclaration_DoesNotReturnResult_AssertParameterAssertBecauseOfDebugAssert ( )
5172
+ {
5173
+ var code =
5174
+ @"Public Sub Foo(Assert As Boolean)
5175
+ End Sub" ;
5176
+
5177
+ var vbe = new MockVbeBuilder ( )
5178
+ . ProjectBuilder ( "TestProject" , ProjectProtection . Unprotected )
5179
+ . AddComponent ( "TestClass" , ComponentType . ClassModule , code )
5180
+ . AddReference ( "VBA" , MockVbeBuilder . LibraryPathVBA , 4 , 2 , true )
5181
+ . AddProjectToVbeBuilder ( )
5182
+ . Build ( ) ;
5183
+
5184
+ IEnumerable < IInspectionResult > inspectionResults ;
5185
+ using ( var state = MockParser . CreateAndParse ( vbe . Object ) )
5186
+ {
5187
+ var inspection = new ShadowedDeclarationInspection ( state ) ;
5188
+ inspectionResults = inspection . GetInspectionResults ( CancellationToken . None ) ;
5189
+ }
5190
+
5191
+ Assert . IsFalse ( inspectionResults . Any ( ) ) ;
5192
+ }
5193
+
5194
+ [ Test ]
5195
+ [ Category ( "Inspections" ) ]
5196
+ [ TestCase ( "" , "As Object" , "" ) ] //Variable
5197
+ [ TestCase ( "Function" , "As Object" , "End Function" ) ]
5198
+ [ TestCase ( "Sub" , "" , "End Sub" ) ]
5199
+ [ TestCase ( "Property Get" , "As Object" , "End Property" ) ]
5200
+ [ TestCase ( "Property Let" , "" , "End Property" ) ]
5201
+ [ TestCase ( "Property Set" , "" , "End Property" ) ]
5202
+ public void ShadowedDeclaration_ReturnResult_LocalAssertVariableAssertBecauseOfNonDebugAssert ( string memberType , string asTypeClause , string endTag )
5203
+ {
5204
+ var code =
5205
+ $@ "Public { memberType } Assert() { asTypeClause }
5206
+ { endTag }
5207
+
5208
+ Public Sub Foo()
5209
+ Dim Assert As Long
5210
+ End Sub" ;
5211
+
5212
+ var vbe = new MockVbeBuilder ( )
5213
+ . ProjectBuilder ( "TestProject" , ProjectProtection . Unprotected )
5214
+ . AddComponent ( "TestClass" , ComponentType . ClassModule , code )
5215
+ . AddReference ( "VBA" , MockVbeBuilder . LibraryPathVBA , 4 , 2 , true )
5216
+ . AddProjectToVbeBuilder ( )
5217
+ . Build ( ) ;
5218
+
5219
+ IEnumerable < IInspectionResult > inspectionResults ;
5220
+ using ( var state = MockParser . CreateAndParse ( vbe . Object ) )
5221
+ {
5222
+ var inspection = new ShadowedDeclarationInspection ( state ) ;
5223
+ inspectionResults = inspection . GetInspectionResults ( CancellationToken . None ) ;
5224
+ }
5225
+
5226
+ Assert . AreEqual ( 1 , inspectionResults . Count ( ) ) ;
5227
+ }
5228
+
5229
+ [ Test ]
5230
+ [ Category ( "Inspections" ) ]
5231
+ [ TestCase ( "" , "As Object" , "" ) ] //Variable
5232
+ [ TestCase ( "Function" , "As Object" , "End Function" ) ]
5233
+ [ TestCase ( "Sub" , "" , "End Sub" ) ]
5234
+ [ TestCase ( "Property Get" , "As Object" , "End Property" ) ]
5235
+ [ TestCase ( "Property Let" , "" , "End Property" ) ]
5236
+ [ TestCase ( "Property Set" , "" , "End Property" ) ]
5237
+ public void ShadowedDeclaration_ReturnResult_AssertParameterAssertBecauseOfNonDebugAssert ( string memberType , string asTypeClause , string endTag )
5238
+ {
5239
+ var code =
5240
+ $@ "Public { memberType } Assert() { asTypeClause }
5241
+ { endTag }
5242
+
5243
+ Public Sub Foo(Assert As Boolean)
5244
+ End Sub" ;
5245
+
5246
+ var vbe = new MockVbeBuilder ( )
5247
+ . ProjectBuilder ( "TestProject" , ProjectProtection . Unprotected )
5248
+ . AddComponent ( "TestClass" , ComponentType . ClassModule , code )
5249
+ . AddReference ( "VBA" , MockVbeBuilder . LibraryPathVBA , 4 , 2 , true )
5250
+ . AddProjectToVbeBuilder ( )
5251
+ . Build ( ) ;
5252
+
5253
+ IEnumerable < IInspectionResult > inspectionResults ;
5254
+ using ( var state = MockParser . CreateAndParse ( vbe . Object ) )
5255
+ {
5256
+ var inspection = new ShadowedDeclarationInspection ( state ) ;
5257
+ inspectionResults = inspection . GetInspectionResults ( CancellationToken . None ) ;
5258
+ }
5259
+
5260
+ Assert . AreEqual ( 1 , inspectionResults . Count ( ) ) ;
5261
+ }
5262
+
5112
5263
[ Test ]
5113
5264
[ Category ( "Inspections" ) ]
5114
5265
public void ShadowedDeclaration_Ignored_DoesNotReturnResult ( )
0 commit comments