<?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: Unit Test Private Methods in Visual Studio</title>
	<atom:link href="http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/</link>
	<description>web development, tech reviews, tips, tricks, blogging</description>
	<lastBuildDate>Sun, 07 Mar 2010 18:27:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: eibrahim</title>
		<link>http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/comment-page-1/#comment-906</link>
		<dc:creator>eibrahim</dc:creator>
		<pubDate>Sat, 31 Oct 2009 22:24:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/#comment-906</guid>
		<description>That&#039;s a pretty good idea except for the  fact that it &quot;pollutes&quot; the  &lt;br&gt;code.</description>
		<content:encoded><![CDATA[<p>That&#39;s a pretty good idea except for the  fact that it &#8220;pollutes&#8221; the  <br />code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eibrahim</title>
		<link>http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/comment-page-1/#comment-875</link>
		<dc:creator>eibrahim</dc:creator>
		<pubDate>Sat, 31 Oct 2009 15:24:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/#comment-875</guid>
		<description>That&#039;s a pretty good idea except for the  fact that it &quot;pollutes&quot; the  &lt;br&gt;code.</description>
		<content:encoded><![CDATA[<p>That&#39;s a pretty good idea except for the  fact that it &#8220;pollutes&#8221; the  <br />code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug de la Torre</title>
		<link>http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/comment-page-1/#comment-874</link>
		<dc:creator>Doug de la Torre</dc:creator>
		<pubDate>Sat, 31 Oct 2009 05:23:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/#comment-874</guid>
		<description>The downside to using PrivateObject is that it is a bit painful to maintain, since signature changes are not caught at compile-time, but instead caught at test-time.  Refactorings that change method signatures tend to catch all the compile-time stuff, but then leave test code broken, and it is tougher to fix.&lt;br&gt;&lt;br&gt;An alternative that I&#039;ve always liked is to use inner-classes to test your code, like this:&lt;br&gt;&lt;br&gt;public class Foo &lt;br&gt;{&lt;br&gt;   private void Bar()&lt;br&gt;   {&lt;br&gt;     // Do so work here in a private method&lt;br&gt;   }&lt;br&gt;&lt;br&gt;#region Unit Tests&lt;br&gt;#if UNIT_TESTS&lt;br&gt;    [TestFixture] public class TestFoo&lt;br&gt;    {&lt;br&gt;        [Test] public void TestBar()&lt;br&gt;        {&lt;br&gt;            Foo foo = new Foo()&lt;br&gt;            foo.Bar();   // inner class can call this method&lt;br&gt;        }&lt;br&gt;    }  &lt;br&gt;#endif&lt;br&gt;#end region&lt;br&gt;}&lt;br&gt;&lt;br&gt;You simply define UNIT_TESTS in Debug/Release builds if you want test code enabled, and leave it out from your Ship builds.&lt;br&gt;&lt;br&gt;Also, you&#039;ll probably have a using statement wrapper, &lt;br&gt;&lt;br&gt;#if UNIT_TESTS&lt;br&gt;using MbUnit.Framework;&lt;br&gt;#endif&lt;br&gt;&lt;br&gt;As an added check, you can write a simple app that does reflection on all the types in the DLL to verify your ship build doesn&#039;t have any classes with test attributes.  If no code references the test framework, your ship builds will automatically not load the referenced test framework DLLs, thus allowing you to ship your product like usual without pulling in test DLL dependencies (and associated bloat and licensing issues).</description>
		<content:encoded><![CDATA[<p>The downside to using PrivateObject is that it is a bit painful to maintain, since signature changes are not caught at compile-time, but instead caught at test-time.  Refactorings that change method signatures tend to catch all the compile-time stuff, but then leave test code broken, and it is tougher to fix.</p>
<p>An alternative that I&#39;ve always liked is to use inner-classes to test your code, like this:</p>
<p>public class Foo <br />{<br />   private void Bar()<br />   {<br />     // Do so work here in a private method<br />   }</p>
<p>#region Unit Tests<br />#if UNIT_TESTS<br />    [TestFixture] public class TestFoo<br />    {<br />        [Test] public void TestBar()<br />        {<br />            Foo foo = new Foo()<br />            foo.Bar();   // inner class can call this method<br />        }<br />    }  <br />#endif<br />#end region<br />}</p>
<p>You simply define UNIT_TESTS in Debug/Release builds if you want test code enabled, and leave it out from your Ship builds.</p>
<p>Also, you&#39;ll probably have a using statement wrapper, </p>
<p>#if UNIT_TESTS<br />using MbUnit.Framework;<br />#endif</p>
<p>As an added check, you can write a simple app that does reflection on all the types in the DLL to verify your ship build doesn&#39;t have any classes with test attributes.  If no code references the test framework, your ship builds will automatically not load the referenced test framework DLLs, thus allowing you to ship your product like usual without pulling in test DLL dependencies (and associated bloat and licensing issues).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eibrahim</title>
		<link>http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/comment-page-1/#comment-814</link>
		<dc:creator>eibrahim</dc:creator>
		<pubDate>Thu, 28 May 2009 09:47:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/#comment-814</guid>
		<description>Sorry, but the last time I used c++ was in college :)</description>
		<content:encoded><![CDATA[<p>Sorry, but the last time I used c++ was in college :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jared</title>
		<link>http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/comment-page-1/#comment-813</link>
		<dc:creator>Jared</dc:creator>
		<pubDate>Wed, 27 May 2009 14:32:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/#comment-813</guid>
		<description>Do you know of a way that you can do this with managed C++ that references unmanaged C++ types? Please see this question: &lt;a href=&quot;http://stackoverflow.com/questions/916507/how-to-convert-a-user-defined-unmanaged-type-to-a-managed-type&quot; rel=&quot;nofollow&quot;&gt;http://stackoverflow.com/questions/916507/how-t...&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Do you know of a way that you can do this with managed C++ that references unmanaged C++ types? Please see this question: <a href="http://stackoverflow.com/questions/916507/how-to-convert-a-user-defined-unmanaged-type-to-a-managed-type" rel="nofollow"></a><a href="http://stackoverflow.com/questions/916507/how-t.." rel="nofollow">http://stackoverflow.com/questions/916507/how-t..</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephen</title>
		<link>http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/comment-page-1/#comment-792</link>
		<dc:creator>stephen</dc:creator>
		<pubDate>Thu, 19 Mar 2009 07:34:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/#comment-792</guid>
		<description>Brilliant Idea, been looking for a straight forward solution to this scenerio that did not invlove using heavyweight reflection.</description>
		<content:encoded><![CDATA[<p>Brilliant Idea, been looking for a straight forward solution to this scenerio that did not invlove using heavyweight reflection.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bookmarks about Mvc</title>
		<link>http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/comment-page-1/#comment-582</link>
		<dc:creator>Bookmarks about Mvc</dc:creator>
		<pubDate>Tue, 26 Aug 2008 04:01:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/#comment-582</guid>
		<description>[...] - bookmarked by 5 members originally found by rvwingerden on 2008-08-03  Unit Test Private Methods in Visual Studio  http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/ - bookmarked by [...]</description>
		<content:encoded><![CDATA[<p>[...] &#8211; bookmarked by 5 members originally found by rvwingerden on 2008-08-03  Unit Test Private Methods in Visual Studio  <a href="http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/" rel="nofollow">http://www.emadibrahim.com/2008/07/09/unit-test-private-methods-in-visual-studio/</a> &#8211; bookmarked by [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
