So I have a helper method that looks something like the following:
private D GetInstanceOfD(string param1, int param2)
{
A a = new A();
B a = new B();
C c = new C(a,b, param1);
return new D(c, param2);
}
It's just a convenient helper method for which I can call to grab a particular object that I need rather then to remember which dependencies I need to hook up to get the object I require.
My first question here is: should methods like these be tested? The only reason I can think of to want to test these type of methods would be to make sure that the correct dependencies are used and are set up correctly.
If the answer to the first question is yes, my second is: how? I am currently using NUnit and RhinoMocks and am trying to work out how this method has to be refactored to be testable (well, and whether something like this should be tested!); dependency injection obviously would not work here as this method actually creates the dependencies!
Or is using this method bad practice and I should be doing something like the following:
D d = new (new C(new A(), new B(), "string"), 1024);