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

Derik Whittaker

Thoughts on Software Development, .Net, OOP, Design Patterns and all things cool



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 -----]



Comments

Christopher Bennage said:

Very nice.

# June 30, 2008 9:54 AM

Davy Brion said:

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

# June 30, 2008 10:28 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Derik Whittaker

Derik is a .Net Developer/Architect specializing in WinForms working out the northern suburbs of Chicago. He is also believer and advocate for Agile development including SCRUM, TDD, CI, etc.

When Derik is not writing code he can be found spending time with his wife and young son, climbing on his bouldering wall, watching sports (mostly baseball), and generally vegging out. Check out Devlicio.us!

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News