I've got a project full of legacy code (by this I simply mean untested) and I'm experimenting with retrofitting unit testing to it. I'm sure this entails a great many problems, but here's the first one.
We have a central class with the Singleton pattern - it's instantiated once and then fetched all over the code. It's a concrete class at the moment, not an interface. Let's call this CentralControl.
Because the code I want to test relies on the presence of this class, and yet it's too complex/heavyweight to properly instantiate in a test scenario, I need to mock it.
I guess the ideal way is to turn what's now CentralControl into an interface, and have both a real and mock implementation. The code that enforces the singleton behaviour could have a new method to instantiate the mock version rather than the real thing.
Would you do this yourself rather than alternatives like extending it, and are there any tools to help automate the process?