Skip to content

Commit 0e1e9de

Browse files
authored
Merge pull request #3998 from WaynePhillipsEA/next
UnitTests: Pass IVBProject rather than ambiguous project name to the TypeLib API
2 parents 67c7657 + d8d5fbe commit 0e1e9de

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Rubberduck.Core/UnitTesting/TestMethod.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using Rubberduck.Parsing;
77
using Rubberduck.Parsing.Symbols;
8+
using Rubberduck.Parsing.VBA;
89
using Rubberduck.UI;
910
using Rubberduck.UI.Controls;
1011
using Rubberduck.VBEditor;
@@ -19,9 +20,11 @@ public class TestMethod : ViewModelBase, IEquatable<TestMethod>, INavigateSource
1920
private readonly ICollection<AssertCompletedEventArgs> _assertResults = new List<AssertCompletedEventArgs>();
2021
private readonly IVBE _vbe;
2122
private readonly IVBETypeLibsAPI _typeLibApi;
23+
private readonly RubberduckParserState _state;
2224

23-
public TestMethod(Declaration declaration, IVBE vbe, IVBETypeLibsAPI typeLibApi)
25+
public TestMethod(RubberduckParserState state, Declaration declaration, IVBE vbe, IVBETypeLibsAPI typeLibApi)
2426
{
27+
_state = state;
2528
_declaration = declaration;
2629
_vbe = vbe;
2730
_typeLibApi = typeLibApi;
@@ -46,7 +49,8 @@ public void Run()
4649
try
4750
{
4851
AssertHandler.OnAssertCompleted += HandleAssertCompleted;
49-
_typeLibApi.ExecuteCode(_vbe, Declaration.ProjectName, Declaration.QualifiedModuleName.ComponentName,
52+
var project = _state.ProjectsProvider.Project(Declaration.ProjectId);
53+
_typeLibApi.ExecuteCode(project, Declaration.QualifiedModuleName.ComponentName,
5054
Declaration.QualifiedName.MemberName);
5155
AssertHandler.OnAssertCompleted -= HandleAssertCompleted;
5256

Rubberduck.Core/UnitTesting/UnitTestUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static IEnumerable<TestMethod> GetAllTests(IVBE vbe, RubberduckParserStat
1717
{
1818
return GetTestModuleProcedures(state)
1919
.Where(item => IsTestMethod(state, item))
20-
.Select(item => new TestMethod(item, vbe, new VBETypeLibsAPI()));
20+
.Select(item => new TestMethod(state, item, vbe, new VBETypeLibsAPI()));
2121
}
2222

2323
public static IEnumerable<TestMethod> GetTests(this IVBComponent component, IVBE vbe, RubberduckParserState state)

0 commit comments

Comments
 (0)