Derik Whittaker

Syndication

News


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
Removing the 'delegate' noise with RhinoMocks 3.5

As you may be aware Ayende has recently released Rhino 3.5 Release Candidate. Among many of the great improvements to this release, he as simplified the code needed to mock void methods.

Lets take a look at the older syntax:
Expect.Call(delegate { mockSession.Login("", ""); }).IgnoreArguments().Repeat.Once();

Lets now take a look at the new syntax:
mockSession.Expect( x => x.Login( "", "" ) ).IgnoreArguments().Repeat.Once();

Both ways will accomplish the same goal, but I know that I always hated having to use a delegate to set expectations on a void method.  To me the new syntax (using Lambda's) is much cleaner and flows off my keyboard much easier.

+1 for all Ayende's hard work

Till next time,

[----- Remember to check out DimeCasts.Net -----]


Posted 06-30-2008 8:28 AM by Derik Whittaker

[Advertisement]

Comments

Christopher Bennage wrote re: Removing the 'delegate' noise with RhinoMocks 3.5
on 06-30-2008 9:54 AM

Very nice.

Davy Brion wrote re: Removing the 'delegate' noise with RhinoMocks 3.5
on 06-30-2008 10:28 AM

the new syntax is definitely nice, but you could also do Expect.Call(() => myObject.MyVoidMethod()) with the previous version

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)