I am a little bored so I thought I would write a nice fluent interface around the Performance Counter crap that is part of .net. I know, I know the world does not really need another Fluent Interface around something, but I am bored and this is keeping be busy while waiting for my flight.
Anyway, about 30 min into the coding session (going a bit slow as I am trying to use CodeRush/Refactor Pro in place of ReSharper) I needed to use the PerformanceCounterCategory class. The problem is this. Since this is a singleton isolating this during my tests is too painful, and because it is a singleton I cannot create an inheritance hierarchy to allow me to isolate it better. So, what did I do?
I created a wrapper around the singleton. By having this wrapper (and accompanying interface) I will be able to better isolate my tests and not actually create a shit load of categories and counters all the time.
Wrap Strategy Refactoring === FOR THE WIN
Singletons == FOR THE LOSS
Till next time,
05-15-2009 5:27 PM