Here is the situation actually posed by a co-worker that pegged my interest:
public DoSomething()
{
//Do Stuff
var assembly = Assembly.LoadFrom("Path");
//Do More Stuff
}
So, in order to mock this you have two options
Create an internal virtual
method:
internal virtual IAssembly LoadAssembly(String path){...Load Here...}
Or, add a new class that can be passed in
public class AssemblyLoader
{
public virtual IAssembly LoadAssembly(String path){...Load here...}
}
Both options seem to be a problem as the first seems that it should be a private method, and the second seems to be an over-design of creating a wrapper for a simple static call?
So, I thought I would take it to the community. I am looking for the most pragmatic approach, while remaining unit-testable.
This is similar to this SO question, however I would like to dig deeper into it really.