Jeffrey Palermo (.com)

Sponsors

The Lounge

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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


Posted Wed, Oct 25 2006 3:16 PM by Jeffrey Palermo

[Advertisement]

Comments

Jean-Paul S. Boodho wrote re: Faking interfaces with events or delegates using Rhino Mocks - level 300
on Wed, Oct 25 2006 4:38 PM
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
Sam Gentile wrote New and Notable 117
on Thu, Oct 26 2006 12:31 PM

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

Sam Gentile wrote New and Notable 117
on Tue, Sep 25 2007 3:08 AM

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