Here is a fairly generic pattern for using refactoring to change an existing design with an embedded dependency into one that supports Dependency Injection (DI) for testing purposes. In many ways, the code transformations I'll show below are similar to the ones in this article by Martin Fowler. Note: although I am a fanatical TDDer, I've not used that approach when designing this refactoring. T