I'm currently tdding a "PluginsService" that I'm writing. I'm needing to use the System libraries of Assembly, AssemblyName, Directory and File. Currently I'm creating wrapper interfaces for each of these so I can mock them in the tests. This does mean however that I'm having to inject quite a few wrappers into the service.
So for example when testing a method that searches a folder for some plugins I'm doing this
With.Mocks(mockery)
.Expecting(() =>
{
Expect.Call(directory.GetFiles(PLUGINPATH, PLUGINSEARCHPATTERN)).IgnoreArguments().Return(pluginLibraries);
Expect.Call(file.ReadAllBytes(null)).IgnoreArguments().Return(bytes);
Expect.Call(assemblyName.GetAssemblyName("fileName")).IgnoreArguments().Return(name);
Expect.Call(assembly.GetExecutingAssembly()).Return(executingAssembly);
})
.Verify(() => result = service.FindAvailablePlugins());
I have 2 questions:
- Is there a better way of handling System library items for TDD?
- Is 4 too many items to be injecting into one class?