Static singletons are difficult to mock and to test, and should be avoided, ideally. As RhinoMocks has pointed out, you can't make a partial mock of your Configuration singleton, but you have some options.
Make your private constructor public. This should be considered a quick hack, though. There are much better ways of doing this.
Change how your singleton is instantiated. Give your
Configuration
class an interface, let's sayIConfiguration
. You probably already have a staticInstance
property onConfiguration
. Change it's type to beIConfiguration
, and give it a public setter. In your unit tests, mock or stubIConfiguration
, and set theConfiguration.Instance
property to that. This is still something of a hack (but it is useful when you have lots of classes that are already using the singleton, and you don't have time to implement the next option).Use dependency injection. Give your
Configuration
class an interface, again let's sayIConfiguration
. Classes that have a dependency on theConfiguration
singleton should be changed to take anIConfiguration
parameter in their constructor. When you create an instance of one of these classes, you inject in the singleton instance ofConfiguration
. When testing, make a mock or stub of typeIConfiguration
, and pass that to the classes instead. You can improve on this with a dependency injection framework, like Castle Windsor or Ninject, which you could probably use to do away with your need for a static singleton altogether.
I highly recommend you change your design and use option 3 (with a dependency injection framework, if possible).