<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Testing the world (and writing better quality code along the way)</title>
	<atom:link href="http://blog.tatham.oddie.com.au/2009/04/09/testing-the-world-and-writing-better-quality-code-along-the-way/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tatham.oddie.com.au/2009/04/09/testing-the-world-and-writing-better-quality-code-along-the-way/</link>
	<description></description>
	<lastBuildDate>Wed, 08 Feb 2012 06:37:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Anthony Paul</title>
		<link>http://blog.tatham.oddie.com.au/2009/04/09/testing-the-world-and-writing-better-quality-code-along-the-way/#comment-19164</link>
		<dc:creator><![CDATA[Anthony Paul]]></dc:creator>
		<pubDate>Fri, 20 Jan 2012 19:56:57 +0000</pubDate>
		<guid isPermaLink="false">http://tatham.wordpress.com/?p=296#comment-19164</guid>
		<description><![CDATA[Thank you for this article; it helped me understand why my async mocking seemed to be hanging (of course, it was actually waiting forever for the callback to be called). 

If I may contribute a minor enhancement, you can implement it this way :

listener
   .Expect(a =&gt; a.BeginAcceptTcpClient(null, null))
   .IgnoreArguments()
   .Return(asyncResult)
   .WhenCalled
      (
      invocation =&gt;
         {
         var callbackIndex = invocation.Arguments.Length - 2;
         var callback = invocation.Arguments[callbackIndex] as AsyncCallback;
         callback(asyncResult);
         }
      );

You may even take it a step further and create an extension method for it that wraps all this up neatly, so that you can call it as follows :

listener
   .Expect(a =&gt; a.BeginAcceptTcpClient(null, null))
   .IgnoreArguments()
   .ReturnAsync(asyncResult)

ReturnAsync is the extension method and can implement both the Return and WhenCalled logic; I didn&#039;t put the code here because it&#039;s so trivial anyone can figure it out.

Thanks again for a great article, and I hope my contribution helps!]]></description>
		<content:encoded><![CDATA[<p>Thank you for this article; it helped me understand why my async mocking seemed to be hanging (of course, it was actually waiting forever for the callback to be called). </p>
<p>If I may contribute a minor enhancement, you can implement it this way :</p>
<p>listener<br />
   .Expect(a =&gt; a.BeginAcceptTcpClient(null, null))<br />
   .IgnoreArguments()<br />
   .Return(asyncResult)<br />
   .WhenCalled<br />
      (<br />
      invocation =&gt;<br />
         {<br />
         var callbackIndex = invocation.Arguments.Length &#8211; 2;<br />
         var callback = invocation.Arguments[callbackIndex] as AsyncCallback;<br />
         callback(asyncResult);<br />
         }<br />
      );</p>
<p>You may even take it a step further and create an extension method for it that wraps all this up neatly, so that you can call it as follows :</p>
<p>listener<br />
   .Expect(a =&gt; a.BeginAcceptTcpClient(null, null))<br />
   .IgnoreArguments()<br />
   .ReturnAsync(asyncResult)</p>
<p>ReturnAsync is the extension method and can implement both the Return and WhenCalled logic; I didn&#8217;t put the code here because it&#8217;s so trivial anyone can figure it out.</p>
<p>Thanks again for a great article, and I hope my contribution helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hot guest</title>
		<link>http://blog.tatham.oddie.com.au/2009/04/09/testing-the-world-and-writing-better-quality-code-along-the-way/#comment-16593</link>
		<dc:creator><![CDATA[hot guest]]></dc:creator>
		<pubDate>Thu, 07 Jul 2011 19:24:21 +0000</pubDate>
		<guid isPermaLink="false">http://tatham.wordpress.com/?p=296#comment-16593</guid>
		<description><![CDATA[how to mock StreamWriter?]]></description>
		<content:encoded><![CDATA[<p>how to mock StreamWriter?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Gfader</title>
		<link>http://blog.tatham.oddie.com.au/2009/04/09/testing-the-world-and-writing-better-quality-code-along-the-way/#comment-13780</link>
		<dc:creator><![CDATA[Peter Gfader]]></dc:creator>
		<pubDate>Sat, 18 Apr 2009 02:21:20 +0000</pubDate>
		<guid isPermaLink="false">http://tatham.wordpress.com/?p=296#comment-13780</guid>
		<description><![CDATA[Nice!
I will definitely have a look at Rhino.Mocks for my next unit tests!
thx]]></description>
		<content:encoded><![CDATA[<p>Nice!<br />
I will definitely have a look at Rhino.Mocks for my next unit tests!<br />
thx</p>
]]></content:encoded>
	</item>
</channel>
</rss>

