Making a Mockery

Thanks to some example code by Ian I’ve completed my first Mockery. NMock allows you to instantiate mock objects based on interface declarations alone.
It’s already saved me a potential chicken and egg scenario where to get an instance of the normal object that’s inputting into the method I was testing I’d have had to include a project which relied on the one I was in the midst of building. Compilers tend to hate the chicken and egg question and usually go on strike.
So, NMock to the rescue and I must say it took no time at all to get up to speed with. Yes, it did require me to set all of the properties on the object that were being used, rather than relying on defaults created by Constructor methods. However, accurately controlling the data retrieved from the object is such a benefit. It will no doubt save the time spent where tests at the moment retrieve data from a database.