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.
- Share this:
- StumbleUpon
2 Responses to Making a Mockery
Leave a Reply Cancel reply
Tag Cloud
3G adobe agriculture analogy Apple authentication berkovitz BIN Contacts CreatePageURLSegment credit card credit cards developers Episerver Esendex Google iPhone Joost Linux log4net logging luhn Mac maestro Mastercard Microsoft NMock Page PATH payWave Plesk regex RFID security software SQL Server Stored Procedures SugarOS T-SQL TechEd uk validation Visa Windows XCodeCategories
Jbjon
- @fluffosaur I usually get pestered for a spoon full of milk in the morning. Parents cat would stick paw in bowl and pull it towards him!
- Have you seen the cautionary tale from Pixar about how Toy Story 2 nearly had to be started over as it got deleted ?http://t.co/P1ip6rdO
- @samwessel YouTube never ceases to amuse me : http://t.co/oLVzq4DZ
- @ruby_gem There's no limits to how awesome meteorologists are even compared to Cyborg Unicorns! http://t.co/bjAlXDHO http://t.co/fu8utUXj
- Subway are handing out vouchers near M&S /Hounds Gate for a free 6" sub with a large drink @ £1.49. #Nom


So my little talk wasn’t completely useless then?
It was very useful. Just needed to find the time to have a play with it. And having your example code helped a great deal. So thanks again!