Skip to content

Commit 99188cc

Browse files
committed
Add BuildFromModules overload
Added to addReferenceActions Dictionary and some name changes
1 parent 80c5fa4 commit 99188cc

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

RubberduckTests/Mocks/MockVbeBuilder.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ namespace RubberduckTests.Mocks
1717
[SuppressMessage("Microsoft.Design", "CA1001")] //CA1001 is complaining about RubberduckTests.Mocks.Windows, which doesn't need to be disposed in this context.
1818
public class MockVbeBuilder
1919
{
20-
//provide ability for inspection tests to modify the default
21-
//Project and Module names (e.g., the defaults are flagged by MeaninglessName inspection)
2220
public static string TestProjectName { set; get; } = "TestProject1";
2321
public static string TestModuleName { set; get; } = "TestModule1";
2422
private readonly Mock<IVBE> _vbe;
@@ -56,12 +54,13 @@ public class MockVbeBuilder
5654
["ADOR"] = LibraryPathAdoRecordset
5755
};
5856

59-
private static readonly Dictionary<string, Action<MockProjectBuilder>> addLibraryRefActions = new Dictionary<string, Action<MockProjectBuilder>>
57+
private static readonly Dictionary<string, Action<MockProjectBuilder>> addReferenceActions = new Dictionary<string, Action<MockProjectBuilder>>
6058
{
6159
["Excel"] = (MockProjectBuilder builder) => builder.AddReference("Excel", LibraryPathMsExcel, 1, 8, true),
6260
["VBA"] = (MockProjectBuilder builder) => builder.AddReference("VBA", LibraryPathVBA, 4, 2, true),
6361
["Scripting"] = (MockProjectBuilder builder) => builder.AddReference("Scripting", LibraryPathScripting, 1, 0, true),
6462
["ADODB"] = (MockProjectBuilder builder) => builder.AddReference("ADODB", LibraryPathAdoDb, 6, 1, false),
63+
["MSForms"] = (MockProjectBuilder builder) => builder.AddReference("MSForms", LibraryPathMsForms, 2, 0, true),
6564
};
6665

6766
//private Mock<IWindows> _vbWindows;
@@ -218,18 +217,16 @@ public static Mock<IVBE> BuildFromModules(IEnumerable<(string name, string conte
218217
}
219218

220219
/// <summary>
221-
/// Builds a mock VBE containing one project with multiple modules.
220+
/// Builds a mock VBE containing one project with one module and one library.
222221
/// </summary>
223-
public static Mock<IVBE> BuildFromModules(IEnumerable<Action<MockProjectBuilder>> AddReferenceLibraryActions, params (string name, string content, ComponentType componentType)[] modules)
224-
{
225-
return BuildFromModules((IEnumerable<(string name, string content, ComponentType componentType)>)modules);
226-
}
222+
public static Mock<IVBE> BuildFromModules((string name, string content, ComponentType componentType) module, string library)
223+
=> BuildFromModules(new(string, string, ComponentType)[] { module }, new string[] { library });
227224

228225
/// <summary>
229-
/// Builds a mock VBE containing one project with one module and one library.
226+
/// Builds a mock VBE containing one project with one module and multiple libraries.
230227
/// </summary>
231-
public static Mock<IVBE> BuildFromModules((string name, string content, ComponentType componentType) module, string library)
232-
=> BuildFromModules(new (string, string, ComponentType)[] { module }, new string[] {library});
228+
public static Mock<IVBE> BuildFromModules((string name, string content, ComponentType componentType) module, IEnumerable<string> libraries)
229+
=> BuildFromModules(new(string, string, ComponentType)[] { module }, libraries);
233230

234231
/// <summary>
235232
/// Builds a mock VBE containing one project with one or more modules using one or more libraries.
@@ -246,7 +243,7 @@ public static Mock<IVBE> BuildFromModules(IEnumerable<(string name, string conte
246243

247244
foreach (var name in libraryNames)
248245
{
249-
addLibraryRefActions[name](builder);
246+
addReferenceActions[name](builder);
250247
}
251248

252249
var project = builder.Build();

0 commit comments

Comments
 (0)