<?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: Advanced mocking: anonymous test spy</title>
	<atom:link href="http://lostechies.com/jimmybogard/2008/03/07/advanced-mocking-anonymous-test-spy/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jimmybogard/2008/03/07/advanced-mocking-anonymous-test-spy/</link>
	<description>Strong opinions, weakly held</description>
	<lastBuildDate>Wed, 22 May 2013 13:39: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: Jimmy Bogard</title>
		<link>http://lostechies.com/jimmybogard/2008/03/07/advanced-mocking-anonymous-test-spy/#comment-253</link>
		<dc:creator>Jimmy Bogard</dc:creator>
		<pubDate>Wed, 23 Apr 2008 13:55:41 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/03/06/advanced-mocking-anonymous-test-spy.aspx#comment-253</guid>
		<description>@Steve

Thanks for the heads up on Constraints.  I&#039;ve found that my style of writing tests (BDD style) prohibits the use of constraints, though.</description>
		<content:encoded><![CDATA[<p>@Steve</p>
<p>Thanks for the heads up on Constraints.  I&#8217;ve found that my style of writing tests (BDD style) prohibits the use of constraints, though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Freeman</title>
		<link>http://lostechies.com/jimmybogard/2008/03/07/advanced-mocking-anonymous-test-spy/#comment-252</link>
		<dc:creator>Steve Freeman</dc:creator>
		<pubDate>Wed, 23 Apr 2008 13:45:47 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/03/06/advanced-mocking-anonymous-test-spy.aspx#comment-252</guid>
		<description>If you&#039;re going to write about mocks, you should really understand the use of Constraints. They help you focus on the being precise about what matters about the message that one object sends another. I find that a lot of the tests I write have no closing assertions at all, because I&#039;ve said everything in the Expectations.

I guess we need to make a point of writing up the concept more clearly.</description>
		<content:encoded><![CDATA[<p>If you&#8217;re going to write about mocks, you should really understand the use of Constraints. They help you focus on the being precise about what matters about the message that one object sends another. I find that a lot of the tests I write have no closing assertions at all, because I&#8217;ve said everything in the Expectations.</p>
<p>I guess we need to make a point of writing up the concept more clearly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simone Busoli</title>
		<link>http://lostechies.com/jimmybogard/2008/03/07/advanced-mocking-anonymous-test-spy/#comment-251</link>
		<dc:creator>Simone Busoli</dc:creator>
		<pubDate>Fri, 14 Mar 2008 13:44:15 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/03/06/advanced-mocking-anonymous-test-spy.aspx#comment-251</guid>
		<description>Using the constraints syntax from Rhino you end up having little or no assertions between exercising and verification, you only set expectations. About issues, I think it mostly depends on how you feel comfortable with. I think that interaction-based testing takes a while to grab and could be harder to read, but once you&#039;ve caught up with it even makes testing faster and requires less code. Actually, not always http://haacked.com/archive/2007/12/09/writing-unit-tests-for-controller-actions.aspx

BTW, I am always using NBehave for my tests right now, I love the SpecBase class, although I&#039;m using it with NUnit since I prefer using the Resharper test runner which doesn&#039;t have a plugin for NBehave yet. Anyways, guys, keep up the good work with NBehave!</description>
		<content:encoded><![CDATA[<p>Using the constraints syntax from Rhino you end up having little or no assertions between exercising and verification, you only set expectations. About issues, I think it mostly depends on how you feel comfortable with. I think that interaction-based testing takes a while to grab and could be harder to read, but once you&#8217;ve caught up with it even makes testing faster and requires less code. Actually, not always <a href="http://haacked.com/archive/2007/12/09/writing-unit-tests-for-controller-actions.aspx" rel="nofollow">http://haacked.com/archive/2007/12/09/writing-unit-tests-for-controller-actions.aspx</a></p>
<p>BTW, I am always using NBehave for my tests right now, I love the SpecBase class, although I&#8217;m using it with NUnit since I prefer using the Resharper test runner which doesn&#8217;t have a plugin for NBehave yet. Anyways, guys, keep up the good work with NBehave!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jimmy Bogard</title>
		<link>http://lostechies.com/jimmybogard/2008/03/07/advanced-mocking-anonymous-test-spy/#comment-250</link>
		<dc:creator>Jimmy Bogard</dc:creator>
		<pubDate>Fri, 14 Mar 2008 13:15:16 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/03/06/advanced-mocking-anonymous-test-spy.aspx#comment-250</guid>
		<description>@Simone

I&#039;ve never used the constraints, thanks for bringing it up!  Do you ever run into any issues related to assertions being alongside the expectations?  I&#039;ve never thought of using RhinoMocks to do my assertions as well as expectations.  I guess I&#039;m used to seeing &quot;expectations, exercising, verification&quot;.</description>
		<content:encoded><![CDATA[<p>@Simone</p>
<p>I&#8217;ve never used the constraints, thanks for bringing it up!  Do you ever run into any issues related to assertions being alongside the expectations?  I&#8217;ve never thought of using RhinoMocks to do my assertions as well as expectations.  I guess I&#8217;m used to seeing &#8220;expectations, exercising, verification&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simone Busoli</title>
		<link>http://lostechies.com/jimmybogard/2008/03/07/advanced-mocking-anonymous-test-spy/#comment-249</link>
		<dc:creator>Simone Busoli</dc:creator>
		<pubDate>Fri, 14 Mar 2008 12:54:38 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/03/06/advanced-mocking-anonymous-test-spy.aspx#comment-249</guid>
		<description>Oh, with the new release of RhinoMocks you can even do this:

LastCall.Constraints(Property.AllPropertiesMatch(message));

so no need to override Equals.</description>
		<content:encoded><![CDATA[<p>Oh, with the new release of RhinoMocks you can even do this:</p>
<p>LastCall.Constraints(Property.AllPropertiesMatch(message));</p>
<p>so no need to override Equals.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simone Busoli</title>
		<link>http://lostechies.com/jimmybogard/2008/03/07/advanced-mocking-anonymous-test-spy/#comment-248</link>
		<dc:creator>Simone Busoli</dc:creator>
		<pubDate>Fri, 14 Mar 2008 12:35:09 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/03/06/advanced-mocking-anonymous-test-spy.aspx#comment-248</guid>
		<description>I never used LastCall.Do a lot, but I see that in this case it requires you to write less code, though I tend to find the approach of setting constraints on the method to be more intuitive, like this:

var body = &quot;Your order is ready!\r\nOrder #:&quot; + order.OrderNumber;

var message = new MailMessage(&quot;sender@email.com&quot;, &quot;recipient@email.com&quot;,  &quot;Order processed&quot;, body);

LastCall.IgnoreArguments().Constraints(Is.Matching&lt;MailMessage&gt;(m =&gt; m.From.Address == message.From.Address &amp;&amp; m.To.Count == 1));

Sure, if MailMessage overrides the Equals method it would be even easier:

LastCall.IgnoreArguments().Constraints(Is.Equal(message));
</description>
		<content:encoded><![CDATA[<p>I never used LastCall.Do a lot, but I see that in this case it requires you to write less code, though I tend to find the approach of setting constraints on the method to be more intuitive, like this:</p>
<p>var body = &#8220;Your order is ready!\r\nOrder #:&#8221; + order.OrderNumber;</p>
<p>var message = new MailMessage(&#8220;sender@email.com&#8221;, &#8220;recipient@email.com&#8221;,  &#8220;Order processed&#8221;, body);</p>
<p>LastCall.IgnoreArguments().Constraints(Is.Matching<mailmessage>(m => m.From.Address == message.From.Address &#038;&#038; m.To.Count == 1));</p>
<p>Sure, if MailMessage overrides the Equals method it would be even easier:</p>
<p>LastCall.IgnoreArguments().Constraints(Is.Equal(message));<br />
</mailmessage></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Baggio</title>
		<link>http://lostechies.com/jimmybogard/2008/03/07/advanced-mocking-anonymous-test-spy/#comment-247</link>
		<dc:creator>Baggio</dc:creator>
		<pubDate>Thu, 13 Mar 2008 16:28:30 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/03/06/advanced-mocking-anonymous-test-spy.aspx#comment-247</guid>
		<description>That helps. Thanks.</description>
		<content:encoded><![CDATA[<p>That helps. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jimmy Bogard</title>
		<link>http://lostechies.com/jimmybogard/2008/03/07/advanced-mocking-anonymous-test-spy/#comment-246</link>
		<dc:creator>Jimmy Bogard</dc:creator>
		<pubDate>Thu, 13 Mar 2008 15:19:10 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/03/06/advanced-mocking-anonymous-test-spy.aspx#comment-246</guid>
		<description>@Baggio

Quick note, Test Double is term that encapsulates any kind of alternate implementation created specifically for testing.  The other terms are specific types of test doubles.

http://www.martinfowler.com/bliki/TestDouble.html

http://xunitpatterns.com/Test%20Double.html

http://martinfowler.com/articles/mocksArentStubs.html

I&#039;ll follow up with some real-world examples.</description>
		<content:encoded><![CDATA[<p>@Baggio</p>
<p>Quick note, Test Double is term that encapsulates any kind of alternate implementation created specifically for testing.  The other terms are specific types of test doubles.</p>
<p><a href="http://www.martinfowler.com/bliki/TestDouble.html" rel="nofollow">http://www.martinfowler.com/bliki/TestDouble.html</a></p>
<p><a href="http://xunitpatterns.com/Test%20Double.html" rel="nofollow">http://xunitpatterns.com/Test%20Double.html</a></p>
<p><a href="http://martinfowler.com/articles/mocksArentStubs.html" rel="nofollow">http://martinfowler.com/articles/mocksArentStubs.html</a></p>
<p>I&#8217;ll follow up with some real-world examples.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Baggio</title>
		<link>http://lostechies.com/jimmybogard/2008/03/07/advanced-mocking-anonymous-test-spy/#comment-245</link>
		<dc:creator>Baggio</dc:creator>
		<pubDate>Thu, 13 Mar 2008 13:16:46 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/03/06/advanced-mocking-anonymous-test-spy.aspx#comment-245</guid>
		<description>As a TDD newbie, I can follow the examples but I find it difficult to grok and differentiate Test Spy, Test Doubles, Mocks, Stubs, Dummy object concepts.


</description>
		<content:encoded><![CDATA[<p>As a TDD newbie, I can follow the examples but I find it difficult to grok and differentiate Test Spy, Test Doubles, Mocks, Stubs, Dummy object concepts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fredrik</title>
		<link>http://lostechies.com/jimmybogard/2008/03/07/advanced-mocking-anonymous-test-spy/#comment-244</link>
		<dc:creator>Fredrik</dc:creator>
		<pubDate>Thu, 13 Mar 2008 13:06:52 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2008/03/06/advanced-mocking-anonymous-test-spy.aspx#comment-244</guid>
		<description>@bogardj:

The fact that it&#039;s generic is merely a convenience for accessing the mocked object through myMock.MockedInstance, which will then be typed instead of just an object. If you want type-safe expectations you need to buy a license for the professional edition of TypeMock, which includes the &#039;natural mocks&#039; functionality.

By default any call to mocked objects are subverted, but you can control this (including for static/instance constructors). Also, you can use ExpectAndReturn and similar methods to make the mock behave like a stub.</description>
		<content:encoded><![CDATA[<p>@bogardj:</p>
<p>The fact that it&#8217;s generic is merely a convenience for accessing the mocked object through myMock.MockedInstance, which will then be typed instead of just an object. If you want type-safe expectations you need to buy a license for the professional edition of TypeMock, which includes the &#8216;natural mocks&#8217; functionality.</p>
<p>By default any call to mocked objects are subverted, but you can control this (including for static/instance constructors). Also, you can use ExpectAndReturn and similar methods to make the mock behave like a stub.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
