<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>rob bowley &#187; rhinomocks</title>
	<atom:link href="http://blog.robbowley.net/tag/rhinomocks/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.robbowley.net</link>
	<description>adventures in extreme programming</description>
	<lastBuildDate>Thu, 15 Jul 2010 08:12:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>nMock vs RhinoMocks</title>
		<link>http://blog.robbowley.net/2008/07/09/nmock-vs-rhinomocks/</link>
		<comments>http://blog.robbowley.net/2008/07/09/nmock-vs-rhinomocks/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 21:16:04 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[nmock]]></category>
		<category><![CDATA[rhinomocks]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://test.robbowley.net/?p=9</guid>
		<description><![CDATA[I&#8217;ve recently started using RhinoMocks instead of nMock, mainly because it&#8217;s strongly-typed. However, I&#8217;ve found a few other little treats:
Stubs
In nMock, if you want to stub some method calls on a mocked interface you have to do something like this:
Mockery mockery = new Mockery();
IService mockService = mockery.NewMock();
Stub.On(mockService).Method("MethodA");
Stub.On(mockService).Method("MethodB");
Stub.On(mockService).Method("MethodC");
...

Which is cumbersome and noisy. In RhinoMocks you can [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently started using RhinoMocks instead of nMock, mainly because it&#8217;s strongly-typed. However, I&#8217;ve found a few other little treats:</p>
<h3>Stubs</h3>
<p>In nMock, if you want to stub some method calls on a mocked interface you have to do something like this:</p>
<pre><code>Mockery mockery = new Mockery();
IService mockService = mockery.NewMock();
Stub.On(mockService).Method("MethodA");
Stub.On(mockService).Method("MethodB");
Stub.On(mockService).Method("MethodC");
...
</code></pre>
<p>Which is cumbersome and noisy. In RhinoMocks you can do this:</p>
<pre><code>MockRepository Repository repository = new MockRepository();
IService serviceMock = repository.Stub();
...
</code></pre>
<p>&#8230;and RhinoMocks will ignore all calls to that interface. This is really nice as you generally only test the SUT&#8217;s interaction with one dependency at a time.</p>
<h3>Dynamic Mocks</h3>
<p>If you only want to test one interaction with a dependency and ignore all others you can create a dynamic mock.</p>
<pre><code>MockRepository Repository repository = new MockRepository();
repository .DynamicMock();
...</code></pre>
<p>All calls to the mocked dependency will be ignored unless they are explicitly expected (e.g. Expect.Call(mockService.MethodA)&#8230;..). This is the same as <em>not</em> saying mockery.VerifyAllExpectationsHaveBeenMet() in nMock. It&#8217;s always annoyed me that you have to remember to do this in nMock and I much prefer that the default for RhinoMocks is to fail when encountering an unexpected method call.</p>
<h3>Raising Events</h3>
<p>nMock does not natively support raising events, which is a pain, but there are <a href="http://blog.gravityfree.ca/2007/03/raising-events-in-nmock-20.html">ways around it</a> (I&#8217;ve extended his example to support custom EventArgs which you can download <a href="http://blog.robbowley.net/assets/2008/7/9/MockEvent_1.zip">here</a>). With RhinoMocks it&#8217;s much simpler. Rather than explaining it myself, check out J-P Boodhoo&#8217;s great example <a href="http://codebetter.com/blogs/jean-paul_boodhoo/archive/2007/05/07/raising-events-from-a-mock-using-rhino-mocks.aspx">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.robbowley.net/2008/07/09/nmock-vs-rhinomocks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
