Oren has answered my Quiz, by saying that
using(TextWriter writer = IoC.Resolve<IFileWriterFactory>().Create(filename)) writer.Write(text);
is easier to maintain! Well I cannot argue with that. Oren is one of a kind and I am sure that he can swallow these IoC containers and maintain them in his sleep. But would you have chosen this path if you didn’t need to test the code? Probably not.
We know that easy to understanding code makes the code maintainable, not only to developers who haven’t written the code but also the the developer who wrote the code 3 or more months beforehand.
but I think that using it [TypeMock] to enable brute force testing is harming the design process
Using TypeMock gives you Freedom. It gives you total freedom to choose your design:
- Freedom to choose When you want to design. Before/During or After writing implementation
- Freedom to choose How you want to create new objects. Using the new keyword/ a Singleton/ Factory or IoC Container
- Freedom to choose the Balance of your design. Flexibility/Extensibility/Maintainability/Cohesion/Just In Time Design (YAGNI)
You might be scared of this freedom, but it is not something new. We have always had this freedom until we had to nUnit test our code. Then we lost this freedom and had to find different constraining techniques. It might make our code better, but it might not. I personally like my freedom.