Unit Testing with Service Stubs or Mock Types
Mock typing to this degree is pretty easy once you figure out the nuts and bolts. I wouldn't use this strategy for everything, but I would use it for services, facades, 3rd party and legacy sub-systems, externally provided parts of your solution, and perhaps code that is going to take a while to make available.
A huge part of software development is momentum. If you get stuck waiting on code that has been outsourced or rickety old 3rd party or legacy sub-systems, it can kill your momentum. Implement a mock type, code against the mock type, and keep on trucking.
Mock types will facilitate test-driven development, delineations, and dependencies on outsourced parts of your project, and undependable legacy and 3rd party systems.
About the Author
Paul Kimmel is the VB Today columnist for www.codeguru.com and has written several books on object-oriented programming and .NET. Check out his upcoming book LINQ Unleashed for C# due in July 2008. Paul Kimmel is an Application Architect for EDS. You may contact him for technology questions at firstname.lastname@example.org.
Lansing is having a free Day of .NET training at Lansing Community College on June 21st. Check out the web site for details. The group likes to think of it as a poor man's TechEd (because it's free), but the content will be excellent.
Copyright © 2008 by Paul T. Kimmel. All Rights Reserved.
Page 4 of 4