<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Plastic/Blog</title>
	
	<link>http://blog.codiceplastico.com</link>
	<description>Code Elegance</description>
	<lastBuildDate>Fri, 06 Nov 2009 21:15:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/emablog" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Agile Testing Days 2010</title>
		<link>http://feedproxy.google.com/~r/emablog/~3/J88a0xv3eIk/</link>
		<comments>http://blog.codiceplastico.com/index.php/2009/11/06/agile-testing-days-2010/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 21:15:36 +0000</pubDate>
		<dc:creator>Emanuele DelBono</dc:creator>
				<category><![CDATA[Emanuele DelBono]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[AgileTD]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://blog.codiceplastico.com/index.php/2009/11/06/agile-testing-days-2010/</guid>
		<description><![CDATA[The call for paper for the AgileTestingDays 2010 is open, you can submit your proposal on the site.
I&#8217;m thinking in these days about a session on testing from a developer perspective. 
]]></description>
			<content:encoded><![CDATA[<p>The call for paper for the AgileTestingDays 2010 is open, you can submit your proposal on the <a href="http://www.agiletestingdays.com">site</a>.<br />
I&#8217;m thinking in these days about a session on testing from a developer perspective. </p>
<img src="http://feeds.feedburner.com/~r/emablog/~4/J88a0xv3eIk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.codiceplastico.com/index.php/2009/11/06/agile-testing-days-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.codiceplastico.com/index.php/2009/11/06/agile-testing-days-2010/</feedburner:origLink></item>
		<item>
		<title>AgileTestingDays…a beautiful experience</title>
		<link>http://feedproxy.google.com/~r/emablog/~3/EDa-qyDsblQ/</link>
		<comments>http://blog.codiceplastico.com/index.php/2009/10/18/agiletestingdays-a-beautiful-experience/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 11:59:03 +0000</pubDate>
		<dc:creator>Alessandro Melchiori</dc:creator>
				<category><![CDATA[Alessandro Melchiori]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Agile testing days]]></category>
		<category><![CDATA[AgileTestingDays]]></category>

		<guid isPermaLink="false">http://blog.codiceplastico.com/?p=278</guid>
		<description><![CDATA[The past week, Emanuele and I were in berlin to attend the agile testing days conference.
We made a speech about Continuous Integration, from theory to practice. It was my first &#8220;international&#8221; speech and it gone quite fine.
In those days I saw and I spoke with a lot of &#8220;agile-guru&#8221; like Tom and Mary Poppendieck and [...]]]></description>
			<content:encoded><![CDATA[<p>The past week, Emanuele and I were in berlin to attend the agile testing days conference.<br />
We made a speech about Continuous Integration, from theory to practice. It was my first &#8220;international&#8221; speech and it gone quite fine.<br />
In those days I saw and I spoke with a lot of &#8220;agile-guru&#8221; like Tom and Mary Poppendieck and it was a beautiful experience.<br />
The percept I had is that the rest of Europe is much more advanced than Italy about agile methodologies and theirs adoption.<br />
For example, Sometimes when we go to our customers and suggest some agile practices, they look us in a strange way&#8230;I don&#8217;t know why? Some other speaker, instead, told me that in UK or in Germany, for example, the adoption of agile methodologies is almost a standard-de-facto and with their customers they speak about user stories or continuous integration in a natural way. I hope it will be like this also in Italy.</p>
<p>In conclusion, many thanks to Jose and all his staff for the great organization and&#8230;see you the next year!</p>
<img src="http://feeds.feedburner.com/~r/emablog/~4/EDa-qyDsblQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.codiceplastico.com/index.php/2009/10/18/agiletestingdays-a-beautiful-experience/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.codiceplastico.com/index.php/2009/10/18/agiletestingdays-a-beautiful-experience/</feedburner:origLink></item>
		<item>
		<title>Slides and demo of our session</title>
		<link>http://feedproxy.google.com/~r/emablog/~3/6XAIIV5_PO4/</link>
		<comments>http://blog.codiceplastico.com/index.php/2009/10/14/slides-and-demo-of-our-session/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 11:31:52 +0000</pubDate>
		<dc:creator>Emanuele DelBono</dc:creator>
				<category><![CDATA[Emanuele DelBono]]></category>
		<category><![CDATA[AgileTD]]></category>
		<category><![CDATA[AgileTestingDays]]></category>
		<category><![CDATA[Continuous Integration]]></category>

		<guid isPermaLink="false">http://blog.codiceplastico.com/?p=276</guid>
		<description><![CDATA[You can get the powerpoint presentation and the demos of our session about Continous Integration at the Agile Testing Days here: link
If you need help or some information on how to use them feel free to contact us!
]]></description>
			<content:encoded><![CDATA[<p>You can get the powerpoint presentation and the demos of our session about Continous Integration at the <a href="http://www.agiletestingdays.com" target="_blank">Agile Testing Days</a> here: <a href="http://www.codiceplastico.com/files/AgileTestingDays.zip">link</a></p>
<p>If you need help or some information on how to use them feel free to contact us!</p>
<img src="http://feeds.feedburner.com/~r/emablog/~4/6XAIIV5_PO4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.codiceplastico.com/index.php/2009/10/14/slides-and-demo-of-our-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.codiceplastico.com/index.php/2009/10/14/slides-and-demo-of-our-session/</feedburner:origLink></item>
		<item>
		<title>@Berlin</title>
		<link>http://feedproxy.google.com/~r/emablog/~3/tbunFgthdq4/</link>
		<comments>http://blog.codiceplastico.com/index.php/2009/10/12/berlin/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 09:48:12 +0000</pubDate>
		<dc:creator>Alessandro Melchiori</dc:creator>
				<category><![CDATA[Alessandro Melchiori]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Agile testing days]]></category>

		<guid isPermaLink="false">http://blog.codiceplastico.com/?p=274</guid>
		<description><![CDATA[Finally, we are in Berlin! Emanuele and I arrived yesterday, after a long travel.
It&#8217;s very cold: on saturday, I had a t-shirt on, today in Berlin it&#8217;s snowing almost.
Yesterday I had a half-marathon with Ema, but the first impact with this city is not so good&#8230;maybe for the rain, maybe for the weather or maybe [...]]]></description>
			<content:encoded><![CDATA[<p>Finally, we are in Berlin! <a href="http://blogs.ugidotnet.org/blogema">Emanuele</a> and I arrived yesterday, after a long travel.<br />
It&#8217;s very cold: on saturday, I had a t-shirt on, today in Berlin it&#8217;s snowing almost.<br />
Yesterday I had a half-marathon with Ema, but the first impact with this city is not so good&#8230;maybe for the rain, maybe for the weather or maybe because I woke up 24 hours before.<br />
The <a href="http://www.agiletestingdays.com">conference</a> starts and today is the tutorials-day&#8230;it&#8217;s a good chanche to finish my demo for wednesday <img src='http://blog.codiceplastico.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Stay tuned!</p>
<img src="http://feeds.feedburner.com/~r/emablog/~4/tbunFgthdq4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.codiceplastico.com/index.php/2009/10/12/berlin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.codiceplastico.com/index.php/2009/10/12/berlin/</feedburner:origLink></item>
		<item>
		<title>Agile testing days…we’re arriving (almost)</title>
		<link>http://feedproxy.google.com/~r/emablog/~3/RbtDvm1aF_A/</link>
		<comments>http://blog.codiceplastico.com/index.php/2009/10/08/agile-testing-days-were-arriving-almost/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 19:53:53 +0000</pubDate>
		<dc:creator>Alessandro Melchiori</dc:creator>
				<category><![CDATA[Alessandro Melchiori]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Agile testing days]]></category>
		<category><![CDATA[CI]]></category>

		<guid isPermaLink="false">http://blog.codiceplastico.com/?p=270</guid>
		<description><![CDATA[This afternoon, Emanuele and I have built the demo for the agile testing days.
Our idea is that to completely (more or less) reproduce the build environment that the team uses all days in our projects. The tasks that we have scheduled are:
- automatic assemblies versioning
- integrating database changes
- build
- running unit tests
- running integration tests
- [...]]]></description>
			<content:encoded><![CDATA[<p>This afternoon, <a href="http://blog.codiceplastico.com/index.php/category/emanuele/" target="_blank">Emanuele</a> and I have built the demo for the <a href="http://www.agiletestingdays.com">agile testing days</a>.<br />
Our idea is that to completely (more or less) reproduce the build environment that the team uses all days in our projects. The tasks that we have scheduled are:</p>
<p>- automatic assemblies versioning<br />
- integrating database changes<br />
- build<br />
- running unit tests<br />
- running integration tests<br />
- deploying<br />
- code metrics (and more over) with source monitor, fxcop and simian</p>
<p>The time available is not so much, and we have tried to choose must useful tasks (for us, obviously)<br />
Any other ideas? Suggestions? Tasks that do you want to investigate?</p>
<img src="http://feeds.feedburner.com/~r/emablog/~4/RbtDvm1aF_A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.codiceplastico.com/index.php/2009/10/08/agile-testing-days-were-arriving-almost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.codiceplastico.com/index.php/2009/10/08/agile-testing-days-were-arriving-almost/</feedburner:origLink></item>
		<item>
		<title>V UgiALT.NET conference: call for presenters</title>
		<link>http://feedproxy.google.com/~r/emablog/~3/JRU9WyWEQ8o/</link>
		<comments>http://blog.codiceplastico.com/index.php/2009/10/06/v-ugialt-net-conference-call-for-paper/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 12:03:08 +0000</pubDate>
		<dc:creator>Emanuele DelBono</dc:creator>
				<category><![CDATA[Emanuele DelBono]]></category>
		<category><![CDATA[ALT.NET]]></category>
		<category><![CDATA[Conference]]></category>

		<guid isPermaLink="false">http://blog.codiceplastico.com/index.php/2009/10/06/v-ugialt-net-conference-call-for-paper/</guid>
		<description><![CDATA[We set the date and the location: Milan (Italy), 23rd January 2010.
Like the last one this edition agenda will be built by the community proposals, so if you have an idea for a session topic that you like to talk about send an email to cfp@ugialt.net with a brief abstract.
We wait for your proposal until [...]]]></description>
			<content:encoded><![CDATA[<p>We set the date and the location: Milan (Italy), 23rd January 2010.</p>
<p>Like the last one this edition agenda will be built by the community proposals, so if you have an idea for a session topic that you like to talk about send an email to <a href="mailto:cfp@ugialt.net">cfp@ugialt.net</a> with a brief abstract.</p>
<p>We wait for your proposal until the end of November then we start with the pool to select the sessions for the conference day.</p>
<p>More information on the <a title="mailing list" href="http://tech.groups.yahoo.com/group/ugialtnet/">mailing list</a></p>
<img src="http://feeds.feedburner.com/~r/emablog/~4/JRU9WyWEQ8o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.codiceplastico.com/index.php/2009/10/06/v-ugialt-net-conference-call-for-paper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.codiceplastico.com/index.php/2009/10/06/v-ugialt-net-conference-call-for-paper/</feedburner:origLink></item>
		<item>
		<title>Fixed Price Contracts that change</title>
		<link>http://feedproxy.google.com/~r/emablog/~3/YcW880KR-8M/</link>
		<comments>http://blog.codiceplastico.com/index.php/2009/09/26/fixed-size-contracts-that-change/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 11:35:38 +0000</pubDate>
		<dc:creator>Emanuele DelBono</dc:creator>
				<category><![CDATA[Emanuele DelBono]]></category>
		<category><![CDATA[Agile contracts]]></category>

		<guid isPermaLink="false">http://blog.codiceplastico.com/index.php/2009/09/26/fixed-size-contracts-that-change/</guid>
		<description><![CDATA[With our customers the most used form of contract is the fixed price, only a few customers with whom we have a good old friendship accept other formats of contract.
But I don’t want to talk about the pros&#38;cons of a fixed price contract, everyone who works in the business of software know how bad it [...]]]></description>
			<content:encoded><![CDATA[<p>With our customers the most used form of contract is the fixed price, only a few customers with whom we have a good old friendship accept other formats of contract.</p>
<p>But I don’t want to talk about the pros&amp;cons of a fixed price contract, everyone who works in the business of software know how bad it is not only for the developer company but also for the customers.</p>
<p>But what happens most of the times?</p>
<p>What I see is that we always start with a fixed price contract in which we put all the functionalities that the application must have and we try to estimate the costs and time needed for the development.</p>
<p>If the project starts we try to be agile, so we try to deliver as soon as possible a small functionality to our customers so that they can begin to try it and to evaluate.</p>
<p>What happens here is a curious thing: the customer sees the prototype of the program and even if it is only a small part of the requested product usually he begin to ask for modifications or for a new functionality.</p>
<p>In these contexts, the customer, having a fixed-price contract should accept an addendum to the initial contract that adds the requested modification and/or the new functionalities.</p>
<p>So we abandon the original contract to follow the new addendum with a small set of functionality that we can precisely estimate.</p>
<p>This happens on every small release and so we move from a big-fixed-size contract to a collection of small-fixed-size contracts that are easier to estimate and certainly more manageable.</p>
<p>It seems like the customer unconsciously understand that the fixed size doesn’t work.</p>
<p>This gives us another important effect: in fixed sized contracts, sometimes happens that the customer thinks that every extra request is included in the contract, so he starts to ask for new features. The problem is not only that we have to work more for the same price, is that the customer does not give the right value to his requests: when something is free, you get it even if you don’t need it.</p>
<p>So splitting the contract in small parts, and evaluate every single part gives to the customer the right value for every feature, so he can decide if what he ask for is really needed.</p>
<p> </p>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5012f425-686f-458f-9e9d-c46a50aefad9" class="wlWriterEditableSmartContent" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/Agile+Contracts">Agile Contracts</a></div>
<img src="http://feeds.feedburner.com/~r/emablog/~4/YcW880KR-8M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.codiceplastico.com/index.php/2009/09/26/fixed-size-contracts-that-change/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.codiceplastico.com/index.php/2009/09/26/fixed-size-contracts-that-change/</feedburner:origLink></item>
		<item>
		<title>SqlServer2008: prevent saving changes</title>
		<link>http://feedproxy.google.com/~r/emablog/~3/-PjgPVYKhcU/</link>
		<comments>http://blog.codiceplastico.com/index.php/2009/09/21/sqlserver2008-prevent-saving-changes/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 13:36:15 +0000</pubDate>
		<dc:creator>Alessandro Melchiori</dc:creator>
				<category><![CDATA[Alessandro Melchiori]]></category>
		<category><![CDATA[Sql Server 2008]]></category>
		<category><![CDATA[SqlServer Management Studio]]></category>

		<guid isPermaLink="false">http://blog.codiceplastico.com/?p=257</guid>
		<description><![CDATA[Since I installed SqlServer2008 on my production machine, I tryed to learn T-Sql commands to create tables, to manage indexes (and so on..). In this way I can introduce this scripts in our build automatic environment.
A few days ago, I needed to modify a table’s stucture through SqlServer Management studio. With my pleasure, I noted [...]]]></description>
			<content:encoded><![CDATA[<p>Since I installed SqlServer2008 on my production machine, I tryed to learn T-Sql commands to create tables, to manage indexes (and so on..). In this way I can introduce this scripts in our build automatic environment.<br />
A few days ago, I needed to modify a table’s stucture through SqlServer Management studio. With my pleasure, I noted that this simple task wasn’t not so simple</p>
<p><img class="alignnone size-medium wp-image-258" title="Sql error" src="http://blog.codiceplastico.com/wp-content/uploads/2009/09/Sql-error-300x240.png" alt="Sql error" width="300" height="240" /></p>
<p>To solve this &#8220;issue&#8221; I disabled &#8220;Prevent saving changes that require table re-creation&#8221; option from Tools -&gt; Options menu:</p>
<p> <img class="alignnone size-medium wp-image-259" title="Options" src="http://blog.codiceplastico.com/wp-content/uploads/2009/09/Options-300x179.png" alt="Options" width="300" height="179" /></p>
<img src="http://feeds.feedburner.com/~r/emablog/~4/-PjgPVYKhcU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.codiceplastico.com/index.php/2009/09/21/sqlserver2008-prevent-saving-changes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.codiceplastico.com/index.php/2009/09/21/sqlserver2008-prevent-saving-changes/</feedburner:origLink></item>
		<item>
		<title>NDepend as an analysis tool</title>
		<link>http://feedproxy.google.com/~r/emablog/~3/h0pHrjdgpC0/</link>
		<comments>http://blog.codiceplastico.com/index.php/2009/09/11/ndepend-as-an-analysis-tool/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 07:23:41 +0000</pubDate>
		<dc:creator>Emanuele DelBono</dc:creator>
				<category><![CDATA[Emanuele DelBono]]></category>
		<category><![CDATA[Code Metrics]]></category>
		<category><![CDATA[NDepend]]></category>

		<guid isPermaLink="false">http://blog.codiceplastico.com/index.php/2009/09/11/ndepend-as-an-analysis-tool/</guid>
		<description><![CDATA[In these days I’m giving a look at NDepend. As a consultant I’m quite often called by software houses to review their code and try to improve the codebase.

The the very first thing that I usually do is to run a tool that analyze the codebase to found the critical points and to take a [...]]]></description>
			<content:encoded><![CDATA[<p>In these days I’m giving a look at NDepend. As a consultant I’m quite often called by software houses to review their code and try to improve the codebase.</p>
<p style="text-align: center;"><a href="http://www.ndepend.com/Res/NDependBig08.PNG"><img class="aligncenter" title="NDepend1" src="http://www.ndepend.com/Res/NDependMedium08.PNG" alt="" width="280" height="177" /></a></p>
<p>The the very first thing that I usually do is to run a tool that analyze the codebase to found the critical points and to take a brief review of the project status.</p>
<p>NDepend is a great tool. In the past I used SourceMonitor but NDepend is much more complete and professional and give a lot more information about the code.</p>
<p>The first impression is a bit confusing, the UI is very complex and maybe show too much information for a newbie but if you analyze the single boxes you could see that all you need is in the right place and the UI became very intuitive and complete after few hours of use.</p>
<p>One of the feature that I love is the CQL queries, there are a lot of ready-to-use queries but you can also build your own.</p>
<p> </p>
<p>The queries measure your code (for example they can extract the methods that have more than 50 lines of code or the types that are too coupled to another and so on…) and they are the indispensable tool  to begin with the refactoring.</p>
<p><img class="alignnone" title="NDepend" src="http://www.ndepend.com/Res/CQLEdition1.PNG" alt="" width="584" height="146" /></p>
<p> </p>
<p><a href="http://www.ndepend.com/Res/NDependBig07.PNG" target="_blank"><img class="alignleft" title="NDepend2" src="http://www.ndepend.com/Res/NDependBig07.PNG" alt="" width="442" height="303" /></a>Another nice feature is that NDepend manages the different between two build. One of the important thing of a code metric is not only is absolute value but the variation during the life of the project. Here NDepend came in help with the Compare command that helps in finding the differences between two build of the same application. This metrics gives you the information about the wellness of your refactoring: if the metrics becomes better your work was good, otherwise you can always revert your changes.</p>
<p> </p>
<p> </p>
<p> </p>
<p>Another option to use NDepend is to integrate the tool with CruiseControl.NET like exposed here (<a title="http://confluence.public.thoughtworks.org/display/CCNET/Using+CruiseControl.NET+with+NDepend" href="http://confluence.public.thoughtworks.org/display/CCNET/Using+CruiseControl.NET+with+NDepend">http://confluence.public.thoughtworks.org/display/CCNET/Using+CruiseControl.NET+with+NDepend</a>).</p>
<p>This gives you the ability to continually run NDepend over the builds and have immediate feedback about the code status. I’m working on this and I will write another post about the use of NDepend in a CI environment.</p>
<p>All the information about NDepend is available here: <a href="http://www.ndepend.com">www.ndepend.com</a> and on the author’s blog you can read a lot of articles about the metrics and the use of NDepend(<a title="http://codebetter.com/blogs/patricksmacchia/default.aspx" href="http://codebetter.com/blogs/patricksmacchia/default.aspx">http://codebetter.com/blogs/patricksmacchia/default.aspx</a>)</p>
<img src="http://feeds.feedburner.com/~r/emablog/~4/h0pHrjdgpC0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.codiceplastico.com/index.php/2009/09/11/ndepend-as-an-analysis-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.codiceplastico.com/index.php/2009/09/11/ndepend-as-an-analysis-tool/</feedburner:origLink></item>
		<item>
		<title>How to mock the IMessageBroker</title>
		<link>http://feedproxy.google.com/~r/emablog/~3/Xa0SbDvboGg/</link>
		<comments>http://blog.codiceplastico.com/index.php/2009/09/07/how-to-mock-the-imessagebroker/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 07:36:07 +0000</pubDate>
		<dc:creator>Emanuele DelBono</dc:creator>
				<category><![CDATA[Emanuele DelBono]]></category>
		<category><![CDATA[Mediator]]></category>
		<category><![CDATA[MessageBroker]]></category>
		<category><![CDATA[Mock]]></category>
		<category><![CDATA[Moq]]></category>
		<category><![CDATA[MVVM]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://blog.codiceplastico.com/index.php/2009/09/07/how-to-mock-the-imessagebroker/</guid>
		<description><![CDATA[On the blogs there are a lot of articles about the M-V-VM pattern showing how to decouple the various components of our application to make it modular.
One of the component that helps the ViewModels to communicate with other ViewModels is the MessageBroker (AKA EventAggregator, AKA Mediator): a manager class that route the messages from the [...]]]></description>
			<content:encoded><![CDATA[<p>On the blogs there are a lot of articles about the M-V-VM pattern showing how to decouple the various components of our application to make it modular.</p>
<p>One of the component that helps the ViewModels to communicate with other ViewModels is the MessageBroker (AKA EventAggregator, AKA Mediator): a manager class that route the messages from the ViewModels.</p>
<p>One good implementation of the Mediator for the MVVM is this <a title="http://sachabarber.net/?p=477" href="http://sachabarber.net/?p=477">http://sachabarber.net/?p=477</a>:</p>
<p>To make it more testable we extract an interface:</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">interface</span> IMessageBroker
{
  <span class="kwrd">void</span> NotifyColleagues(MessageType messageType);
  <span class="kwrd">void</span> Register&lt;T&gt;(Action&lt;T&gt; action, MessageType messageType);
}</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p> </p>
<p>If you TDD your application or if you write unit test you could need to mock the IMessageBroker and it’s not immediate because the Action&lt;T&gt;.</p>
<p><a href="http://blogs.ugidotnet.org/AMelchiori" target="_blank">Alessandro</a> wrote a solution that is interesting using <a href="http://code.google.com/p/moq/" target="_blank">Moq</a>:</p>
<pre class="csharpcode">[Fact]
<span class="kwrd">public</span> <span class="kwrd">void</span> Sample_Test()
{
  Mock&lt;IMessageBroker&gt; broker = <span class="kwrd">new</span> Mock&lt;IMessageBroker&gt;();
  Action&lt;String&gt; action = <span class="kwrd">null</span>;

  broker
    .Setup(b =&gt; b.Subscribe(It.IsAny&lt;Action&lt;String&gt;&gt;()))
    .Callback&lt;Action&lt;String&gt;&gt;(a =&gt; action = a);

  <span class="kwrd">new</span> FakeViewModel(broker.Object);

  action.Invoke(<span class="str">"TestMessage"</span>);

  <span class="rem">// Asserts...</span>
}</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>Moq is a powerful mock framework and it’s simplicity make the elegant and easy to read!</p>
<p> </p>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4f4c6087-6f7c-4bce-a555-bbecf6e33351" class="wlWriterEditableSmartContent" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/Moq">Moq</a>,<a rel="tag" href="http://technorati.com/tags/MVVM">MVVM</a>,<a rel="tag" href="http://technorati.com/tags/Mock">Mock</a>,<a rel="tag" href="http://technorati.com/tags/Test">Test</a>,<a rel="tag" href="http://technorati.com/tags/Mediator">Mediator</a>,<a rel="tag" href="http://technorati.com/tags/MessageBroker">MessageBroker</a></div>
<img src="http://feeds.feedburner.com/~r/emablog/~4/Xa0SbDvboGg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.codiceplastico.com/index.php/2009/09/07/how-to-mock-the-imessagebroker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.codiceplastico.com/index.php/2009/09/07/how-to-mock-the-imessagebroker/</feedburner:origLink></item>
	</channel>
</rss>
