CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeffrey Palermo [MVP]

Software management consultant and CTO, Headspring Systems

Faking interfaces with events or delegates using Rhino Mocks - level 300

I think mock objects themselves are a 300-level topic.  I wish it weren't so, but from the folks I talk to, the average developer doesn't use them.  Fakes, stubs, mocks (whatever you want to call them - and I know they overlap, and I understand the semantic differences among them) are critical for testing.  It's important to isolate code under test, and in order to do that, we have to fake out other classes the current class talks to.  Not all the classes as a rule, but the ones that might give our test unpredictable results.

Phil Haack lays out an example faking an event on an interface.  While I prefer to use plain delegates for my view-controller notification, events are multicast delegates, so the work as well.  Give it a read.

http://haacked.com/archive/2006/06/23/UsingRhinoMocksToUnitTestEventsOnInterfaces.aspx



Comments

Jean-Paul S. Boodho said:

Hey Jeff, I give a demonstration of this technique in a screencast I made a couple of weeks ago. The link to the screencast is here : http://www.jpboodhoo.com/blog/ScreencastAppliedTestDrivenDevelopmentForWebApplicationsPart3.aspx. My recommendation is to download the flash file and play it using the GlobX Swiff player. Thanks
# October 25, 2006 4:38 PM

Sam Gentile said:

I am still reeling from seeing the Red Hot Chili Peppers with Mars Volta 2 nights ago in Philly at the

# October 26, 2006 12:31 PM

Sam Gentile said:

I am still reeling from seeing the Red Hot Chili Peppers with Mars Volta 2 nights ago in Philly at the

# September 25, 2007 3:08 AM

About Jeffrey Palermo

Jeffrey Palermo is a software management consultant and the CTO of Headspring Systems in Austin, TX. Jeffrey specializes in Agile coaching and helps companies double the productivity of software teams. Jeffrey is an MCSD.Net , Microsoft MVP, Certified Scrummaster, Austin .Net User Group leader, AgileAustin board member, INETA speaker, INETA Membership Mentor, Christian, husband, father, motorcyclist, Eagle Scout, U.S. Army Veteran, and Texas A&M University graduate. Check out Devlicio.us!

This Blog

Syndication