<?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: Mocking .NET Objects with NUnit</title>
	<atom:link href="http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/</link>
	<description>Musings of a software developer in Milwaukee, WI.</description>
	<pubDate>Tue, 06 Jan 2009 10:58:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Mocking With NUnit &#171; bloggersfun</title>
		<link>http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/comment-page-1/#comment-14224</link>
		<dc:creator>Mocking With NUnit &#171; bloggersfun</dc:creator>
		<pubDate>Fri, 26 Sep 2008 03:03:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/#comment-14224</guid>
		<description>[...] Mocking With&#160;NUnit  If you choose Nunit for you Unit Testing and with Mock object for isolating classes from their dependencies for testing purposes.You can go through this tutorial:http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/ [...]</description>
		<content:encoded><![CDATA[<p>[...] Mocking With&nbsp;NUnit  If you choose Nunit for you Unit Testing and with Mock object for isolating classes from their dependencies for testing purposes.You can go through this tutorial:http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/ [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deva</title>
		<link>http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/comment-page-1/#comment-13429</link>
		<dc:creator>Deva</dc:creator>
		<pubDate>Wed, 02 Jul 2008 11:18:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/#comment-13429</guid>
		<description>Hi,
      Do you have a documentation for the NMock Example Project given</description>
		<content:encoded><![CDATA[<p>Hi,<br />
      Do you have a documentation for the NMock Example Project given</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Paulino</title>
		<link>http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/comment-page-1/#comment-13427</link>
		<dc:creator>Dave Paulino</dc:creator>
		<pubDate>Wed, 02 Jul 2008 03:23:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/#comment-13427</guid>
		<description>@Chad
Very good article and very well explained. This will help developers to understand mock object.

@Geoff
Using the scenario above I agree it is very hard to unit test, but we can use to MVP design pattern to unit test our code.</description>
		<content:encoded><![CDATA[<p>@Chad<br />
Very good article and very well explained. This will help developers to understand mock object.</p>
<p>@Geoff<br />
Using the scenario above I agree it is very hard to unit test, but we can use to MVP design pattern to unit test our code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Lane</title>
		<link>http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/comment-page-1/#comment-11410</link>
		<dc:creator>Geoff Lane</dc:creator>
		<pubDate>Thu, 22 May 2008 14:15:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/#comment-11410</guid>
		<description>Chad,
In a Real application the Service would likely implement an Interface as well. You could then call the Service from UI code. Using ASP.NET, you would likely need to use a framework like &lt;a href="http://www.springframework.net/" rel="nofollow"&gt;Spring .NET&lt;/a&gt; to wire together your dependencies. If you do that though, you can then inject those dependencies into your Pages.

&lt;code&gt;
public class ViewPerson : Page {
    private IPersonService personService;
    protected void Page_Load(object sender, EventArgs e)
    {
        Person person = personService.GetPerson(Request.QueryString["personId"]);
        // ... do something with person
    }
}
&lt;/code&gt;

That doesn't necessarily help a lot with Unit Testing though. Web/UI code is hard to unit test. Your best bet is to keep your UIs very thin, with very little code, and use it merely as a translation layer to get things out of the Web context and into "plain code" context. Then you can Unit Test all of the other code and leave testing of UIs to functional tests.</description>
		<content:encoded><![CDATA[<p>Chad,<br />
In a Real application the Service would likely implement an Interface as well. You could then call the Service from UI code. Using ASP.NET, you would likely need to use a framework like <a href="http://www.springframework.net/" rel="nofollow">Spring .NET</a> to wire together your dependencies. If you do that though, you can then inject those dependencies into your Pages.</p>
<p><pre><code>
public class ViewPerson : Page {
    private IPersonService personService;
    protected void Page_Load(object sender, EventArgs e)
    {
        Person person = personService.GetPerson(Request.QueryString[&quot;personId&quot;]);
        // ... do something with person
    }
}
</code></pre></p>
<p>That doesn&#8217;t necessarily help a lot with Unit Testing though. Web/UI code is hard to unit test. Your best bet is to keep your UIs very thin, with very little code, and use it merely as a translation layer to get things out of the Web context and into &#8220;plain code&#8221; context. Then you can Unit Test all of the other code and leave testing of UIs to functional tests.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad</title>
		<link>http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/comment-page-1/#comment-11386</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Thu, 22 May 2008 04:00:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/#comment-11386</guid>
		<description>Hi Geoff

Im wading my way through loose coupling using interfaces. Forcing me to think about my dependencis before I code. What would be a quick example of your classes using asp.net as a GUI using the above example?

Regards
Chad</description>
		<content:encoded><![CDATA[<p>Hi Geoff</p>
<p>Im wading my way through loose coupling using interfaces. Forcing me to think about my dependencis before I code. What would be a quick example of your classes using asp.net as a GUI using the above example?</p>
<p>Regards<br />
Chad</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Lane</title>
		<link>http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/comment-page-1/#comment-11179</link>
		<dc:creator>Geoff Lane</dc:creator>
		<pubDate>Fri, 29 Feb 2008 02:31:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/#comment-11179</guid>
		<description>Christopher,
Was that an ArgumentException? Using this technique and NMock you can only mock things based on an Interface, not a concrete types. Using an interface is a good practice anyway because it leads to a looser coupling of your objects.

If your really must mock concrete classes (you want to give up loose coupling, or are dealing with dependencies that were not written by you), you might want to look at another Mocking framework like &lt;a href="http://www.ayende.com/projects/rhino-mocks.aspx" rel="nofollow"&gt;Rhino Mocks&lt;/a&gt;.

Hope that helps.</description>
		<content:encoded><![CDATA[<p>Christopher,<br />
Was that an ArgumentException? Using this technique and NMock you can only mock things based on an Interface, not a concrete types. Using an interface is a good practice anyway because it leads to a looser coupling of your objects.</p>
<p>If your really must mock concrete classes (you want to give up loose coupling, or are dealing with dependencies that were not written by you), you might want to look at another Mocking framework like <a href="http://www.ayende.com/projects/rhino-mocks.aspx" rel="nofollow">Rhino Mocks</a>.</p>
<p>Hope that helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christopher Piggott</title>
		<link>http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/comment-page-1/#comment-11178</link>
		<dc:creator>Christopher Piggott</dc:creator>
		<pubDate>Fri, 29 Feb 2008 02:14:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/#comment-11178</guid>
		<description>I tried the above example using my own classes, but I get this:

at System.Runtime.Remoting.Proxies.RealProxy..ctor(Type classToProxy, IntPtr stub, Object stubData)
at NUnit.Mocks.DynamicMock.get_MockInstance()
at SerialWidgetTest_Test.SSHStreamTest.Test1() in C:\WORK\firmware\Helpers\C#\trunk\TestWidgets\TestWidget_NUnit\SSHStreamTest.cs:line 27

I'm not even sure what that means.  Is the type of object I'm trying to mock too complex?</description>
		<content:encoded><![CDATA[<p>I tried the above example using my own classes, but I get this:</p>
<p>at System.Runtime.Remoting.Proxies.RealProxy..ctor(Type classToProxy, IntPtr stub, Object stubData)<br />
at NUnit.Mocks.DynamicMock.get_MockInstance()<br />
at SerialWidgetTest_Test.SSHStreamTest.Test1() in C:\WORK\firmware\Helpers\C#\trunk\TestWidgets\TestWidget_NUnit\SSHStreamTest.cs:line 27</p>
<p>I&#8217;m not even sure what that means.  Is the type of object I&#8217;m trying to mock too complex?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hitesh</title>
		<link>http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/comment-page-1/#comment-11131</link>
		<dc:creator>hitesh</dc:creator>
		<pubDate>Tue, 15 Jan 2008 16:09:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/#comment-11131</guid>
		<description>Very good sample...it helps me to understand the creation of mock object and use them for unit testing</description>
		<content:encoded><![CDATA[<p>Very good sample&#8230;it helps me to understand the creation of mock object and use them for unit testing</p>
]]></content:encoded>
	</item>
</channel>
</rss>
