<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Working With Assertions Made on Arguments in Rhino Mocks</title>
	<atom:link href="http://lostechies.com/chrismissal/2010/03/18/working-with-assertions-made-on-arguments-in-rhino-mocks/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/chrismissal/2010/03/18/working-with-assertions-made-on-arguments-in-rhino-mocks/</link>
	<description>Thoughts while working and playing as a Software Developer</description>
	<lastBuildDate>Mon, 10 Jun 2013 15:59:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Chris Missal</title>
		<link>http://lostechies.com/chrismissal/2010/03/18/working-with-assertions-made-on-arguments-in-rhino-mocks/#comment-194</link>
		<dc:creator>Chris Missal</dc:creator>
		<pubDate>Thu, 18 Mar 2010 18:01:32 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2010/03/17/working-with-assertions-made-on-arguments-in-rhino-mocks.aspx#comment-194</guid>
		<description>@Chad

You&#039;re right on the SOLID issues, but I wouldn&#039;t say that they&#039;ve caused pain. I just had the one hiccup that I mentioned above. I could actually modify these pretty easily. The code doesn&#039;t show it above (cause I accidentally omitted it), but the CustomerServiceNotifier is an INotifier, which are injected via our container. It would pretty easy to add the idea of Match() and BuildNotification() methods. We only have a few of these right now, but if/when that area grows, that could be really helpful. Good thoughts!</description>
		<content:encoded><![CDATA[<p>@Chad</p>
<p>You&#8217;re right on the SOLID issues, but I wouldn&#8217;t say that they&#8217;ve caused pain. I just had the one hiccup that I mentioned above. I could actually modify these pretty easily. The code doesn&#8217;t show it above (cause I accidentally omitted it), but the CustomerServiceNotifier is an INotifier, which are injected via our container. It would pretty easy to add the idea of Match() and BuildNotification() methods. We only have a few of these right now, but if/when that area grows, that could be really helpful. Good thoughts!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chadmyers</title>
		<link>http://lostechies.com/chrismissal/2010/03/18/working-with-assertions-made-on-arguments-in-rhino-mocks/#comment-193</link>
		<dc:creator>chadmyers</dc:creator>
		<pubDate>Thu, 18 Mar 2010 17:14:29 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2010/03/17/working-with-assertions-made-on-arguments-in-rhino-mocks.aspx#comment-193</guid>
		<description>Looking through this, it feels like you&#039;ve got an OCP and maybe an SRP issue, which is why you&#039;re feeling the pain of the mock troubles here.

The &quot;if (order.HasNotes)&quot; code feels like OCP violation as it&#039;s somewhat similar to a switch/case statement block.  Perhaps you should consider having strategies with a Match() method and a BuildNotification() method. The strategies get injected via IoC and your Notify() method just iterates the strategies and if they Match() on the current Order, then you call BuildNotification() and the strategy will append whatever it needs to the notification.</description>
		<content:encoded><![CDATA[<p>Looking through this, it feels like you&#8217;ve got an OCP and maybe an SRP issue, which is why you&#8217;re feeling the pain of the mock troubles here.</p>
<p>The &#8220;if (order.HasNotes)&#8221; code feels like OCP violation as it&#8217;s somewhat similar to a switch/case statement block.  Perhaps you should consider having strategies with a Match() method and a BuildNotification() method. The strategies get injected via IoC and your Notify() method just iterates the strategies and if they Match() on the current Order, then you call BuildNotification() and the strategy will append whatever it needs to the notification.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Missal</title>
		<link>http://lostechies.com/chrismissal/2010/03/18/working-with-assertions-made-on-arguments-in-rhino-mocks/#comment-192</link>
		<dc:creator>Chris Missal</dc:creator>
		<pubDate>Thu, 18 Mar 2010 15:42:46 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2010/03/17/working-with-assertions-made-on-arguments-in-rhino-mocks.aspx#comment-192</guid>
		<description>@MM

Correct, multiple assertions would have pointed to a better failure sooner. I&#039;m just thinking that taking it one step further and breaking them into their own tests would be an even better step. After all, they are individual requirements we want to ensure are working as expected.</description>
		<content:encoded><![CDATA[<p>@MM</p>
<p>Correct, multiple assertions would have pointed to a better failure sooner. I&#8217;m just thinking that taking it one step further and breaking them into their own tests would be an even better step. After all, they are individual requirements we want to ensure are working as expected.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Missal</title>
		<link>http://lostechies.com/chrismissal/2010/03/18/working-with-assertions-made-on-arguments-in-rhino-mocks/#comment-191</link>
		<dc:creator>Chris Missal</dc:creator>
		<pubDate>Thu, 18 Mar 2010 15:41:09 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2010/03/17/working-with-assertions-made-on-arguments-in-rhino-mocks.aspx#comment-191</guid>
		<description>@Garry

I think you might be right, a hand-rolled mock might make things a bit more concise here. I use them sometimes, usually when subclassing an object to test it.</description>
		<content:encoded><![CDATA[<p>@Garry</p>
<p>I think you might be right, a hand-rolled mock might make things a bit more concise here. I use them sometimes, usually when subclassing an object to test it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MM</title>
		<link>http://lostechies.com/chrismissal/2010/03/18/working-with-assertions-made-on-arguments-in-rhino-mocks/#comment-190</link>
		<dc:creator>MM</dc:creator>
		<pubDate>Thu, 18 Mar 2010 15:14:48 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2010/03/17/working-with-assertions-made-on-arguments-in-rhino-mocks.aspx#comment-190</guid>
		<description>The ironic thing is, multiple assertions would have probably allowed you to find the problem faster.

emailService.AssertWasCalled(x =&gt; x.SendOrderReceived(
    Arg&lt;string&gt;.Is.Anything, 
    Arg&lt;string&gt;.Matches(body =&gt; body.Contains(&quot;This order needs a shipping quote.&quot;))));
    
emailService.AssertWasCalled(x =&gt; x.SendOrderReceived(
    Arg&lt;string&gt;.Is.Anything, 
    Arg&lt;string&gt;.Matches(body =&gt; body.Contains(customerNumber.ToString()))));
    
emailService.AssertWasCalled(x =&gt; x.SendOrderReceived(
    Arg&lt;string&gt;.Is.Anything, 
    Arg&lt;string&gt;.Matches(body =&gt; body.Contains(orderNumber.ToString()))));

This might make the test less readable but you would have seen which Contains was failing. 

I think it&#039;s debatable as to whether you&#039;re actually testing three things in this case (regardless of how many actual assertions you have). You&#039;re really just checking the contents of one argument. Three separate tests might be overkill but I&#039;m not sure.</description>
		<content:encoded><![CDATA[<p>The ironic thing is, multiple assertions would have probably allowed you to find the problem faster.</p>
<p>emailService.AssertWasCalled(x => x.SendOrderReceived(<br />
    Arg<string>.Is.Anything,<br />
    Arg</string><string>.Matches(body => body.Contains(&#8220;This order needs a shipping quote.&#8221;))));</p>
<p>emailService.AssertWasCalled(x => x.SendOrderReceived(<br />
    Arg</string><string>.Is.Anything,<br />
    Arg</string><string>.Matches(body => body.Contains(customerNumber.ToString()))));</p>
<p>emailService.AssertWasCalled(x => x.SendOrderReceived(<br />
    Arg</string><string>.Is.Anything,<br />
    Arg</string><string>.Matches(body => body.Contains(orderNumber.ToString()))));</p>
<p>This might make the test less readable but you would have seen which Contains was failing. </p>
<p>I think it&#8217;s debatable as to whether you&#8217;re actually testing three things in this case (regardless of how many actual assertions you have). You&#8217;re really just checking the contents of one argument. Three separate tests might be overkill but I&#8217;m not sure.</string></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Sohl</title>
		<link>http://lostechies.com/chrismissal/2010/03/18/working-with-assertions-made-on-arguments-in-rhino-mocks/#comment-189</link>
		<dc:creator>Greg Sohl</dc:creator>
		<pubDate>Thu, 18 Mar 2010 13:56:37 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2010/03/17/working-with-assertions-made-on-arguments-in-rhino-mocks.aspx#comment-189</guid>
		<description>I don&#039;t have a problem with multiple Asserts in a test, as long as each produces a proper message. For example, in recently testing a thread-safe cache, after adding an item, there were multiple counters that should be set to particular values. The &quot;Add&quot; test verifies all those counters with multiple Asserts and clear messages on failure.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t have a problem with multiple Asserts in a test, as long as each produces a proper message. For example, in recently testing a thread-safe cache, after adding an item, there were multiple counters that should be set to particular values. The &#8220;Add&#8221; test verifies all those counters with multiple Asserts and clear messages on failure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Garry Shutler</title>
		<link>http://lostechies.com/chrismissal/2010/03/18/working-with-assertions-made-on-arguments-in-rhino-mocks/#comment-188</link>
		<dc:creator>Garry Shutler</dc:creator>
		<pubDate>Thu, 18 Mar 2010 12:07:08 +0000</pubDate>
		<guid isPermaLink="false">/blogs/chrismissal/archive/2010/03/17/working-with-assertions-made-on-arguments-in-rhino-mocks.aspx#comment-188</guid>
		<description>In this kind of scenario I find it much easier to hand-roll my mock object. Then you can expose a property like &quot;LastSentOrderBody&quot; which lets you split up the assertions. This gives you much finer grained assertions which prevents this sort of problem.</description>
		<content:encoded><![CDATA[<p>In this kind of scenario I find it much easier to hand-roll my mock object. Then you can expose a property like &#8220;LastSentOrderBody&#8221; which lets you split up the assertions. This gives you much finer grained assertions which prevents this sort of problem.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
