<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	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>TDD developer &#187; mbunit</title>
	<atom:link href="http://testdrivendevelopment.wordpress.com/tag/mbunit/feed/" rel="self" type="application/rss+xml" />
	<link>http://testdrivendevelopment.wordpress.com</link>
	<description>Diary of an agile developer</description>
	<lastBuildDate>Wed, 28 Oct 2009 22:06:05 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='testdrivendevelopment.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/a6ef45b2d30fa0fcbe697fa111d46fdd?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>TDD developer &#187; mbunit</title>
		<link>http://testdrivendevelopment.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://testdrivendevelopment.wordpress.com/osd.xml" title="TDD developer" />
		<item>
		<title>Use NAnt to run mbunit tests using gallio</title>
		<link>http://testdrivendevelopment.wordpress.com/2008/12/01/use-nant-to-run-mbunit-tests-using-gallio/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2008/12/01/use-nant-to-run-mbunit-tests-using-gallio/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 19:55:11 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gallio]]></category>
		<category><![CDATA[mbunit]]></category>
		<category><![CDATA[NAnt]]></category>

		<guid isPermaLink="false">http://testdrivendevelopment.wordpress.com/2008/12/01/use-nant-to-run-mbunit-tests-using-gallio/</guid>
		<description><![CDATA[Gallio has a great build-in support for NAnt! Unfortunately at the moment this is not well document so if you need to create a target to execute all tests inside an assembly you can write this xml fragment inside your NAnt project file:
&#60;target name=&#8221;test&#8221; depends=&#8221;build&#8221;&#62; &#160; &#60;gallio &#160;&#160;&#160; result-property=&#8221;exitCode&#8221; &#160;&#160;&#160; failonerror=&#8221;false&#8221; &#62; &#160;&#160;&#160; &#60;runner-extension value=&#8221;TeamCityExtension,Gallio.TeamCityIntegration&#8221; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&blog=2459763&post=52&subd=testdrivendevelopment&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Gallio has a great build-in support for NAnt! <br />Unfortunately at the moment this is not well document so if you need to create a target to execute all tests inside an assembly you can write this xml fragment inside your NAnt project file:</p>
<p>&lt;target name=&#8221;test&#8221; depends=&#8221;build&#8221;&gt; <br />&nbsp; &lt;gallio <br />&nbsp;&nbsp;&nbsp; result-property=&#8221;exitCode&#8221; <br />&nbsp;&nbsp;&nbsp; failonerror=&#8221;false&#8221; &gt; <br />&nbsp;&nbsp;&nbsp; &lt;runner-extension value=&#8221;TeamCityExtension,Gallio.TeamCityIntegration&#8221; /&gt; <br />&nbsp;&nbsp;&nbsp; &lt;assemblies&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211; Specify the tests assemblies &#8211;&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;include name=&#8221;${src.dir}Data.Fixturebin${project.config}Data.Fixture.dll&#8221;/&gt; <br />&nbsp;&nbsp;&nbsp; &lt;/assemblies&gt; <br />&nbsp; &lt;/gallio&gt; <br />&nbsp; &lt;fail if=&#8221;${exitCode != &#8216;0&#8242;}&#8221; &gt;One or more tests failed. Please check the log for more details&lt;/fail&gt;&nbsp;&nbsp;&nbsp; <br />&lt;/target&gt;</p>
<p>don&#8217;t forget to load Gallio NAnt Tasks before start with this line of xml</p>
<p>&lt;loadtasks assembly=&#8221;.toolsGallioGallio.NAntTasks.dll&#8221; /&gt;</p>
<p>If you need more information you can take a look at comment in the source code <a href="http://code.google.com/p/mb-unit/source/browse/trunk/v3/src/Extensions/NAnt/Gallio.NAntTasks/GallioTask.cs">here</a></p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:02166a15-f528-4dcf-88d4-45d3b5ea5ee6" style="display:inline;margin:0;padding:0;">Technorati Tag: <a href="http://technorati.com/tags/NAnt" rel="tag">NAnt</a>,<a href="http://technorati.com/tags/Gallio" rel="tag">Gallio</a>,<a href="http://technorati.com/tags/mbunit" rel="tag">mbunit</a></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&blog=2459763&post=52&subd=testdrivendevelopment&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2008/12/01/use-nant-to-run-mbunit-tests-using-gallio/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>
	</item>
		<item>
		<title>Optimise Rhino.Mocks tests using a base class</title>
		<link>http://testdrivendevelopment.wordpress.com/2008/04/27/optimise-rhinomocks-tests-using-a-base-class/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2008/04/27/optimise-rhinomocks-tests-using-a-base-class/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 10:29:56 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mbunit]]></category>
		<category><![CDATA[nbehave]]></category>
		<category><![CDATA[rhino.mocks]]></category>

		<guid isPermaLink="false">http://testdrivendevelopment.wordpress.com/2008/04/27/optimise-rhinomocks-tests-using-a-base-class/</guid>
		<description><![CDATA[It&#8217;s usual my team to use ModelViewPresenter pattern and than use Rhino.Mocks to test Presenter without concrete View and Model. Rhino.Mock is a great tool but its usage can be quite booring as it requires some repeated code for each test. Here a sample:
    public class Presenter
    {
  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&blog=2459763&post=16&subd=testdrivendevelopment&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>It&#8217;s usual my team to use ModelViewPresenter pattern and than use Rhino.Mocks to test Presenter without concrete View and Model. Rhino.Mock is a great tool but its usage can be quite booring as it requires some repeated code for each test. Here a sample:</p>
<pre>    <span class="kwrd">public</span> <span class="kwrd">class</span> Presenter
    {
        <span class="kwrd">public</span> Presenter(IView view, IModel model)
        {
            model.Loaded += <span class="kwrd">delegate</span> { <span class="kwrd">throw</span> <span class="kwrd">new</span> NotImplementedException(); };
        }
    }

    <span class="kwrd">public</span> <span class="kwrd">interface</span> IModel
    {
        <span class="kwrd">event</span> EventHandler Loaded;
    }

    <span class="kwrd">public</span> <span class="kwrd">interface</span> IView
    {
    }</pre>
<p>I want to test that during constructor Presenter subscribe model Loaded event. So I need to write this unit test using Rhino.Mocks:</p>
<pre>[TestFixture]
<span class="kwrd">public</span> <span class="kwrd">class</span> ClassicMockingSample
{
    <span class="kwrd">private</span> IView _view;
    <span class="kwrd">private</span> IModel _model;
    <span class="kwrd">private</span> MockRepository _repository;

    [SetUp]
    <span class="kwrd">public</span> <span class="kwrd">void</span> SetUp()
    {
        _repository = <span class="kwrd">new</span> MockRepository();
        _view = _repository.Stub&lt;IView&gt;();
        _model = _repository.CreateMock&lt;IModel&gt;();
    }

    [Test]
    <span class="kwrd">public</span> <span class="kwrd">void</span> Ctor_Always_SubscribeModelEvents()
    {

        <span class="kwrd">using</span> (_repository.Record())
        {
            Expect.Call(<span class="kwrd">delegate</span> { _model.Loaded += <span class="kwrd">null</span>; })
                .Constraints(Is.NotNull());
        }
        <span class="kwrd">using</span> (_repository.Playback())
        {
            <span class="kwrd">new</span> Presenter(_view, _model);
        }
    }
}</pre>
<p>Looking at NBehave framework I discover a usefull class SpecBase that hides the codes needed to create MockRepository repository and give you more readable code.<br />
Here the same test as shown before but refactored using SpecBase class</p>
<pre>[Context]
<span class="kwrd">public</span> <span class="kwrd">class</span> NBehaveLikeMockingSample : SpecBase
{
    <span class="kwrd">private</span> IModel model;
    <span class="kwrd">private</span> IView view;

    <span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> Before_each_spec()
    {
        model = Mock&lt;IModel&gt;();
        view = Stub&lt;IView&gt;();
    }

    [Specification]
    <span class="kwrd">public</span> <span class="kwrd">void</span> Ctor_Always_SubscribeModelEvents()
    {
        <span class="kwrd">using</span> (RecordExpectedBehavior)
        {
            Expect.Call(<span class="kwrd">delegate</span> { model.Loaded += <span class="kwrd">null</span>; })
                .Constraints(Is.NotNull());
        }
        <span class="kwrd">using</span> (PlaybackBehavior)
        {
            <span class="kwrd">new</span> Presenter(view, model);
        }
    }
}</pre>
<p>As you can see there is nothing magic here.<br />
It&#8217; just a more readable unit test. Context and Specification attribute are alias of MbUnit attribute</p>
<pre><span class="kwrd">using</span> Context = MbUnit.Framework.TestFixtureAttribute;
<span class="kwrd">using</span> Specification = MbUnit.Framework.TestAttribute;</pre>
<p>As I don&#8217;t need all the NBehave framework for the moment I decided to copy the class SpecBase inside my UnitTest Assembly after removing the AutoMocking feature.The code it&#8217;s here:</p>
<pre><span class="kwrd">public</span> <span class="kwrd">class</span> SpecBase
{
    <span class="kwrd">private</span> MockRepository _mocks;

    <span class="kwrd">protected</span> IDisposable RecordExpectedBehavior
    {
        get { <span class="kwrd">return</span> _mocks.Record(); }
    }

    <span class="kwrd">protected</span> IDisposable PlaybackBehavior
    {
        get { <span class="kwrd">return</span> _mocks.Playback(); }
    }

    [SetUp]
    <span class="kwrd">public</span> <span class="kwrd">void</span> MainSetup()
    {
        _mocks = <span class="kwrd">new</span> MockRepository();
        Before_each_spec();
    }

    [TearDown]
    <span class="kwrd">public</span> <span class="kwrd">void</span> MainTeardown()
    {
        After_each_spec();
    }

    <span class="kwrd">protected</span> <span class="kwrd">virtual</span> <span class="kwrd">void</span> Before_each_spec()
    {

    }

    <span class="kwrd">protected</span> <span class="kwrd">virtual</span> <span class="kwrd">void</span> After_each_spec()
    {
    }

    <span class="kwrd">protected</span> TType Mock&lt;TType&gt;()
    {
        <span class="kwrd">return</span> _mocks.DynamicMock&lt;TType&gt;();
    }

    <span class="kwrd">protected</span> TType Mock&lt;TType&gt;(<span class="kwrd">object</span>[] prams)
    {
        <span class="kwrd">return</span> _mocks.DynamicMock&lt;TType&gt;(prams);
    }

    <span class="kwrd">protected</span> TType Partial&lt;TType&gt;()
        <span class="kwrd">where</span> TType : <span class="kwrd">class</span>
    {
        <span class="kwrd">return</span> _mocks.PartialMock&lt;TType&gt;();
    }

    <span class="kwrd">protected</span> TType Stub&lt;TType&gt;()
    {
        <span class="kwrd">return</span> _mocks.Stub&lt;TType&gt;();
    }

    <span class="kwrd">protected</span> <span class="kwrd">void</span> Verify(<span class="kwrd">object</span> mock)
    {
        _mocks.Verify(mock);
    }

    <span class="kwrd">protected</span> <span class="kwrd">void</span> VerifyAll()
    {
        _mocks.VerifyAll();
    }

    <span class="kwrd">protected</span> <span class="kwrd">void</span> Spec_not_implemented()
    {
        Assert.Ignore(<span class="str">"Spec not implemented"</span>);
    }
}</pre>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:eb9418a1-5ae4-430e-8a3c-4ec61e22cade" class="wlWriterSmartContent" style="display:inline;margin:0;padding:0;">Technorati Tag: <a rel="tag" href="http://technorati.com/tags/MbUnit">MbUnit</a>,<a rel="tag" href="http://technorati.com/tags/Rhino.Mocks">Rhino.Mocks</a>,<a rel="tag" href="http://technorati.com/tags/NBehave">NBehave</a></div>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/testdrivendevelopment.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/testdrivendevelopment.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&blog=2459763&post=16&subd=testdrivendevelopment&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2008/04/27/optimise-rhinomocks-tests-using-a-base-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>
	</item>
	</channel>
</rss>