So, I have a helper method that looks something like this:
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);
}
This is just a convenient helper method for which I can call to capture the specific object that I need, and then remember which dependencies I need to connect in order to get the desired object.
My first question is: should such methods be checked? The only reason I can think that I want to test these types of methods is to make sure that the correct dependencies are used and configured correctly.
If the answer to the first question is yes, the second - how? I am currently using NUnit and RhinoMocks, and I am trying to figure out how this method should be reorganized for verification (well, and whether something like this needs to be verified!); dependency injection will obviously not work here, as this method does create dependencies!
Or this bad practice method is used, and I should do something like the following:
D d = new (new C(new A(), new B(), "string"), 1024);
source
share