4
4
using RubberduckTests . Mocks ;
5
5
using Rubberduck . Inspections . Concrete ;
6
6
using Rubberduck . VBEditor . SafeComWrappers ;
7
+ using Rubberduck . Parsing . Inspections . Abstract ;
8
+ using Rubberduck . Parsing . VBA ;
7
9
8
10
namespace RubberduckTests . Inspections
9
11
{
10
12
[ TestFixture ]
11
- public class ImplementedInterfaceMemberInspectionTests
13
+ public class ImplementedInterfaceMemberInspectionTests : InspectionTestsBase
12
14
{
13
15
[ Test ]
14
16
[ Category ( "Inspections" ) ]
@@ -120,6 +122,35 @@ Sub IClass1_Qux()
120
122
CheckActualEmptyBlockCountEqualsExpected ( interfaceCode , concreteCode , 1 ) ;
121
123
}
122
124
125
+ //https://github.com/rubberduck-vba/Rubberduck/issues/5143
126
+ [ TestCase ( @"MsgBox ""?""" , "" , 1 ) ] //No implementers, only the annotation marks interface class
127
+ [ TestCase ( "" , "" , 0 ) ] //Annotated only, but no implementers - no result
128
+ [ TestCase ( @"MsgBox ""?""" , "Implements IClass1" , 1 ) ] //Annotated and an Implementer yields a single inspection result
129
+ [ Category ( "Inspections" ) ]
130
+ public void ImplementedInterfaceMember_AnnotatedOnly_ReturnsResult ( string interfaceBody , string implementsStatement , int expected )
131
+ {
132
+ string interfaceCode =
133
+ $@ "
134
+ '@Interface
135
+
136
+ Public Sub DoSomething(ByVal a As Integer)
137
+ End Sub
138
+ Public Sub DoSomethingElse(ByVal a As Integer)
139
+ { interfaceBody }
140
+ End Sub" ;
141
+ string concreteCode =
142
+ $@ "
143
+
144
+ { implementsStatement }
145
+
146
+ Private Sub IClass_DoSomething(ByVal a As Integer)
147
+ MsgBox ""?""
148
+ End Sub
149
+ Public Sub IClass_DoSomethingElse(ByVal a As Integer)
150
+ End Sub" ;
151
+ CheckActualEmptyBlockCountEqualsExpected ( interfaceCode , concreteCode , expected ) ;
152
+ }
153
+
123
154
private void CheckActualEmptyBlockCountEqualsExpected ( string interfaceCode , string concreteCode , int expectedCount )
124
155
{
125
156
var builder = new MockVbeBuilder ( ) ;
@@ -129,16 +160,13 @@ private void CheckActualEmptyBlockCountEqualsExpected(string interfaceCode, stri
129
160
. Build ( ) ;
130
161
var vbe = builder . AddProject ( project ) . Build ( ) ;
131
162
132
- using ( var state = MockParser . CreateAndParse ( vbe . Object ) )
133
- {
134
-
135
- var inspection = new ImplementedInterfaceMemberInspection ( state ) ;
136
- var inspector = InspectionsHelper . GetInspector ( inspection ) ;
137
- var actualResults = inspector . FindIssuesAsync ( state , CancellationToken . None ) . Result ;
138
-
139
- Assert . AreEqual ( expectedCount , actualResults . Count ( ) ) ;
140
- }
163
+ var inspectionResults = InspectionResults ( vbe . Object ) ;
164
+ Assert . AreEqual ( expectedCount , inspectionResults . Count ( ) ) ;
165
+ }
141
166
167
+ protected override IInspection InspectionUnderTest ( RubberduckParserState state )
168
+ {
169
+ return new ImplementedInterfaceMemberInspection ( state ) ;
142
170
}
143
171
}
144
172
}
0 commit comments