8
8
using Rubberduck . CodeAnalysis . Settings ;
9
9
using Rubberduck . Parsing . VBA ;
10
10
using Rubberduck . Parsing . Inspections . Abstract ;
11
+ using System . Collections . Generic ;
11
12
12
13
namespace RubberduckTests . Inspections
13
14
{
14
15
[ TestFixture ]
15
16
public class UseMeaningfulNameInspectionTests : InspectionTestsBase
16
17
{
17
- private string _initialDefaultProjectName ;
18
- private string _initialDefaultModuleName ;
19
-
20
- //(10/15/2019)The default MockVbeBuilder default identifiers "TestProject1" and "TestModule1"
21
- //are flagged by this inspection and interfere with the intended test results.
22
- //Modify these static property values during setup to remove the unintended results.
23
- //Reset the values during teardown to prevent failure of subsequent test classes using the
24
- //default names during setup or expected vs actual asserts.
25
- [ OneTimeSetUp ]
26
- public void CacheDefaultNames ( )
27
- {
28
- _initialDefaultProjectName = MockVbeBuilder . TestProjectName ;
29
- _initialDefaultModuleName = MockVbeBuilder . TestModuleName ;
30
- MockVbeBuilder . TestProjectName = "VBAProject" ;
31
- MockVbeBuilder . TestModuleName = "TestModule" ;
32
- }
33
-
34
- [ OneTimeTearDown ]
35
- public void RestoreDefaultIdentifiers ( )
36
- {
37
- MockVbeBuilder . TestProjectName = _initialDefaultProjectName ;
38
- MockVbeBuilder . TestModuleName = _initialDefaultModuleName ;
39
- }
40
-
41
18
[ Test ]
42
19
[ Category ( "Inspections" ) ]
43
20
public void UseMeaningfulName_NoResultForLineNumberLabels ( )
@@ -47,7 +24,7 @@ Sub DoSomething()
47
24
10 Debug.Print 42
48
25
End Sub
49
26
" ;
50
- Assert . AreEqual ( 0 , InspectionResultsForStandardModule ( inputCode ) . Count ( ) ) ;
27
+ Assert . AreEqual ( 0 , InspectionResultsForModules ( ( "TestModule" , inputCode , ComponentType . StandardModule ) ) . Count ( ) ) ;
51
28
}
52
29
53
30
[ Test ]
@@ -182,6 +159,12 @@ internal static Mock<IConfigurationService<CodeInspectionSettings>> GetInspectio
182
159
return settings ;
183
160
}
184
161
162
+ private IEnumerable < IInspectionResult > InspectionResultsForModules ( params ( string name , string content , ComponentType componentType ) [ ] modules )
163
+ {
164
+ var vbe = MockVbeBuilder . BuildFromModules ( "TestProject" , modules , Enumerable . Empty < string > ( ) ) ;
165
+ return InspectionResults ( vbe . Object ) ;
166
+ }
167
+
185
168
protected override IInspection InspectionUnderTest ( RubberduckParserState state )
186
169
{
187
170
return new UseMeaningfulNameInspection ( state , GetInspectionSettings ( ) . Object ) ;
0 commit comments