Skip to content

Commit 0e74b1d

Browse files
committed
Added ocal InspectionResultsForModules version
Removed use of one-time setup and teardown
1 parent 2326ae4 commit 0e74b1d

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

RubberduckTests/Inspections/UseMeaningfulNameInspectionTests.cs

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,13 @@
88
using Rubberduck.CodeAnalysis.Settings;
99
using Rubberduck.Parsing.VBA;
1010
using Rubberduck.Parsing.Inspections.Abstract;
11+
using System.Collections.Generic;
1112

1213
namespace RubberduckTests.Inspections
1314
{
1415
[TestFixture]
1516
public class UseMeaningfulNameInspectionTests : InspectionTestsBase
1617
{
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-
4118
[Test]
4219
[Category("Inspections")]
4320
public void UseMeaningfulName_NoResultForLineNumberLabels()
@@ -47,7 +24,7 @@ Sub DoSomething()
4724
10 Debug.Print 42
4825
End Sub
4926
";
50-
Assert.AreEqual(0, InspectionResultsForStandardModule(inputCode).Count());
27+
Assert.AreEqual(0, InspectionResultsForModules(("TestModule", inputCode, ComponentType.StandardModule)).Count());
5128
}
5229

5330
[Test]
@@ -182,6 +159,12 @@ internal static Mock<IConfigurationService<CodeInspectionSettings>> GetInspectio
182159
return settings;
183160
}
184161

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+
185168
protected override IInspection InspectionUnderTest(RubberduckParserState state)
186169
{
187170
return new UseMeaningfulNameInspection(state, GetInspectionSettings().Object);

0 commit comments

Comments
 (0)