My case was similiar to this one:
public static class SomeFactory
{
public ISomeObject Create() { // do nasty things such as service calls }
}
public class ThisIsWhatIWantToTest
{
public void AMethod()
{
// ...
var someObject = SomeFactory.Create();
// ...
}
}
I wanted to write tests for AMethod but I had a hard time. Acutally I could not manage to find a seam to work around the service call easily.
Another thing I noticed along the way is, that static things obscure the dependencies in the code. This is not a good thing because it makes the code harder to understand. If you have dependencies, the should be widely visible for the sake of clarity.
I will very carefully consider the use of statics from now.
Cheers,
Tobias.
Der Kommentar wurde von einem Blog-Administrator entfernt.
AntwortenLöschen