<?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/"
	>

<channel>
	<title>Infinity</title>
	<atom:link href="http://blog.cyragon.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cyragon.com</link>
	<description>where it all begins</description>
	<lastBuildDate>Wed, 18 Aug 2010 21:12:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Coping contents of Template Column in data grid to clipboard</title>
		<link>http://blog.cyragon.com/2010/08/coping-contents-of-template-column-in-data-grid-to-clipboard/</link>
		<comments>http://blog.cyragon.com/2010/08/coping-contents-of-template-column-in-data-grid-to-clipboard/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 21:12:25 +0000</pubDate>
		<dc:creator>Ben Farmer</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://blog.cyragon.com/?p=187</guid>
		<description><![CDATA[There are some nice new features (coming from Silverlight 2) in the latest versions of Silverlight &#8211; being able to copy rows in a DataGrid via the familiar Control+C for instance. But I noticed something strange: some columns were blank when I pasted them into Excel (or notepad). The blank columns were always DataGridTemplateColumn and [...]]]></description>
			<content:encoded><![CDATA[<p>There are some nice new features (coming from Silverlight 2) in the latest versions of Silverlight &#8211; being able to copy rows in a DataGrid via the familiar Control+C for instance. </p>
<p>But I noticed something strange: some columns were blank when I pasted them into Excel (or notepad). The blank columns were always DataGridTemplateColumn and that made sense. How could it know what to copy from one or more controls? </p>
<p>Turns out this is really easy to fix if you are using data binding. All you have to do is bind the ClipboardContentBinding property on the DataGridTemplateColumn with the value you want copied for this column.</p>
<p>For example:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p187code2'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1872"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p187code2"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;data:DataGridTemplateColumn</span> <span style="color: #000066;">Header</span>=<span style="color: #ff0000;">&quot;Name&quot;</span> <span style="color: #000066;">ClipboardContentBinding</span>=<span style="color: #ff0000;">&quot;{Binding Name}&quot;</span> <span style="color: #000066;">SortMemberPath</span>=<span style="color: #ff0000;">&quot;Name&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;data:DataGridTemplateColumn.CellTemplate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DataTemplate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;HyperlinkButton</span> <span style="color: #000066;">Content</span>=<span style="color: #ff0000;">&quot;{Binding Name}&quot;</span> <span style="color: #000066;">Margin</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DataTemplate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/data:DataGridTemplateColumn.CellTemplate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/data:DataGridTemplateColumn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>And that&#8217;s it. Control+C copy works as desired.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cyragon.com/2010/08/coping-contents-of-template-column-in-data-grid-to-clipboard/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CodeStock 2010: Chaos to Awesome</title>
		<link>http://blog.cyragon.com/2010/06/codestock-2010-chaos-to-awesome/</link>
		<comments>http://blog.cyragon.com/2010/06/codestock-2010-chaos-to-awesome/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 13:00:07 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[CodeStock]]></category>

		<guid isPermaLink="false">http://blog.cyragon.com/?p=183</guid>
		<description><![CDATA[We&#8217;ll be posting our notes and slidedeck a bit later, but here are some of the resources we talked about in the presentation. VisualSVN Server: http://www.visualsvn.com/server/ Ankh SVN (plugin for Visual Studio): http://ankhsvn.open.collab.net/ Hudson Continuous Integration: http://hudson-ci.org/ Fitnesse (.NET/SLiM): http://www.fitnesse.org/ and http://www.fitnesse.org/FitNesse.DotNet You can always message us on twitter @jwcarroll and @benfarmer.]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ll be posting our notes and slidedeck a bit later, but here are some of the resources we talked about in the presentation.</p>
<p>VisualSVN Server: <a href="http://www.visualsvn.com/server/">http://www.visualsvn.com/server/</a><br />
Ankh SVN (plugin for Visual Studio): <a href="http://ankhsvn.open.collab.net/">http://ankhsvn.open.collab.net/</a></p>
<p>Hudson Continuous Integration: <a href="http://hudson-ci.org/">http://hudson-ci.org/</a></p>
<p>Fitnesse (.NET/SLiM): <a href="http://www.fitnesse.org">http://www.fitnesse.org/</a> and <a href="http://www.fitnesse.org/FitNesse.DotNet">http://www.fitnesse.org/FitNesse.DotNet</a></p>
<p>You can always message us on twitter <a href="http://twitter.com/jwcarroll">@jwcarroll</a> and <a href="http://twitter.com/benfarmer">@benfarmer</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cyragon.com/2010/06/codestock-2010-chaos-to-awesome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending Moq&#8217;s Setup() to return multiple values</title>
		<link>http://blog.cyragon.com/2010/06/extending-moqs-setup-to-return-multiple-values/</link>
		<comments>http://blog.cyragon.com/2010/06/extending-moqs-setup-to-return-multiple-values/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 20:37:35 +0000</pubDate>
		<dc:creator>jwcarroll</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Moq]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://blog.cyragon.com/?p=134</guid>
		<description><![CDATA[If you regularly use TDD, then you are familiar with the concept of mocking. If you don&#8217;t use TDD, then you need to slap yourself and apologize to Bob Martin, Michael Feathers and Ron Jeffries immediately. I&#8217;ll wait here&#8230; While I would argue you should begin your TDD journey by writing your own mocks; using a framework [...]]]></description>
			<content:encoded><![CDATA[<p>If you regularly use <a href="http://en.wikipedia.org/wiki/Test-driven_development">TDD</a>, then you are familiar with the concept of mocking. If you don&#8217;t use TDD, then you need to slap yourself and apologize to <a href="http://www.objectmentor.com/omTeam/martin_r.html">Bob Martin</a>, <a href="http://www.objectmentor.com/omTeam/feathers_m.html">Michael Feathers</a> and <a href="http://www.objectmentor.com/omTeam/jeffries_r.html">Ron Jeffries</a> immediately. I&#8217;ll wait here&#8230;</p>
<p>While I would argue you should begin your TDD journey by <a href="http://blog.objectmentor.com/articles/2009/10/28/manual-mocking-resisting-the-invasion-of-dots-and-parentheses">writing your own mocks</a>; using a framework will certainly make like easier in many instances and allow you to focus on the tests themselves.</p>
<p>I was a <a href="http://www.ayende.com/projects/rhino-mocks.aspx">RhinoMocks</a> guy for a long time, but have recently converted to <a href="http://code.google.com/p/moq/">Moq</a>&#8230; AND I LOVE IT!!! Moq is simple and easy to use, and doesn&#8217;t get in the way of the intent of your tests. That being said, there are certain scenarios you run into with any framework that you end up coding around, and sometimes that <em>does</em> get in the way of your what you trying to say with your test.</p>
<p>Moq allows for a pretty simple syntax when you want to set up a return value on a mocked type.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p134code11'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13411"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p134code11"><pre class="csharp" style="font-family:monospace;">var mockService <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Mock<span style="color: #008000;">&lt;</span>IReturnStuff<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
mockService<span style="color: #008000;">.</span><span style="color: #0000FF;">Setup</span><span style="color: #008000;">&#40;</span>svc <span style="color: #008000;">=&gt;</span> svc<span style="color: #008000;">.</span><span style="color: #0000FF;">SomeMethodCall</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Returns</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Hello, World!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>
Pretty sweet so far, and that works 99% of the time. But&#8230; what about a scenario where we want to return different values on successive calls to that method. I can think of a lot of situations where, in the absence of formal eventing, you want your code to test some value until it meets a certain criteria. You might be polling a web service for status updates, or checking a database to see if a record has been written. Whatever the case may be, it <em>will</em> come up.</p>
<p>So, for illustration purposes, let&#8217;s make up one such example. Suppose we wanted to ask a service for a specified set of values, but the return types could be varied. Perhaps we only care about some subset of those values, and want to test that our code correctly deals with variable data.</p>
<p>We have our service contract:<br />
</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p134code12'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13412"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p134code12"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">interface</span> IReturnStuff
<span style="color: #008000;">&#123;</span>
    <span style="color: #6666cc; font-weight: bold;">String</span> ReturnAString<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>
Next we have our consuming class (the subject under test):<br />
</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p134code13'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13413"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="p134code13"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> UsesReturnedStuff
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> IReturnStuff ReturnStuff <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> Regex Filter <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> UsesReturnedStuff<span style="color: #008000;">&#40;</span>IReturnStuff returnStuff<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        ReturnStuff <span style="color: #008000;">=</span> returnStuff<span style="color: #008000;">;</span>
        Filter <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Regex<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;(the|quick|brown|fox|hello|world)(:Pu)?&quot;</span>, RegexOptions<span style="color: #008000;">.</span><span style="color: #0000FF;">IgnoreCase</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> List<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">&gt;</span> GetStuff<span style="color: #008000;">&#40;</span>Int32 times<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        var stuff <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span>var i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> times<span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            var newStuff <span style="color: #008000;">=</span> ReturnStuff<span style="color: #008000;">.</span><span style="color: #0000FF;">ReturnAString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>Filter<span style="color: #008000;">.</span><span style="color: #0000FF;">IsMatch</span><span style="color: #008000;">&#40;</span>newStuff<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                stuff<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>newStuff<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> stuff<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>
As you can see we have a pretty basic setup here that uses a white-list approach to building up a list. We want to write some tests to mock this behavior. If we wanted two different return values when this method is called, we might instinctively write a test like this:<br />
</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p134code14'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13414"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p134code14"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>Test<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> LastSetupWins<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
var mockReturnStuff <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Mock<span style="color: #008000;">&lt;</span>IReturnStuff<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
var usesStuff <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> UsesReturnedStuff<span style="color: #008000;">&#40;</span>mockReturnStuff<span style="color: #008000;">.</span><span style="color: #6666cc; font-weight: bold;">Object</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
mockReturnStuff<span style="color: #008000;">.</span><span style="color: #0000FF;">Setup</span><span style="color: #008000;">&#40;</span>svc <span style="color: #008000;">=&gt;</span> svc<span style="color: #008000;">.</span><span style="color: #0000FF;">ReturnAString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Returns</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Hello&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
mockReturnStuff<span style="color: #008000;">.</span><span style="color: #0000FF;">Setup</span><span style="color: #008000;">&#40;</span>svc <span style="color: #008000;">=&gt;</span> svc<span style="color: #008000;">.</span><span style="color: #0000FF;">ReturnAString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Returns</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;World!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
var stuff <span style="color: #008000;">=</span> usesStuff<span style="color: #008000;">.</span><span style="color: #0000FF;">GetStuff</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">AreEqual</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Hello World!&quot;</span>, <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Join</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &quot;</span>, stuff<span style="color: #008000;">.</span><span style="color: #0000FF;">ToArray</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>
If you couldn&#8217;t already tell from the name of the test method, this won&#8217;t work as the last return value to be Setup wins. The output from this test will produce the text:</p>
<blockquote><p>&#8220;World! World!&#8221;</p></blockquote>
<p>Not so great, but the Moq documentation gives us a workaround by using a callback method. A little bit of refactoring and Voila!<br />
</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p134code15'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13415"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p134code15"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>Test<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SetupWithCallback<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    var mockReturnStuff <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Mock<span style="color: #008000;">&lt;</span>IReturnStuff<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    var usesStuff <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> UsesReturnedStuff<span style="color: #008000;">&#40;</span>mockReturnStuff<span style="color: #008000;">.</span><span style="color: #6666cc; font-weight: bold;">Object</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var returnValues <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span><span style="color: #666666;">&quot;Hello&quot;</span>, <span style="color: #666666;">&quot;World!&quot;</span><span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
    var numCalls <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
&nbsp;
    mockReturnStuff<span style="color: #008000;">.</span><span style="color: #0000FF;">Setup</span><span style="color: #008000;">&#40;</span>svc <span style="color: #008000;">=&gt;</span> svc<span style="color: #008000;">.</span><span style="color: #0000FF;">ReturnAString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">.</span><span style="color: #0000FF;">Returns</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> returnValues<span style="color: #008000;">&#91;</span>numCalls<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">.</span><span style="color: #0000FF;">Callback</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> numCalls<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var stuff <span style="color: #008000;">=</span> usesStuff<span style="color: #008000;">.</span><span style="color: #0000FF;">GetStuff</span><span style="color: #008000;">&#40;</span>returnValues<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">AreEqual</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Hello World!&quot;</span>, <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Join</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &quot;</span>, stuff<span style="color: #008000;">.</span><span style="color: #0000FF;">ToArray</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>
Here we are taking advantage of anonymous methods and closures to essentially keep feeding our Mock service it&#8217;s next value. This works, but&#8230; yuck! Reading this test is not very clear, and it gets in the way of the intent.<br />
Since we are supposed to refactor our test code too, lets move the ugly bits out into a private method, and re-write our test again.<br />
</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p134code16'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13416"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code" id="p134code16"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> Int32 SetupMany<span style="color: #008000;">&#40;</span>Mock<span style="color: #008000;">&lt;</span>IReturnStuff<span style="color: #008000;">&gt;</span> mock, Expression<span style="color: #008000;">&lt;</span>Func<span style="color: #008000;">&lt;</span>IReturnStuff, <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">&gt;&gt;</span> expression, <span style="color: #0600FF; font-weight: bold;">params</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    var numCalls <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
&nbsp;
    mock<span style="color: #008000;">.</span><span style="color: #0000FF;">Setup</span><span style="color: #008000;">&#40;</span>expression<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">.</span><span style="color: #0000FF;">Returns</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> args<span style="color: #008000;">&#91;</span>numCalls<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">.</span><span style="color: #0000FF;">Callback</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> numCalls<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> args<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">&#91;</span>Test<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SetupWithExtractedMethod<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    var mockReturnStuff <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Mock<span style="color: #008000;">&lt;</span>IReturnStuff<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    var usesStuff <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> UsesReturnedStuff<span style="color: #008000;">&#40;</span>mockReturnStuff<span style="color: #008000;">.</span><span style="color: #6666cc; font-weight: bold;">Object</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var calls <span style="color: #008000;">=</span> SetupMany<span style="color: #008000;">&#40;</span>mockReturnStuff,
                          svc <span style="color: #008000;">=&gt;</span> svc<span style="color: #008000;">.</span><span style="color: #0000FF;">ReturnAString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>,
                          <span style="color: #666666;">&quot;Hello&quot;</span>, <span style="color: #666666;">&quot;World!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var stuff <span style="color: #008000;">=</span> usesStuff<span style="color: #008000;">.</span><span style="color: #0000FF;">GetStuff</span><span style="color: #008000;">&#40;</span>calls<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">AreEqual</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Hello World!&quot;</span>, <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Join</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &quot;</span>, stuff<span style="color: #008000;">.</span><span style="color: #0000FF;">ToArray</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>
This is good. We haven&#8217;t lost any functionality, but the intent of the test is much clearer. There is less friction because you can read the code and understand what it is doing pretty quickly without having to &#8220;decipher&#8221; the meaning.<br />
Now, this is all fine and good, but I am likely to run into this same scenario more than once. What I would really love to have is a SetupMany() method that was built into Moq. A method I could call directly on the mocked object. Well&#8230; starting with C# 3.0 Extension Methods give us the ability to do just that. With a little work, we should be able to create a very generic extension to give us the desired behavior.<br />
</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p134code17'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13417"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p134code17"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">class</span> MoqExtensions
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> SetupMany<span style="color: #008000;">&lt;</span>TSvc, TReturn<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> Mock<span style="color: #008000;">&lt;</span>TSvc<span style="color: #008000;">&gt;</span> mock,
        Expression<span style="color: #008000;">&lt;</span>Func<span style="color: #008000;">&lt;</span>TSvc, TReturn<span style="color: #008000;">&gt;&gt;</span> expression,
        <span style="color: #0600FF; font-weight: bold;">params</span> TReturn<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>
        <span style="color: #0600FF; font-weight: bold;">where</span> TSvc <span style="color: #008000;">:</span> <span style="color: #6666cc; font-weight: bold;">class</span>
    <span style="color: #008000;">&#123;</span>
        var numCalls <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
&nbsp;
        mock<span style="color: #008000;">.</span><span style="color: #0000FF;">Setup</span><span style="color: #008000;">&#40;</span>expression<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">.</span><span style="color: #0000FF;">Returns</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> numCalls <span style="color: #008000;">&lt;</span> args<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span> <span style="color: #008000;">?</span> args<span style="color: #008000;">&#91;</span>numCalls<span style="color: #008000;">&#93;</span> <span style="color: #008000;">:</span> args<span style="color: #008000;">&#91;</span>args<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span> <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">.</span><span style="color: #0000FF;">Callback</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> numCalls<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>
Ok, so I know the method signature looks pretty scary. Just don&#8217;t stare at it long enough or you will go blind! The extra bit with the Ternary operator is a bit of error checking to prevent you from running over the bounds of the array. If you call the method more times than available arguments, it will simply keep returning the last argument in the list.<br />
Refactoring our test one last time gives us an even cleaner syntax that works with any return type. The second test merely demonstrates the &#8220;sticky&#8221; final value being returned over and over.<br />
</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p134code18'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13418"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="p134code18"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>Test<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SetupWithGenericExtensionMethod<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    var mockReturnStuff <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Mock<span style="color: #008000;">&lt;</span>IReturnStuff<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    var usesStuff <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> UsesReturnedStuff<span style="color: #008000;">&#40;</span>mockReturnStuff<span style="color: #008000;">.</span><span style="color: #6666cc; font-weight: bold;">Object</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    mockReturnStuff<span style="color: #008000;">.</span><span style="color: #0000FF;">SetupMany</span><span style="color: #008000;">&#40;</span>svc <span style="color: #008000;">=&gt;</span> svc<span style="color: #008000;">.</span><span style="color: #0000FF;">ReturnAString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, <span style="color: #666666;">&quot;Hello&quot;</span>, <span style="color: #666666;">&quot;World!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var stuff <span style="color: #008000;">=</span> usesStuff<span style="color: #008000;">.</span><span style="color: #0000FF;">GetStuff</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">AreEqual</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Hello World!&quot;</span>, <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Join</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &quot;</span>, stuff<span style="color: #008000;">.</span><span style="color: #0000FF;">ToArray</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">&#91;</span>Test<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SetupWithLotsOfParams<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    var mockReturnStuff <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Mock<span style="color: #008000;">&lt;</span>IReturnStuff<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    var usesStuff <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> UsesReturnedStuff<span style="color: #008000;">&#40;</span>mockReturnStuff<span style="color: #008000;">.</span><span style="color: #6666cc; font-weight: bold;">Object</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    mockReturnStuff<span style="color: #008000;">.</span><span style="color: #0000FF;">SetupMany</span><span style="color: #008000;">&#40;</span>svc <span style="color: #008000;">=&gt;</span> svc<span style="color: #008000;">.</span><span style="color: #0000FF;">ReturnAString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>,
                              <span style="color: #666666;">&quot;the&quot;</span>,<span style="color: #666666;">&quot;quick&quot;</span>,<span style="color: #666666;">&quot;brown&quot;</span>,<span style="color: #666666;">&quot;fox&quot;</span>,<span style="color: #666666;">&quot;jumps&quot;</span>,<span style="color: #666666;">&quot;over&quot;</span>,<span style="color: #666666;">&quot;the&quot;</span>,<span style="color: #666666;">&quot;fence&quot;</span>,<span style="color: #666666;">&quot;hello!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var stuff <span style="color: #008000;">=</span> usesStuff<span style="color: #008000;">.</span><span style="color: #0000FF;">GetStuff</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">11</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">AreEqual</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;the quick brown fox the hello! hello! hello!&quot;</span>, <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Join</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &quot;</span>, stuff<span style="color: #008000;">.</span><span style="color: #0000FF;">ToArray</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>
And there you have it. Extending the Moq API without having to actually go in and modify the source. Hopefully this will save you a headache or two in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cyragon.com/2010/06/extending-moqs-setup-to-return-multiple-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeStock 2010</title>
		<link>http://blog.cyragon.com/2010/03/codestock-2010/</link>
		<comments>http://blog.cyragon.com/2010/03/codestock-2010/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 15:45:06 +0000</pubDate>
		<dc:creator>Ben Farmer</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[CodeStock]]></category>

		<guid isPermaLink="false">http://blog.cyragon.com/?p=132</guid>
		<description><![CDATA[My good friend Josh Carroll and I have submitted a session to CodeStock about practicing Agile on small software development teams. Sign up and vote for our session! Chaos to Awesome in 60 minutes / the heart of Agile without all the fluff Track / Area: Developer / Methodology Technology: Agile, CI, testing, development processes, [...]]]></description>
			<content:encoded><![CDATA[<p>My good friend Josh Carroll and I have submitted a session to CodeStock about practicing Agile on small software development teams. Sign up and vote for our session!</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Chaos to Awesome in 60 minutes / the heart of Agile without all the fluff</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Track / Area: Developer / Methodology</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Technology: Agile, CI, testing, development processes, tools</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">General / Specific Experience Level: Beginner / Beginner</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Co-Presented with Josh Carroll.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Want to increase visibility, collaboration, and communication in your development process? Striving to ensure higher quality products with rapid feedback cycles? Don&#8217;t know where to start?</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Our goal is to show you how we use simple tools and practices to work in an agile way &#8211; without any fluff. We will cover how we manage our task board and source code; simple continuous integration; unit testing with mocks; design patterns for clean separation of concerns and testability. All in one hour. &#8216;Cause that&#8217;s how we roll.</div>
<p style="padding-left: 30px;"><strong>Chaos to Awesome in 60 minutes / the heart of Agile without all the fluff</strong></p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;"><strong>Track / Area:</strong> Developer / Methodology</p>
<p style="padding-left: 30px;"><strong>Technology:</strong> Agile, CI, testing, development processes, tools</p>
<p style="padding-left: 30px;"><strong>General / Specific Experience Level:</strong> Beginner / Beginner</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">Co-Presented with<strong> Josh Carroll</strong>.</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">Want to increase visibility, collaboration, and communication in your development process? Striving to ensure higher quality products with rapid feedback cycles? Don&#8217;t know where to start?</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">Our goal is to show you how we use simple tools and practices to work in an agile way &#8211; without any fluff. We will cover how we manage our task board and source code; simple continuous integration; unit testing with mocks; design patterns for clean separation of concerns and testability. All in one hour. &#8216;Cause that&#8217;s how we roll.</p>
<p>You can check out all the details on the <a href="http://codestock.org/Sessions/chaos-to-awesome-in-60-minutes--the-heart-of-agile-without-all-the-fluff.aspx">CodeStock session page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cyragon.com/2010/03/codestock-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Agile Degeneration: the Antidote</title>
		<link>http://blog.cyragon.com/2009/10/agile-degeneration-the-antidote/</link>
		<comments>http://blog.cyragon.com/2009/10/agile-degeneration-the-antidote/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 19:33:34 +0000</pubDate>
		<dc:creator>Ben Farmer</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[scrum]]></category>

		<guid isPermaLink="false">http://blog.cyragon.com/?p=129</guid>
		<description><![CDATA[A friend posted a piece about agile team degeneration on his blog and this is my reply. Take a couple of minutes and go read his post for proper context: http://blog.mspatch.com/post/2009/10/01/Agile-Degeneration.aspx So you read it, right? Whatever. I know you didn&#8217;t read it. I have Google Analytics and it&#8217;s telling me a different story. Well, [...]]]></description>
			<content:encoded><![CDATA[<p>A friend posted a piece about agile team degeneration on his blog and this is my reply. Take a couple of minutes and go read his post for proper context: <a href="http://blog.mspatch.com/post/2009/10/01/Agile-Degeneration.aspx">http://blog.mspatch.com/post/2009/10/01/Agile-Degeneration.aspx</a></p>
<p>So you read it, right?</p>
<p>Whatever. I know you didn&#8217;t read it. I have Google Analytics and it&#8217;s telling me a different story.</p>
<p>Well, since you didn&#8217;t read his post, I&#8217;ll distill it down to fit your impatience. An agile team can be taken over by a single, forceful, individual in one of two ways: (1) being confidence, charismatic, and passionate about their idea and reasoning until it wins or, more subliminally, (2) using their social influence to gain a majority on the team and use that to make sure their idea is chosen.</p>
<p>Can this happen to a team? Uh, yeah. Does this happen? I would say so.</p>
<p>Obviously, the issue is that agile teams contain human beings. That&#8217;s mistake number 1. What were they thinking?</p>
<p>Sure, a team consists of people and we&#8217;re flawed. However, I think there are checks and balances built into agile/scrum to help prevent this from happening. Here are four lines of defense, as I see them.</p>
<p><strong>First line of defense</strong>: The Team. Each team member has the responsibility to listen to and help each other. It&#8217;s not about one person winning or being the star. However, we become lazy, passive, unwilling to step up and contend. It&#8217;s hard work after all. You have to show up and make an effort. <em>Every day</em>. Besides, the arena of ideas is a dangerous place. What will people think of me? What if I don&#8217;t have the best idea? Complacency is easy. I&#8217;d much rather do that.</p>
<p><strong>Second line of defense</strong>: Scrum Master. The scrum master is a facilitator. It&#8217;s their responsibility to make sure all team members are engaged in the conversation. They need to create balance by knowing each team member: who to draw out and who to prevent from shutting down discussion. They also need to keep it on point and on time. It&#8217;s a very difficult job.Â  And who really wants to do that all the time? Why does it have to be hard? Maybe no one will notice&#8230;</p>
<p><strong>Third line of defense</strong>: Product Owner. The product owner needs to be assisting the scrum master in facilitation. When the scrum master is absent (physically or de facto), the product owner must step in and provide the missing facilitation.Â  But there are so many other things to worry about. And, really, let&#8217;s be honest, it&#8217;s more than a little below what I should really be doing.</p>
<p><strong>Fourth line of defense</strong>: Management. Management is really the first and last line: after all, the buck stops with them. They are responsible for bringing in exceptional people and creating teams with the critical mass to succeed. There are times they will have to make difficult decisions with team changes or helping people move on to a &#8220;better fit&#8221; (i.e. fire them). Good leadership is hard to find. Who wants to be a leader when you can be a celebrity? Planning, vision, difficult decisions, dealing with all the problems: blah! Who wants that? I&#8217;ll take a triple frapalattemocha with cinnamon and some non-dairy whipped cream with just a pinch of sprinkles to go. Yeah, now that&#8217;s something I can enjoy.</p>
<p>&#8220;Management&#8221; is not a universal cop-out for the problems that exist.</p>
<p>Each of us need to be leaders and take ownership on our team. We can try to claim ignorance or find excuses when the team fails but, ultimately, it will be our fault if we don&#8217;t do our part.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cyragon.com/2009/10/agile-degeneration-the-antidote/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
