<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>TJ Solutions</title>
    <link>http://www.tjsolutions.nl/</link>
    <description />
    <language>en-us</language>
    <copyright>Tijmen van de Kamp, Tom de Koning</copyright>
    <lastBuildDate>Tue, 01 Jun 2010 14:35:45 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>blog@tjsolutions.nl</managingEditor>
    <webMaster>blog@tjsolutions.nl</webMaster>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=3c742b84-9373-47ed-8adf-5c7fba200309</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,3c742b84-9373-47ed-8adf-5c7fba200309.aspx</pingback:target>
      <dc:creator>Tom</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,3c742b84-9373-47ed-8adf-5c7fba200309.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=3c742b84-9373-47ed-8adf-5c7fba200309</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I will be presenting at the Avans Hogeschool Tilburg this week and wanted to apply
a trick I first saw by Juval Lowy in his <a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=0&amp;tabid=23">architecture
master class</a>: starting Visual Studio from within the presentation directly. Why
would you want to do this? Because it looks cool of course!
</p>
        <p>
After a bit of Googling around I found it all is very, very easy to do. Just download
a suitable VS2010 / VS2008 icon. As I was lazy I went straight to Google images and
found these:
</p>
        <p>
          <a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/StartingVisualstudiofromwithinPowerPoint_E95D/VS2008_2.jpg">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VS2008" border="0" alt="VS2008" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/StartingVisualstudiofromwithinPowerPoint_E95D/VS2008_thumb.jpg" width="154" height="93" />
          </a>
          <a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/StartingVisualstudiofromwithinPowerPoint_E95D/VS2010_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VS2010" border="0" alt="VS2010" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/StartingVisualstudiofromwithinPowerPoint_E95D/VS2010_thumb.png" width="116" height="116" />
          </a>
        </p>
        <p>
I cleaned up the 2010 icon a bit in Paint as I will be presenting in VS2010 this week,
if you know where to get the proper icons drop a line in the comments.
</p>
        <p>
 
</p>
        <p>
Now, in PowerPoint paste any of the icons. Select the image and go to Insert, Action
=&gt; Run program.
</p>
        <p>
Insert the path to your devenv.exe, typically this will be "C:\Program Files
(x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" on a Windows 7 machine. 
</p>
        <p>
This will start VS2010 but you can (and should) add the path to the solution file.
</p>
        <p>
 
</p>
        <p>
Like it, comments? Find the comment button and let me know!
</p>
        <img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=3c742b84-9373-47ed-8adf-5c7fba200309" />
      </body>
      <title>Starting Visual studio from within PowerPoint</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,3c742b84-9373-47ed-8adf-5c7fba200309.aspx</guid>
      <link>http://www.tjsolutions.nl/2010/06/01/StartingVisualStudioFromWithinPowerPoint.aspx</link>
      <pubDate>Tue, 01 Jun 2010 14:35:45 GMT</pubDate>
      <description>&lt;p&gt;
I will be presenting at the Avans Hogeschool Tilburg this week and wanted to apply
a trick I first saw by Juval Lowy in his &lt;a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=0&amp;amp;tabid=23"&gt;architecture
master class&lt;/a&gt;: starting Visual Studio from within the presentation directly. Why
would you want to do this? Because it looks cool of course!
&lt;/p&gt;
&lt;p&gt;
After a bit of Googling around I found it all is very, very easy to do. Just download
a suitable VS2010 / VS2008 icon. As I was lazy I went straight to Google images and
found these:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/StartingVisualstudiofromwithinPowerPoint_E95D/VS2008_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VS2008" border="0" alt="VS2008" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/StartingVisualstudiofromwithinPowerPoint_E95D/VS2008_thumb.jpg" width="154" height="93" /&gt;&lt;/a&gt; &lt;a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/StartingVisualstudiofromwithinPowerPoint_E95D/VS2010_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VS2010" border="0" alt="VS2010" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/StartingVisualstudiofromwithinPowerPoint_E95D/VS2010_thumb.png" width="116" height="116" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
I cleaned up the 2010 icon a bit in Paint as I will be presenting in VS2010 this week,
if you know where to get the proper icons drop a line in the comments.
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
Now, in PowerPoint paste any of the icons. Select the image and go to Insert, Action
=&amp;gt; Run program.
&lt;/p&gt;
&lt;p&gt;
Insert the path to your devenv.exe, typically this will be &amp;quot;C:\Program Files
(x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe&amp;quot; on a Windows 7 machine. 
&lt;/p&gt;
&lt;p&gt;
This will start VS2010 but you can (and should) add the path to the solution file.
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
Like it, comments? Find the comment button and let me know!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=3c742b84-9373-47ed-8adf-5c7fba200309" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,3c742b84-9373-47ed-8adf-5c7fba200309.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=e17144a2-3592-4e5f-9389-a4ffc152bc47</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,e17144a2-3592-4e5f-9389-a4ffc152bc47.aspx</pingback:target>
      <dc:creator>Tom</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,e17144a2-3592-4e5f-9389-a4ffc152bc47.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=e17144a2-3592-4e5f-9389-a4ffc152bc47</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h1>
        </h1>
        <h1>Manipulating the DOM with Firebug
</h1>
        <p>
Currently I"m working more and more with jQuery and JavaScript to get behavior into
my pages. This was quite painful in the beginning as I was depended a bit too much
on alert"('this happens!').
</p>
        <p>
But I guess this is where you get started and then find out about the excellent <a href="https://addons.mozilla.org/en-US/firefox/addon/1843">firebug</a>.
With the console you can then fire your JavaScript and jQuery commands to the page
like so:
</p>
        <p>
 
</p>
        <p>
 <a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_thumb_2.png" width="508" height="481" /></a></p>
        <p>
        </p>
        <p>
 
</p>
        <p>
I'm querying on of Holland's main news sites for their logo. Firebug conveniently
comes up with the link to the element and when clicked it will show where it's located
on the page.
</p>
        <p>
This is all nice but let's change the boring logo of <a href="www.nu.nl">nu.nl</a> to
that of our own!
</p>
        <p>
Easy enough, just use the following to change the picture in the page:
</p>
        <code>$('#sidemenu a img').attr('src', 'http://www.tjsolutions.nl/themes/tjs/images/headerbg.jpg') </code>
        <p>
 
</p>
        <p>
 
</p>
        <p>
          <a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_8.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_thumb_3.png" width="516" height="488" />
          </a>
        </p>
        <p>
 
</p>
        <p>
But changing the elements in a page is just the beginning. You can just as easily
add new functionality by binding a click event handler to one or more elements in
the page. 
</p>
        <p>
 
</p>
        <h1>Viewing registered events
</h1>
        <p>
You can also use the console to inspect what events are registered to an element on
the page. All you need to do is use this syntax:
</p>
        <code>$(selector).data("events"); </code>
        <p>
 
</p>
        <p>
When we try that on the last input (randomly chosen) you get an overview of all the
events bound (in this case only one).
</p>
        <p>
 
</p>
        <p>
          <a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/events_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="events" border="0" alt="events" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/events_thumb.png" width="557" height="147" />
          </a>
        </p>
        <p>
 
</p>
        <p>
If you the click on the object and hover over "function" you'll end up with the code
itself:
</p>
        <p>
 
</p>
        <p>
          <a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/function_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="function" border="0" alt="function" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/function_thumb.png" width="559" height="157" />
          </a>
        </p>
        <p>
 
</p>
        <p>
This is a very neat trick that I wish I had stumbled upon earlier. Hope it helps.
</p>
        <img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=e17144a2-3592-4e5f-9389-a4ffc152bc47" />
      </body>
      <title>Getting started with Firebug and jQuery</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,e17144a2-3592-4e5f-9389-a4ffc152bc47.aspx</guid>
      <link>http://www.tjsolutions.nl/2009/12/01/GettingStartedWithFirebugAndJQuery.aspx</link>
      <pubDate>Tue, 01 Dec 2009 17:56:46 GMT</pubDate>
      <description>&lt;h1&gt;
&lt;/h1&gt;
&lt;h1&gt;Manipulating the DOM with Firebug
&lt;/h1&gt;
&lt;p&gt;
Currently I"m working more and more with jQuery and JavaScript to get behavior into
my pages. This was quite painful in the beginning as I was depended a bit too much
on alert&amp;quot;('this happens!').
&lt;/p&gt;
&lt;p&gt;
But I guess this is where you get started and then find out about the excellent &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/1843"&gt;firebug&lt;/a&gt;.
With the console you can then fire your JavaScript and jQuery commands to the page
like so:
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&amp;#160;&lt;a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_thumb_2.png" width="508" height="481" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
I'm querying on of Holland's main news sites for their logo. Firebug conveniently
comes up with the link to the element and when clicked it will show where it's located
on the page.
&lt;/p&gt;
&lt;p&gt;
This is all nice but let's change the boring logo of &lt;a href="www.nu.nl"&gt;nu.nl&lt;/a&gt; to
that of our own!
&lt;/p&gt;
&lt;p&gt;
Easy enough, just use the following to change the picture in the page:
&lt;/p&gt;
&lt;code&gt;$('#sidemenu a img').attr('src', 'http://www.tjsolutions.nl/themes/tjs/images/headerbg.jpg') &lt;/code&gt; 
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_thumb_3.png" width="516" height="488" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
But changing the elements in a page is just the beginning. You can just as easily
add new functionality by binding a click event handler to one or more elements in
the page. 
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;h1&gt;Viewing registered events
&lt;/h1&gt;
&lt;p&gt;
You can also use the console to inspect what events are registered to an element on
the page. All you need to do is use this syntax:
&lt;/p&gt;
&lt;code&gt;$(selector).data(&amp;quot;events&amp;quot;); &lt;/code&gt; 
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
When we try that on the last input (randomly chosen) you get an overview of all the
events bound (in this case only one).
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/events_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="events" border="0" alt="events" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/events_thumb.png" width="557" height="147" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
If you the click on the object and hover over "function" you'll end up with the code
itself:
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/function_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="function" border="0" alt="function" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/function_thumb.png" width="559" height="157" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
This is a very neat trick that I wish I had stumbled upon earlier. Hope it helps.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=e17144a2-3592-4e5f-9389-a4ffc152bc47" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,e17144a2-3592-4e5f-9389-a4ffc152bc47.aspx</comments>
      <category>BDD</category>
      <category>Javascript</category>
      <category>Testing</category>
    </item>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=eac64485-c3f7-4d54-a23b-64be19470e2e</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,eac64485-c3f7-4d54-a23b-64be19470e2e.aspx</pingback:target>
      <dc:creator>Tom</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,eac64485-c3f7-4d54-a23b-64be19470e2e.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=eac64485-c3f7-4d54-a23b-64be19470e2e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was pointed to the Passionate programmer by one of the blog posts at <a href="http://www.lostechies.com/blogs/louissalin/archive/2009/11/15/the-passionate-programmer-review.aspx?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+LosTechies+%28LosTechies%29">Los
Techies</a>. I'm about a third through the book and so far it has been a real joy
to read!
</p>
        <p>
It's full of good tips on how to alter your behavior to become something better as
a programmer. I'm probably going to write some posts on what I've done with the various
"act on it!", but in the meantime, go get it and start reading!
</p>
        <img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=eac64485-c3f7-4d54-a23b-64be19470e2e" />
      </body>
      <title>The Passionate programmer</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,eac64485-c3f7-4d54-a23b-64be19470e2e.aspx</guid>
      <link>http://www.tjsolutions.nl/2009/11/17/ThePassionateProgrammer.aspx</link>
      <pubDate>Tue, 17 Nov 2009 19:56:09 GMT</pubDate>
      <description>&lt;p&gt;
I was pointed to the Passionate programmer by one of the blog posts at &lt;a href="http://www.lostechies.com/blogs/louissalin/archive/2009/11/15/the-passionate-programmer-review.aspx?utm_source=feedburner&amp;amp;utm_medium=feed&amp;amp;utm_campaign=Feed%3A+LosTechies+%28LosTechies%29"&gt;Los
Techies&lt;/a&gt;. I'm about a third through the book and so far it has been a real joy
to read!
&lt;/p&gt;
&lt;p&gt;
It's full of good tips on how to alter your behavior to become something better as
a programmer. I'm probably going to write some posts on what I've done with the various
"act on it!", but in the meantime, go get it and start reading!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=eac64485-c3f7-4d54-a23b-64be19470e2e" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,eac64485-c3f7-4d54-a23b-64be19470e2e.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=b9a7be28-2e24-451c-82a2-4ac11d6922d4</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,b9a7be28-2e24-451c-82a2-4ac11d6922d4.aspx</pingback:target>
      <dc:creator>Tom</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,b9a7be28-2e24-451c-82a2-4ac11d6922d4.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=b9a7be28-2e24-451c-82a2-4ac11d6922d4</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Just a quick update on my <a href="http://www.tjsolutions.nl/2009/10/31/FunctionalProgrammingWithTheRequestResponseServiceLayer.aspx">previous</a> posting
following one of the comments made by <a href="http://benpittoors.wordpress.com/">den
Ben</a></p>
        <p>
 
</p>
        <p>
just out of curiosity... why wouldn't you 
<br />
dispatcher.Add&lt;SaveDocumentRequest&gt;(s =&gt; 
<br />
{ 
<br />
s.Document = document; 
<br />
s.UserID = userID; 
<br />
});
</p>
        <p>
 
</p>
        <p>
He's absolutely right. Using a Func forced me to (mis)use the params keyword as you
are not allowed  to use the above syntax with the old code: 
</p>
        <pre class="code">
          <span style="color: blue">public virtual </span>
          <span style="color: #2b91af">IDispatcher </span>Add&lt;TRequestType&gt;(<span style="color: blue">params </span><span style="color: #2b91af">Func</span>&lt;TRequestType, <span style="color: blue">object</span>&gt;[]
funcs) <span style="color: blue">where </span>TRequestType : <span style="color: #2b91af">Request</span>, <span style="color: blue">new</span>()
{ TRequestType request = <span style="color: blue">new </span>TRequestType(); <span style="color: blue">foreach </span>(<span style="color: blue">var </span>func <span style="color: blue">in </span>funcs)
{ func.Invoke(request); } AddRequest(request, <span style="color: blue">false</span>); <span style="color: blue">return
this</span>; }</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
          <a href="http://11011.net/software/vspaste">
          </a>
        </p>
        <p>
I actually had noticed the code not using the return value by the func but disregarded
it as I was a bit too happy with the "elegance" of my inital solution.
</p>
        <p>
But I think (and I think you'll agree) that using an Action is much cleaner here:
</p>
        <pre class="code">
          <span style="color: blue">public virtual </span>
          <span style="color: #2b91af">IDispatcher </span>Add&lt;TRequestType&gt;(<span style="color: #2b91af">Action</span>&lt;TRequestType&gt;
action) <span style="color: blue">where </span>TRequestType : <span style="color: #2b91af">Request</span>, <span style="color: blue">new</span>()
{ TRequestType request = <span style="color: blue">new </span>TRequestType(); action(request);
AddRequest(request, <span style="color: blue">false</span>); <span style="color: blue">return
this</span>; }</pre>
        <p>
 
</p>
        <p>
Thanks <a href="http://benpittoors.wordpress.com/">den Ben</a>!<a href="http://11011.net/software/vspaste"></a></p>
        <img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=b9a7be28-2e24-451c-82a2-4ac11d6922d4" />
      </body>
      <title>Functional programming with the Request/Response Service Layer part2</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,b9a7be28-2e24-451c-82a2-4ac11d6922d4.aspx</guid>
      <link>http://www.tjsolutions.nl/2009/11/16/FunctionalProgrammingWithTheRequestResponseServiceLayerPart2.aspx</link>
      <pubDate>Mon, 16 Nov 2009 18:01:36 GMT</pubDate>
      <description>&lt;p&gt;
Just a quick update on my &lt;a href="http://www.tjsolutions.nl/2009/10/31/FunctionalProgrammingWithTheRequestResponseServiceLayer.aspx"&gt;previous&lt;/a&gt; posting
following one of the comments made by &lt;a href="http://benpittoors.wordpress.com/"&gt;den
Ben&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
just out of curiosity... why wouldn't you 
&lt;br /&gt;
dispatcher.Add&amp;lt;SaveDocumentRequest&amp;gt;(s =&amp;gt; 
&lt;br /&gt;
{ 
&lt;br /&gt;
s.Document = document; 
&lt;br /&gt;
s.UserID = userID; 
&lt;br /&gt;
});
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
He's absolutely right. Using a Func forced me to (mis)use the params keyword as you
are not allowed&amp;#160; to use the above syntax with the old code: 
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public virtual &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IDispatcher &lt;/span&gt;Add&amp;lt;TRequestType&amp;gt;(&lt;span style="color: blue"&gt;params &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Func&lt;/span&gt;&amp;lt;TRequestType, &lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;[]
funcs) &lt;span style="color: blue"&gt;where &lt;/span&gt;TRequestType : &lt;span style="color: #2b91af"&gt;Request&lt;/span&gt;, &lt;span style="color: blue"&gt;new&lt;/span&gt;()
{ TRequestType request = &lt;span style="color: blue"&gt;new &lt;/span&gt;TRequestType(); &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;func &lt;span style="color: blue"&gt;in &lt;/span&gt;funcs)
{ func.Invoke(request); } AddRequest(request, &lt;span style="color: blue"&gt;false&lt;/span&gt;); &lt;span style="color: blue"&gt;return
this&lt;/span&gt;; }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
I actually had noticed the code not using the return value by the func but disregarded
it as I was a bit too happy with the "elegance" of my inital solution.
&lt;/p&gt;
&lt;p&gt;
But I think (and I think you'll agree) that using an Action is much cleaner here:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public virtual &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IDispatcher &lt;/span&gt;Add&amp;lt;TRequestType&amp;gt;(&lt;span style="color: #2b91af"&gt;Action&lt;/span&gt;&amp;lt;TRequestType&amp;gt;
action) &lt;span style="color: blue"&gt;where &lt;/span&gt;TRequestType : &lt;span style="color: #2b91af"&gt;Request&lt;/span&gt;, &lt;span style="color: blue"&gt;new&lt;/span&gt;()
{ TRequestType request = &lt;span style="color: blue"&gt;new &lt;/span&gt;TRequestType(); action(request);
AddRequest(request, &lt;span style="color: blue"&gt;false&lt;/span&gt;); &lt;span style="color: blue"&gt;return
this&lt;/span&gt;; }&lt;/pre&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
Thanks &lt;a href="http://benpittoors.wordpress.com/"&gt;den Ben&lt;/a&gt;!&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=b9a7be28-2e24-451c-82a2-4ac11d6922d4" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,b9a7be28-2e24-451c-82a2-4ac11d6922d4.aspx</comments>
      <category>.NET</category>
      <category>Functional</category>
      <category>Linq</category>
      <category>Request Response Service Layer</category>
    </item>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=eba99e4a-f608-48e7-8541-397cb4c9bcf1</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,eba99e4a-f608-48e7-8541-397cb4c9bcf1.aspx</pingback:target>
      <dc:creator>Tom</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,eba99e4a-f608-48e7-8541-397cb4c9bcf1.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=eba99e4a-f608-48e7-8541-397cb4c9bcf1</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of my colleagues asked me today if I could write a utility function that would
make his life more easy.
</p>
        <p>
The objective was to call a stored procedure n-times for every item in a list. Of
course some of the properties on every item had to be mapped to parameters in the
stored procedure.
</p>
        <p>
 
</p>
        <p>
The desired syntax would be something like:
</p>
        <p>
builder.SetStoredProcedureNameTo( " some sproc name ") 
<br />
        .Execute ( customerList , 
<br />
            (s,t) =&gt; s.AddParameterWIthValue(
parameterName, t.PROPERTY_NAME_1) , 
<br />
            (s,t) =&gt; s.AddParameterWIthValue(
parameterName, t.PROPERTY_NAME_2) , 
<br />
             (s,t) =&gt;
s.AddParameterWIthValue( parameterName, t.PROPERTY_NAME_3) 
<br />
      );
</p>
        <p>
 
</p>
        <p>
I already have a fluent wrapper class to make our ADO.Net a bit more friendly, the
interface looks like:
</p>
        <pre class="code">
          <span style="color: blue">public interface </span>
          <span style="color: #2b91af">ICustomSqlCommandBuilder </span>{ <span style="color: #2b91af">ICustomSqlCommandBuilder </span>SetStoredProcedureNameTo(<span style="color: blue">string </span>storedProcedureName); <span style="color: #2b91af">ICustomSqlCommandBuilder </span>AddParameterWithValue(<span style="color: blue">string </span>parameterNameInDatabase, <span style="color: blue">object </span>value); <span style="color: #2b91af">ICustomSqlCommandBuilder </span>AddExlicitOutputIntParameterToTheCommandFor(<span style="color: blue">string </span>parameterName); <span style="color: #2b91af">ICustomSqlCommandBuilder </span>AddExlicitOutputDateTimeParameterToTheCommandFor(<span style="color: blue">string </span>parameterName); <span style="color: #2b91af">IList</span>&lt;TReturnType&gt;
ExecuteReaderFor&lt;TReturnType&gt;() <span style="color: blue">where </span>TReturnType
: <span style="color: blue">new</span>(); }</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
Nothing special except for the ExecuteReaderFor&lt;TReturnType&gt;() but that's for
another post. 
</p>
        <p>
 
</p>
        <p>
Having the fluent interface on ICustomSqlCommandBuilder combined with the lambda magic
explained in <a href="http://www.tjsolutions.nl/2009/10/31/FunctionalProgrammingForEveryday.aspx">this</a> post
I came up with the following signature:
</p>
        <pre class="code">
          <span style="color: #2b91af">ICustomSqlCommandBuilder </span>ExecuteScalarForThisList&lt;T&gt;( <span style="color: #2b91af">IList</span>&lt;T&gt;
list, <span style="color: blue">params </span><span style="color: #2b91af">Action</span>&lt;<span style="color: #2b91af">ICustomSqlCommandBuilder</span>,
T&gt;[] actionList);</pre>
        <a href="http://11011.net/software/vspaste">
        </a>The general idea is to apply <pre class="code">(s, t) =&gt; s.AddParameterWithValue(<span style="color: #a31515">"parameterName"</span>,
t.PROPERTY_NAME)</pre><p>
to every property in the object&lt;T&gt; that needs to be mapped against a parameter
in the stored procedure. Having the params allows us to map as many properties to
parameters in the stored procedure as we like. If we then loop through all the items
in the list first and apply all actions in the actionList per item, we can then call
ExecuteScalar on the stored procedure.
</p><pre class="code"><span style="color: blue">foreach </span>(<span style="color: blue">var </span>item <span style="color: blue">in </span>list)
{ <span style="color: blue">foreach </span>(<span style="color: blue">var </span>action <span style="color: blue">in </span>actionList)
{ action.Invoke(<span style="color: blue">this</span>, item); } <span style="color: blue">var </span>result
= sqlCommand.ExecuteScalar(); sqlCommand.Parameters.Clear(); }</pre><p>
Now, another requirement was to wrap it in a transaction and also to have the verification
of the result a bit more flexible. All in all not too complicated, just a matter of
introducing another Action:
</p><pre class="code"><span style="color: blue">public </span><span style="color: #2b91af">ICustomSqlCommandBuilder </span>ExecuteScalarForThisList&lt;T&gt;( <span style="color: #2b91af">IList</span>&lt;T&gt;
list, <span style="color: #2b91af">Action</span>&lt;<span style="color: blue">object</span>&gt;
verify, <span style="color: blue">params </span><span style="color: #2b91af">Action</span>&lt;<span style="color: #2b91af">ICustomSqlCommandBuilder</span>,
T&gt;[] actionList) { sqlCommand.Connection.Open(); <span style="color: #2b91af">SqlTransaction </span>transaction
= sqlCommand.Connection.BeginTransaction(); sqlCommand.Transaction = transaction; <span style="color: blue">try </span>{ <span style="color: blue">foreach </span>(<span style="color: blue">var </span>item <span style="color: blue">in </span>list)
{ <span style="color: blue">foreach </span>(<span style="color: blue">var </span>action <span style="color: blue">in </span>actionList)
{ action.Invoke(<span style="color: blue">this</span>, item); } <span style="color: blue">var </span>result
= sqlCommand.ExecuteScalar(); verify(result); sqlCommand.Parameters.Clear(); } transaction.Commit();
} <span style="color: blue">catch </span>(<span style="color: #2b91af">SqlException</span>)
{ transaction.Rollback(); <span style="color: blue">throw</span>; } <span style="color: blue">catch </span>(<span style="color: #2b91af">Exception</span>)
{ transaction.Rollback(); <span style="color: blue">throw</span>; } <span style="color: blue">return
this</span>; }</pre><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a><p>
 
</p><p>
Including a bit of exceptionally brittle exception handling and calling the stored
procedure on a list of Customers now resolves to:
</p><pre class="code"><span style="color: #2b91af">Action</span>&lt;<span style="color: blue">object</span>&gt;
resultConstraint = result =&gt; { <span style="color: blue">if </span>(result != <span style="color: blue">null</span>)
{ <span style="color: blue">if </span>((<span style="color: blue">int</span>)result
&gt; 1000) { <span style="color: blue">throw new </span><span style="color: #2b91af">Exception</span>(<span style="color: #a31515">"result
should be less than 1000!"</span>); } } }; builder .SetStoredProcedureNameTo(<span style="color: #a31515">"sens_sp_modifyCustomerIncome"</span>)
.ExecuteScalarForThisList( customerList, resultConstraint, (s, t) =&gt; s.AddParameterWithValue(<span style="color: #a31515">"id"</span>,
t.ID), (s, t) =&gt; s.AddParameterWithValue(<span style="color: #a31515">"income"</span>,
t.Income) <span style="color: green">//etc for the rest of the properties </span>);</pre><a href="http://11011.net/software/vspaste"></a>I really, really like this syntax! <img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=eba99e4a-f608-48e7-8541-397cb4c9bcf1" /></body>
      <title>Having fun with functional programming and legacy ADO.Net!</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,eba99e4a-f608-48e7-8541-397cb4c9bcf1.aspx</guid>
      <link>http://www.tjsolutions.nl/2009/11/12/HavingFunWithFunctionalProgrammingAndLegacyADONet.aspx</link>
      <pubDate>Thu, 12 Nov 2009 19:14:15 GMT</pubDate>
      <description>&lt;p&gt;
One of my colleagues asked me today if I could write a utility function that would
make his life more easy.
&lt;/p&gt;
&lt;p&gt;
The objective was to call a stored procedure n-times for every item in a list. Of
course some of the properties on every item had to be mapped to parameters in the
stored procedure.
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
The desired syntax would be something like:
&lt;/p&gt;
&lt;p&gt;
builder.SetStoredProcedureNameTo( " some sproc name ") 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .Execute ( customerList , 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (s,t) =&amp;gt; s.AddParameterWIthValue(
parameterName, t.PROPERTY_NAME_1) , 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (s,t) =&amp;gt; s.AddParameterWIthValue(
parameterName, t.PROPERTY_NAME_2) , 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (s,t) =&amp;gt;
s.AddParameterWIthValue( parameterName, t.PROPERTY_NAME_3) 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; );
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
I already have a fluent wrapper class to make our ADO.Net a bit more friendly, the
interface looks like:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ICustomSqlCommandBuilder &lt;/span&gt;{ &lt;span style="color: #2b91af"&gt;ICustomSqlCommandBuilder &lt;/span&gt;SetStoredProcedureNameTo(&lt;span style="color: blue"&gt;string &lt;/span&gt;storedProcedureName); &lt;span style="color: #2b91af"&gt;ICustomSqlCommandBuilder &lt;/span&gt;AddParameterWithValue(&lt;span style="color: blue"&gt;string &lt;/span&gt;parameterNameInDatabase, &lt;span style="color: blue"&gt;object &lt;/span&gt;value); &lt;span style="color: #2b91af"&gt;ICustomSqlCommandBuilder &lt;/span&gt;AddExlicitOutputIntParameterToTheCommandFor(&lt;span style="color: blue"&gt;string &lt;/span&gt;parameterName); &lt;span style="color: #2b91af"&gt;ICustomSqlCommandBuilder &lt;/span&gt;AddExlicitOutputDateTimeParameterToTheCommandFor(&lt;span style="color: blue"&gt;string &lt;/span&gt;parameterName); &lt;span style="color: #2b91af"&gt;IList&lt;/span&gt;&amp;lt;TReturnType&amp;gt;
ExecuteReaderFor&amp;lt;TReturnType&amp;gt;() &lt;span style="color: blue"&gt;where &lt;/span&gt;TReturnType
: &lt;span style="color: blue"&gt;new&lt;/span&gt;(); }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
Nothing special except for the ExecuteReaderFor&amp;lt;TReturnType&amp;gt;() but that's for
another post. 
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
Having the fluent interface on ICustomSqlCommandBuilder combined with the lambda magic
explained in &lt;a href="http://www.tjsolutions.nl/2009/10/31/FunctionalProgrammingForEveryday.aspx"&gt;this&lt;/a&gt; post
I came up with the following signature:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;ICustomSqlCommandBuilder &lt;/span&gt;ExecuteScalarForThisList&amp;lt;T&amp;gt;( &lt;span style="color: #2b91af"&gt;IList&lt;/span&gt;&amp;lt;T&amp;gt;
list, &lt;span style="color: blue"&gt;params &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ICustomSqlCommandBuilder&lt;/span&gt;,
T&amp;gt;[] actionList);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;The general idea is to apply &lt;pre class="code"&gt;(s, t) =&amp;gt; s.AddParameterWithValue(&lt;span style="color: #a31515"&gt;&amp;quot;parameterName&amp;quot;&lt;/span&gt;,
t.PROPERTY_NAME)&lt;/pre&gt;
&lt;p&gt;
to every property in the object&amp;lt;T&amp;gt; that needs to be mapped against a parameter
in the stored procedure. Having the params allows us to map as many properties to
parameters in the stored procedure as we like. If we then loop through all the items
in the list first and apply all actions in the actionList per item, we can then call
ExecuteScalar on the stored procedure.
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;item &lt;span style="color: blue"&gt;in &lt;/span&gt;list)
{ &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;action &lt;span style="color: blue"&gt;in &lt;/span&gt;actionList)
{ action.Invoke(&lt;span style="color: blue"&gt;this&lt;/span&gt;, item); } &lt;span style="color: blue"&gt;var &lt;/span&gt;result
= sqlCommand.ExecuteScalar(); sqlCommand.Parameters.Clear(); }&lt;/pre&gt;
&lt;p&gt;
Now, another requirement was to wrap it in a transaction and also to have the verification
of the result a bit more flexible. All in all not too complicated, just a matter of
introducing another Action:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ICustomSqlCommandBuilder &lt;/span&gt;ExecuteScalarForThisList&amp;lt;T&amp;gt;( &lt;span style="color: #2b91af"&gt;IList&lt;/span&gt;&amp;lt;T&amp;gt;
list, &lt;span style="color: #2b91af"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;
verify, &lt;span style="color: blue"&gt;params &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ICustomSqlCommandBuilder&lt;/span&gt;,
T&amp;gt;[] actionList) { sqlCommand.Connection.Open(); &lt;span style="color: #2b91af"&gt;SqlTransaction &lt;/span&gt;transaction
= sqlCommand.Connection.BeginTransaction(); sqlCommand.Transaction = transaction; &lt;span style="color: blue"&gt;try &lt;/span&gt;{ &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;item &lt;span style="color: blue"&gt;in &lt;/span&gt;list)
{ &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;action &lt;span style="color: blue"&gt;in &lt;/span&gt;actionList)
{ action.Invoke(&lt;span style="color: blue"&gt;this&lt;/span&gt;, item); } &lt;span style="color: blue"&gt;var &lt;/span&gt;result
= sqlCommand.ExecuteScalar(); verify(result); sqlCommand.Parameters.Clear(); } transaction.Commit();
} &lt;span style="color: blue"&gt;catch &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;SqlException&lt;/span&gt;)
{ transaction.Rollback(); &lt;span style="color: blue"&gt;throw&lt;/span&gt;; } &lt;span style="color: blue"&gt;catch &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Exception&lt;/span&gt;)
{ transaction.Rollback(); &lt;span style="color: blue"&gt;throw&lt;/span&gt;; } &lt;span style="color: blue"&gt;return
this&lt;/span&gt;; }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
Including a bit of exceptionally brittle exception handling and calling the stored
procedure on a list of Customers now resolves to:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;Action&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;
resultConstraint = result =&amp;gt; { &lt;span style="color: blue"&gt;if &lt;/span&gt;(result != &lt;span style="color: blue"&gt;null&lt;/span&gt;)
{ &lt;span style="color: blue"&gt;if &lt;/span&gt;((&lt;span style="color: blue"&gt;int&lt;/span&gt;)result
&amp;gt; 1000) { &lt;span style="color: blue"&gt;throw new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Exception&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;result
should be less than 1000!&amp;quot;&lt;/span&gt;); } } }; builder .SetStoredProcedureNameTo(&lt;span style="color: #a31515"&gt;&amp;quot;sens_sp_modifyCustomerIncome&amp;quot;&lt;/span&gt;)
.ExecuteScalarForThisList( customerList, resultConstraint, (s, t) =&amp;gt; s.AddParameterWithValue(&lt;span style="color: #a31515"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;,
t.ID), (s, t) =&amp;gt; s.AddParameterWithValue(&lt;span style="color: #a31515"&gt;&amp;quot;income&amp;quot;&lt;/span&gt;,
t.Income) &lt;span style="color: green"&gt;//etc for the rest of the properties &lt;/span&gt;);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;I really, really like this syntax! &lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=eba99e4a-f608-48e7-8541-397cb4c9bcf1" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,eba99e4a-f608-48e7-8541-397cb4c9bcf1.aspx</comments>
      <category>.NET</category>
      <category>ADO.Net</category>
      <category>Functional</category>
    </item>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=da163853-8db7-45bf-a157-9c0058030aa3</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,da163853-8db7-45bf-a157-9c0058030aa3.aspx</pingback:target>
      <dc:creator>Tom</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,da163853-8db7-45bf-a157-9c0058030aa3.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=da163853-8db7-45bf-a157-9c0058030aa3</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
At my current project we are using a dispatcher class to batch requests to our WCF
layer based on the <a href="http://davybrion.com/blog/2009/11/requestresponse-service-layer-series/">Request/Response
Service Layer</a> created by Davy Brion. Once you call the Get&lt;TResponseType&gt;()
on the dispatcher the WCF layer starts working on the requests one by one and return
them in one roundtrip.
</p>
        <p>
Adding requests to the dispatcher is easy:
</p>
        <pre class="code">
          <span style="color: blue">var </span>saveDocumentRequest = <span style="color: blue">new </span><span style="color: #2b91af">SaveDocumentRequest</span>(); <span style="color: blue">var </span>getRemainingDocuments
= <span style="color: blue">new </span><span style="color: #2b91af">GetRemainingDocumentsRequest</span>();
dispatcher.Add(saveDocumentRequest, getRemainingDocuments);</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
 
</p>
        <p>
Where the signature of the Add method in Dispatcher is like;
</p>
        <pre class="code">
          <span style="color: blue">public void </span>Add(<span style="color: blue">params </span><span style="color: #2b91af">Request</span>[]
requests)</pre>
        <p>
        </p>
        <p>
Although this syntax is not bad, it feels like so much like code from last month:
not very sexy. Wouldn't be more fun if we could spice it up a bit using generics and
a bit of Func?
</p>
        <p>
I'd love to get rid of instantiating a variable just for the sake of adding it to
my dispatcher. After a bit of fiddling around with my unit tests I came up with the
following solution.
</p>
        <p>
What I want is to call the Add method in a generic way and set the parameters on my
request object inline, using a Func. This is best illustrated with a test:
</p>
        <pre class="code">[<span style="color: #2b91af">Test</span>] <span style="color: blue">public
void </span>can_assign_value_using_a_func_in_a_generic_method_call() { <span style="color: #2b91af">Guid </span>id
= <span style="color: #2b91af">Guid</span>.NewGuid(); <span style="color: blue">var </span>dispatcher
= <span style="color: blue">new </span><span style="color: #2b91af">Dispatcher</span>();
dispatcher.Add&lt;<span style="color: #2b91af">GetPersonsRequest</span>&gt;(s =&gt;
s.ID = id); <span style="color: green">//disregard ugly cast; this is only for test
purposes </span><span style="color: blue">var </span>request = (<span style="color: #2b91af">GetPersonsRequest</span>)dispatcher.Requests.First();
request.ID.ShouldEqual(id); }</pre>
        <a href="http://11011.net/software/vspaste">
        </a>Where the Request and dispatcher have
these signatures: 
<br /><pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">GetPersonsRequest</span>:<span style="color: #2b91af">Request </span>{ <span style="color: blue">public </span><span style="color: #2b91af">Guid </span>ID
{ <span style="color: blue">get</span>; <span style="color: blue">set</span>; } } <span style="color: blue">public
class </span><span style="color: #2b91af">Dispatcher </span>{ <span style="color: blue">public </span>Dispatcher()
{ Requests = <span style="color: blue">new </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">Request</span>&gt;();
} <span style="color: blue">public void </span>Add&lt;TRequestType&gt;(<span style="color: blue">params </span><span style="color: #2b91af">Func</span>&lt;TRequestType, <span style="color: blue">object</span>&gt;[]
funcs)<br /><span style="color: blue">where </span>TRequestType : <span style="color: #2b91af">Request</span>, <span style="color: blue">new</span>()
{ <span style="color: blue">var </span>request = <span style="color: blue">new </span>TRequestType(); <span style="color: blue">foreach </span>(<span style="color: blue">var </span>func <span style="color: blue">in </span>funcs)
{ func(request); } Requests.Add(request); } <span style="color: blue">public </span><span style="color: #2b91af">IList</span>&lt;<span style="color: #2b91af">Request</span>&gt;
Requests { <span style="color: blue">get</span>; <span style="color: blue">set</span>;
} }</pre><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a><p>
I can now set only property in my Request type, what if it has more properties that
need to be set? Just introduce the infamous params to the method signature like so:
</p><pre class="code"><span style="color: blue">public void </span>Add&lt;TRequestType&gt;(<span style="color: blue">params </span><span style="color: #2b91af">Func</span>&lt;TRequestType, <span style="color: blue">object</span>&gt;[]
funcs) 
<br /><span style="color: blue">where </span>TRequestType:<span style="color: #2b91af">Request</span>, <span style="color: blue">new</span>()
{ <span style="color: blue">var </span>request = <span style="color: blue">new </span>TRequestType(); <span style="color: blue">foreach </span>(<span style="color: blue">var </span>func <span style="color: blue">in </span>funcs)
{ func(request); } Requests.Add(request); }</pre><p><a href="http://11011.net/software/vspaste"></a></p><p>
And again the test:
</p><pre class="code">[<span style="color: #2b91af">Test</span>] <span style="color: blue">public
void </span>can_assign_two_values_using_a_func_in_a_generic_method_call() { <span style="color: blue">var </span>dispatcher
= <span style="color: blue">new </span><span style="color: #2b91af">Dispatcher</span>(); <span style="color: #2b91af">Guid </span>id
= <span style="color: #2b91af">Guid</span>.NewGuid(); dispatcher.Add&lt;<span style="color: #2b91af">GetPersonsRequest</span>&gt;(s
=&gt; s.ID = id, t=&gt; t.GetAllDetails = <span style="color: blue">true</span>); <span style="color: green">//disregard
ugly cast; this is only for test purposes </span><span style="color: blue">var </span>request
= (<span style="color: #2b91af">GetPersonsRequest</span>)dispatcher.Requests.First();
request.ID.ShouldEqual(id); request.GetAllDetails.ShouldBeTrue(); }</pre><a href="http://11011.net/software/vspaste"></a><p>
When we change the return type of the Add method to the dispatcher itself, we can
then use a fluent interface to get a very friendly syntax  for making calls:
</p><p>
 
</p><pre class="code"><span style="color: green">//input parameters for first request </span><span style="color: blue">var </span>document
= <span style="color: blue">new object</span>(); <span style="color: blue">var </span>userID
= <span style="color: #2b91af">Guid</span>.NewGuid(); <span style="color: green">//input
parameters for second request </span><span style="color: blue">var </span>dossierID
= <span style="color: #2b91af">Guid</span>.NewGuid(); dispatcher .Add&lt;<span style="color: #2b91af">SaveDocumentRequest</span>&gt;(s
=&gt; s.Document = document, t =&gt; t.UserID = userID) .Add&lt;<span style="color: #2b91af">GetZaakRequest</span>&gt;(s
=&gt; s.DossierId = dossierID);</pre><p>
I really like the fact that I don't have to initialize a variable and still have access
to all the properties in the request object..
</p><img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=da163853-8db7-45bf-a157-9c0058030aa3" /></body>
      <title>Functional programming with the Request/Response Service Layer</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,da163853-8db7-45bf-a157-9c0058030aa3.aspx</guid>
      <link>http://www.tjsolutions.nl/2009/10/31/FunctionalProgrammingWithTheRequestResponseServiceLayer.aspx</link>
      <pubDate>Sat, 31 Oct 2009 16:54:24 GMT</pubDate>
      <description>&lt;p&gt;
At my current project we are using a dispatcher class to batch requests to our WCF
layer based on the &lt;a href="http://davybrion.com/blog/2009/11/requestresponse-service-layer-series/"&gt;Request/Response
Service Layer&lt;/a&gt; created by Davy Brion. Once you call the Get&amp;lt;TResponseType&amp;gt;()
on the dispatcher the WCF layer starts working on the requests one by one and return
them in one roundtrip.
&lt;/p&gt;
&lt;p&gt;
Adding requests to the dispatcher is easy:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;saveDocumentRequest = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SaveDocumentRequest&lt;/span&gt;(); &lt;span style="color: blue"&gt;var &lt;/span&gt;getRemainingDocuments
= &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;GetRemainingDocumentsRequest&lt;/span&gt;();
dispatcher.Add(saveDocumentRequest, getRemainingDocuments);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
Where the signature of the Add method in Dispatcher is like;
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public void &lt;/span&gt;Add(&lt;span style="color: blue"&gt;params &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Request&lt;/span&gt;[]
requests)&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Although this syntax is not bad, it feels like so much like code from last month:
not very sexy. Wouldn't be more fun if we could spice it up a bit using generics and
a bit of Func?
&lt;/p&gt;
&lt;p&gt;
I'd love to get rid of instantiating a variable just for the sake of adding it to
my dispatcher. After a bit of fiddling around with my unit tests I came up with the
following solution.
&lt;/p&gt;
&lt;p&gt;
What I want is to call the Add method in a generic way and set the parameters on my
request object inline, using a Func. This is best illustrated with a test:
&lt;/p&gt;
&lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;Test&lt;/span&gt;] &lt;span style="color: blue"&gt;public
void &lt;/span&gt;can_assign_value_using_a_func_in_a_generic_method_call() { &lt;span style="color: #2b91af"&gt;Guid &lt;/span&gt;id
= &lt;span style="color: #2b91af"&gt;Guid&lt;/span&gt;.NewGuid(); &lt;span style="color: blue"&gt;var &lt;/span&gt;dispatcher
= &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Dispatcher&lt;/span&gt;();
dispatcher.Add&amp;lt;&lt;span style="color: #2b91af"&gt;GetPersonsRequest&lt;/span&gt;&amp;gt;(s =&amp;gt;
s.ID = id); &lt;span style="color: green"&gt;//disregard ugly cast; this is only for test
purposes &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;request = (&lt;span style="color: #2b91af"&gt;GetPersonsRequest&lt;/span&gt;)dispatcher.Requests.First();
request.ID.ShouldEqual(id); }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;Where the Request and dispatcher have
these signatures: 
&lt;br /&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;GetPersonsRequest&lt;/span&gt;:&lt;span style="color: #2b91af"&gt;Request &lt;/span&gt;{ &lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Guid &lt;/span&gt;ID
{ &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; } } &lt;span style="color: blue"&gt;public
class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Dispatcher &lt;/span&gt;{ &lt;span style="color: blue"&gt;public &lt;/span&gt;Dispatcher()
{ Requests = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Request&lt;/span&gt;&amp;gt;();
} &lt;span style="color: blue"&gt;public void &lt;/span&gt;Add&amp;lt;TRequestType&amp;gt;(&lt;span style="color: blue"&gt;params &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Func&lt;/span&gt;&amp;lt;TRequestType, &lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;[]
funcs)&lt;br /&gt;
&lt;span style="color: blue"&gt;where &lt;/span&gt;TRequestType : &lt;span style="color: #2b91af"&gt;Request&lt;/span&gt;, &lt;span style="color: blue"&gt;new&lt;/span&gt;()
{ &lt;span style="color: blue"&gt;var &lt;/span&gt;request = &lt;span style="color: blue"&gt;new &lt;/span&gt;TRequestType(); &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;func &lt;span style="color: blue"&gt;in &lt;/span&gt;funcs)
{ func(request); } Requests.Add(request); } &lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IList&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;Request&lt;/span&gt;&amp;gt;
Requests { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;;
} }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
I can now set only property in my Request type, what if it has more properties that
need to be set? Just introduce the infamous params to the method signature like so:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public void &lt;/span&gt;Add&amp;lt;TRequestType&amp;gt;(&lt;span style="color: blue"&gt;params &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Func&lt;/span&gt;&amp;lt;TRequestType, &lt;span style="color: blue"&gt;object&lt;/span&gt;&amp;gt;[]
funcs) 
&lt;br /&gt;
&lt;span style="color: blue"&gt;where &lt;/span&gt;TRequestType:&lt;span style="color: #2b91af"&gt;Request&lt;/span&gt;, &lt;span style="color: blue"&gt;new&lt;/span&gt;()
{ &lt;span style="color: blue"&gt;var &lt;/span&gt;request = &lt;span style="color: blue"&gt;new &lt;/span&gt;TRequestType(); &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;func &lt;span style="color: blue"&gt;in &lt;/span&gt;funcs)
{ func(request); } Requests.Add(request); }&lt;/pre&gt;
&lt;p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
And again the test:
&lt;/p&gt;
&lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;Test&lt;/span&gt;] &lt;span style="color: blue"&gt;public
void &lt;/span&gt;can_assign_two_values_using_a_func_in_a_generic_method_call() { &lt;span style="color: blue"&gt;var &lt;/span&gt;dispatcher
= &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Dispatcher&lt;/span&gt;(); &lt;span style="color: #2b91af"&gt;Guid &lt;/span&gt;id
= &lt;span style="color: #2b91af"&gt;Guid&lt;/span&gt;.NewGuid(); dispatcher.Add&amp;lt;&lt;span style="color: #2b91af"&gt;GetPersonsRequest&lt;/span&gt;&amp;gt;(s
=&amp;gt; s.ID = id, t=&amp;gt; t.GetAllDetails = &lt;span style="color: blue"&gt;true&lt;/span&gt;); &lt;span style="color: green"&gt;//disregard
ugly cast; this is only for test purposes &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;request
= (&lt;span style="color: #2b91af"&gt;GetPersonsRequest&lt;/span&gt;)dispatcher.Requests.First();
request.ID.ShouldEqual(id); request.GetAllDetails.ShouldBeTrue(); }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
When we change the return type of the Add method to the dispatcher itself, we can
then use a fluent interface to get a very friendly syntax&amp;#160; for making calls:
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: green"&gt;//input parameters for first request &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;document
= &lt;span style="color: blue"&gt;new object&lt;/span&gt;(); &lt;span style="color: blue"&gt;var &lt;/span&gt;userID
= &lt;span style="color: #2b91af"&gt;Guid&lt;/span&gt;.NewGuid(); &lt;span style="color: green"&gt;//input
parameters for second request &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;dossierID
= &lt;span style="color: #2b91af"&gt;Guid&lt;/span&gt;.NewGuid(); dispatcher .Add&amp;lt;&lt;span style="color: #2b91af"&gt;SaveDocumentRequest&lt;/span&gt;&amp;gt;(s
=&amp;gt; s.Document = document, t =&amp;gt; t.UserID = userID) .Add&amp;lt;&lt;span style="color: #2b91af"&gt;GetZaakRequest&lt;/span&gt;&amp;gt;(s
=&amp;gt; s.DossierId = dossierID);&lt;/pre&gt;
&lt;p&gt;
I really like the fact that I don't have to initialize a variable and still have access
to all the properties in the request object..
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=da163853-8db7-45bf-a157-9c0058030aa3" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,da163853-8db7-45bf-a157-9c0058030aa3.aspx</comments>
      <category>.NET</category>
      <category>Functional</category>
      <category>Linq</category>
    </item>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=4e1908d7-da65-4aea-bdb8-85b7e6d1c079</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,4e1908d7-da65-4aea-bdb8-85b7e6d1c079.aspx</pingback:target>
      <dc:creator>Tom</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,4e1908d7-da65-4aea-bdb8-85b7e6d1c079.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=4e1908d7-da65-4aea-bdb8-85b7e6d1c079</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm always trying to improve on my speed in development. Yesterday I noticed Udi Dahan
using the In-proc test feature of TestDriven.Net in one of his presentations at the
SDC - Netherlands, like so:
</p>
        <p>
 
</p>
        <p>
          <a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/Fasterrunningunittests_100CC/image_4.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/Fasterrunningunittests_100CC/image_thumb_1.png" width="333" height="192" />
          </a>
        </p>
        <p>
 
</p>
        <p>
 
</p>
        <p>
I had seen this option before but as it was hidden in some submenu and the regular
test method worked just fine, there seemed no benefit in using it.
</p>
        <p>
 
</p>
        <p>
          <strong>However.</strong>
        </p>
        <p>
Running your tests using In-proc makes for about 25% speed difference on average!
To me, this is very noticeable but the function is hidden in some context submenu,
hence still slow to use. After a bit of emailing with TestDriven.Net, it appears that
you can run In-proc using the DTE runner.
</p>
        <p>
To map it to a shortcut key, use the following screenshot:
</p>
        <p>
 
</p>
        <p>
          <a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/Fasterrunningunittests_100CC/image_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/Fasterrunningunittests_100CC/image_thumb.png" width="680" height="396" />
          </a>
        </p>
        <img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=4e1908d7-da65-4aea-bdb8-85b7e6d1c079" />
      </body>
      <title>Faster running unit tests</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,4e1908d7-da65-4aea-bdb8-85b7e6d1c079.aspx</guid>
      <link>http://www.tjsolutions.nl/2009/10/20/FasterRunningUnitTests.aspx</link>
      <pubDate>Tue, 20 Oct 2009 16:15:40 GMT</pubDate>
      <description>&lt;p&gt;
I'm always trying to improve on my speed in development. Yesterday I noticed Udi Dahan
using the In-proc test feature of TestDriven.Net in one of his presentations at the
SDC - Netherlands, like so:
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/Fasterrunningunittests_100CC/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/Fasterrunningunittests_100CC/image_thumb_1.png" width="333" height="192" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
I had seen this option before but as it was hidden in some submenu and the regular
test method worked just fine, there seemed no benefit in using it.
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;However.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Running your tests using In-proc makes for about 25% speed difference on average!
To me, this is very noticeable but the function is hidden in some context submenu,
hence still slow to use. After a bit of emailing with TestDriven.Net, it appears that
you can run In-proc using the DTE runner.
&lt;/p&gt;
&lt;p&gt;
To map it to a shortcut key, use the following screenshot:
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/Fasterrunningunittests_100CC/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/Fasterrunningunittests_100CC/image_thumb.png" width="680" height="396" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=4e1908d7-da65-4aea-bdb8-85b7e6d1c079" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,4e1908d7-da65-4aea-bdb8-85b7e6d1c079.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=f90776ac-a285-44a7-aa45-01782a58b52e</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,f90776ac-a285-44a7-aa45-01782a58b52e.aspx</pingback:target>
      <dc:creator>Tom</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,f90776ac-a285-44a7-aa45-01782a58b52e.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=f90776ac-a285-44a7-aa45-01782a58b52e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have converted quite a few to Resharper recently. I'm quite the addict myself and
I can't see myself using Visual Studio productively without it anymore. 
</p>
        <p>
Resharper does have a learning curve however since there are just because of the sheer
amount of enhancements it brings to working with VS.
</p>
        <p>
 
</p>
        <p>
To get you up to speed using Resharper, perform these settings in Visual studio after
installing: 
<br />
Within Visual studio: ALT - R - O =&gt; intellisense, completion behavior =&gt; 
<br />
Automatically show completion list in <b>0 </b>milliseconds 
<br />
"Check" all options except Case-sensitive prefix matching 
<br />
Finally, "Only those that are at least": set this to 1
</p>
        <p>
 
</p>
        <p>
You can watch the following screencasts: 
<br />
- <a href="http://www.jameskovacs.com/blog/CategoryView.aspx?category=Screencast" target="_blank">James
Kovacs</a> screencasts on Resharper 
<br />
- My own <a href=" http://cid-b81b6d38a9d75bc1.skydrive.live.com/self.aspx/TDD/TDD%20intro%20met%20MVP.avi" target="_blank">MVP
coding demo</a> using Resharper and Rhino mocks 
<br />
- <a href="http://www.ayende.com/102/section.aspx/redirect/1" target="_blank">Ayende</a> demoing
Rhino mocks
</p>
        <p>
(pls note that you'll need the <a href="http://www.techsmith.com/download/codecs.asp">Camtasia
TSCC codec</a> to view the last two)
</p>
        <p>
 
</p>
        <p>
You can use <a href="http://osherove.com/tools/" target="_blank">keyjedi</a> to display
the shortcuts used when someone else is looking over your shoulder. This will greatly
enhance the introduction within your team. This only works on x86 systems, I have
compiled the code into an x64 assembly that works on my win7 machine, let me know
if you need it.
</p>
        <p>
Lastly, have the developers print out the <a href="http://www.jetbrains.com/resharper/docs/ReSharper40DefaultKeymap.pdf">Resharper
keymapping</a> (in plastic cover preferably, in case of any coffee, tea and all that
:-) )
</p>
        <p>
 
</p>
        <p>
If you have any further questions, please let me know.
</p>
        <img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=f90776ac-a285-44a7-aa45-01782a58b52e" />
      </body>
      <title>How to get started with Resharper quickly</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,f90776ac-a285-44a7-aa45-01782a58b52e.aspx</guid>
      <link>http://www.tjsolutions.nl/2009/10/20/HowToGetStartedWithResharperQuickly.aspx</link>
      <pubDate>Tue, 20 Oct 2009 12:23:41 GMT</pubDate>
      <description>&lt;p&gt;
I have converted quite a few to Resharper recently. I'm quite the addict myself and
I can't see myself using Visual Studio productively without it anymore. 
&lt;/p&gt;
&lt;p&gt;
Resharper does have a learning curve however since there are just because of the sheer
amount of enhancements it brings to working with VS.
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
To get you up to speed using Resharper, perform these settings in Visual studio after
installing: 
&lt;br /&gt;
Within Visual studio: ALT - R - O =&amp;gt; intellisense, completion behavior =&amp;gt; 
&lt;br /&gt;
Automatically show completion list in &lt;b&gt;0 &lt;/b&gt;milliseconds 
&lt;br /&gt;
"Check" all options except Case-sensitive prefix matching 
&lt;br /&gt;
Finally, "Only those that are at least": set this to 1
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
You can watch the following screencasts: 
&lt;br /&gt;
- &lt;a href="http://www.jameskovacs.com/blog/CategoryView.aspx?category=Screencast" target="_blank"&gt;James
Kovacs&lt;/a&gt; screencasts on Resharper 
&lt;br /&gt;
- My own &lt;a href=" http://cid-b81b6d38a9d75bc1.skydrive.live.com/self.aspx/TDD/TDD%20intro%20met%20MVP.avi" target="_blank"&gt;MVP
coding demo&lt;/a&gt; using Resharper and Rhino mocks 
&lt;br /&gt;
- &lt;a href="http://www.ayende.com/102/section.aspx/redirect/1" target="_blank"&gt;Ayende&lt;/a&gt; demoing
Rhino mocks
&lt;/p&gt;
&lt;p&gt;
(pls note that you'll need the &lt;a href="http://www.techsmith.com/download/codecs.asp"&gt;Camtasia
TSCC codec&lt;/a&gt; to view the last two)
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
You can use &lt;a href="http://osherove.com/tools/" target="_blank"&gt;keyjedi&lt;/a&gt; to display
the shortcuts used when someone else is looking over your shoulder. This will greatly
enhance the introduction within your team. This only works on x86 systems, I have
compiled the code into an x64 assembly that works on my win7 machine, let me know
if you need it.
&lt;/p&gt;
&lt;p&gt;
Lastly, have the developers print out the &lt;a href="http://www.jetbrains.com/resharper/docs/ReSharper40DefaultKeymap.pdf"&gt;Resharper
keymapping&lt;/a&gt; (in plastic cover preferably, in case of any coffee, tea and all that
:-) )
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
If you have any further questions, please let me know.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=f90776ac-a285-44a7-aa45-01782a58b52e" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,f90776ac-a285-44a7-aa45-01782a58b52e.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=791a33b2-d3cf-4bcb-94a3-af0bccf229b2</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,791a33b2-d3cf-4bcb-94a3-af0bccf229b2.aspx</pingback:target>
      <dc:creator>Tijmen</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,791a33b2-d3cf-4bcb-94a3-af0bccf229b2.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=791a33b2-d3cf-4bcb-94a3-af0bccf229b2</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of my machines refused to install updates to the .NET Framework 3.5 sp1, both
through auto-update and when installing manually. I finally fixed it by using Aaron
Stebner's <a href="http://blogs.msdn.com/astebner/archive/2009/07/27/9850215.aspx" target="_blank">.NET
framework cleanup tool</a> and re-installing .NET. This tool radically removes all
versions of the .NET framework, including IIS artefacts, registry entries, the works.
I found this tool through a post on <a href="http://www.raymond.cc/blog/archives/2008/12/02/uninstall-microsoft-net-framework-with-aaron-stebner-cleanup-tool/" target="_blank">raymond.cc</a>.
</p>
        <p>
Note that this tool should probably not be the first thing to try; uninstalling and
re-installing the .NET framework versions would probably a safer bet to try first.
</p>
        <img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=791a33b2-d3cf-4bcb-94a3-af0bccf229b2" />
      </body>
      <title>.NET framework cleanup tool</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,791a33b2-d3cf-4bcb-94a3-af0bccf229b2.aspx</guid>
      <link>http://www.tjsolutions.nl/2009/10/15/NETFrameworkCleanupTool.aspx</link>
      <pubDate>Thu, 15 Oct 2009 07:53:47 GMT</pubDate>
      <description>&lt;p&gt;
One of my machines refused to install updates to the .NET Framework 3.5 sp1, both
through auto-update and when installing manually. I finally fixed it by using Aaron
Stebner's &lt;a href="http://blogs.msdn.com/astebner/archive/2009/07/27/9850215.aspx" target="_blank"&gt;.NET
framework cleanup tool&lt;/a&gt; and re-installing .NET. This tool radically removes all
versions of the .NET framework, including IIS artefacts, registry entries, the works.
I found this tool through a post on &lt;a href="http://www.raymond.cc/blog/archives/2008/12/02/uninstall-microsoft-net-framework-with-aaron-stebner-cleanup-tool/" target="_blank"&gt;raymond.cc&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Note that this tool should probably not be the first thing to try; uninstalling and
re-installing the .NET framework versions would probably a safer bet to try first.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=791a33b2-d3cf-4bcb-94a3-af0bccf229b2" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,791a33b2-d3cf-4bcb-94a3-af0bccf229b2.aspx</comments>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=19fd90fc-5243-427f-9875-51e90003dc22</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,19fd90fc-5243-427f-9875-51e90003dc22.aspx</pingback:target>
      <dc:creator>Tijmen</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,19fd90fc-5243-427f-9875-51e90003dc22.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=19fd90fc-5243-427f-9875-51e90003dc22</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Just a quick note: there is an update out
for the latest .NET framework version, that addresses issues with ASP.NET dynamic
data. Amongst others, the site will not display foreign key fields in a one-to-one
relationship. This <a href="http://support.microsoft.com/kb/959209">KB article</a> contains
all the download links to the various versions.<br />
Not a new issue by any means (the fix is dated January 2009), but good to know nonetheless.<br /><p></p><img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=19fd90fc-5243-427f-9875-51e90003dc22" /></body>
      <title>Update to .NET 3.5 sp1 required for dynamic data</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,19fd90fc-5243-427f-9875-51e90003dc22.aspx</guid>
      <link>http://www.tjsolutions.nl/2009/10/01/UpdateToNET35Sp1RequiredForDynamicData.aspx</link>
      <pubDate>Thu, 01 Oct 2009 17:36:27 GMT</pubDate>
      <description>Just a quick note: there is an update out for the latest .NET framework version, that addresses issues with ASP.NET dynamic data. Amongst others, the site will not display foreign key fields in a one-to-one relationship. This &lt;a href="http://support.microsoft.com/kb/959209"&gt;KB
article&lt;/a&gt; contains all the download links to the various versions.&lt;br&gt;
Not a new issue by any means (the fix is dated January 2009), but good to know nonetheless.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=19fd90fc-5243-427f-9875-51e90003dc22" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,19fd90fc-5243-427f-9875-51e90003dc22.aspx</comments>
      <category>ASP.NET</category>
    </item>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=eedd4d22-2ac2-4e85-b62b-626cea249eb2</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,eedd4d22-2ac2-4e85-b62b-626cea249eb2.aspx</pingback:target>
      <dc:creator>Tijmen</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,eedd4d22-2ac2-4e85-b62b-626cea249eb2.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=eedd4d22-2ac2-4e85-b62b-626cea249eb2</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Nothing much to, just that it took me some time to figure it out today. The code below
tests whether DivisionID is actually set in the presenter.
</p>
        <p>
 
</p>
        <pre class="code">
          <span style="color: blue;">public class </span>
          <span style="color: rgb(43, 145, 175);">Presenter </span>{ <span style="color: blue;">readonly </span><span style="color: rgb(43, 145, 175);">IRepository </span>repository; <span style="color: blue;">public </span>Presenter(<span style="color: rgb(43, 145, 175);">IRepository </span>repository)
{ <span style="color: blue;">this</span>.repository = repository; } <span style="color: blue;">public </span><span style="color: rgb(43, 145, 175);">IView </span>View
{ <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; } <span style="color: blue;">public
void </span>GetDivision() { View.DivisionID = repository.GetDivisionID(); } } <span style="color: blue;">public
interface </span><span style="color: rgb(43, 145, 175);">IView </span>{ <span style="color: blue;">int </span>DivisionID
{ <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
} [<span style="color: rgb(43, 145, 175);">TestFixture</span>] <span style="color: blue;">public
class </span><span style="color: rgb(43, 145, 175);">PresenterTests </span>{ <span style="color: rgb(43, 145, 175);">Presenter </span>sut; <span style="color: rgb(43, 145, 175);">IView </span>view; <span style="color: rgb(43, 145, 175);">IRepository </span>repository;
[<span style="color: rgb(43, 145, 175);">SetUp</span>] <span style="color: blue;">public
void </span>SetUp() { view = <span style="color: rgb(43, 145, 175);">MockRepository</span>.GenerateMock&lt;<span style="color: rgb(43, 145, 175);">IView</span>&gt;();
repository = <span style="color: rgb(43, 145, 175);">MockRepository</span>.GenerateMock&lt;<span style="color: rgb(43, 145, 175);">IRepository</span>&gt;();
sut = <span style="color: blue;">new </span><span style="color: rgb(43, 145, 175);">Presenter</span>(repository){View
= view}; } [<span style="color: rgb(43, 145, 175);">Test</span>] <span style="color: blue;">public
void </span>when_on_the_sut_GetDivisionID_is_called_it_should_set_the_divisionID_on_the_view()
{ <span style="color: green;">//AAA mocking style //Arrange </span><span style="color: blue;">const
int </span>divisionID = 1; repository.Stub(s =&gt; s.GetDivisionID()).Return(divisionID); <span style="color: green;">//note:
the expectation is set when DivisionID is set to divisionID </span>view.Expect(s =&gt;
s.DivisionID = divisionID); <span style="color: green;">//Act </span>sut.GetDivision(); <span style="color: green;">//Assert </span>view.VerifyAllExpectations();
} }</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=eedd4d22-2ac2-4e85-b62b-626cea249eb2" />
      </body>
      <title>RhinoMocks - set expectations on setter for automatic properties</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,eedd4d22-2ac2-4e85-b62b-626cea249eb2.aspx</guid>
      <link>http://www.tjsolutions.nl/2009/09/16/RhinoMocksSetExpectationsOnSetterForAutomaticProperties.aspx</link>
      <pubDate>Wed, 16 Sep 2009 21:00:20 GMT</pubDate>
      <description>&lt;p&gt;
Nothing much to, just that it took me some time to figure it out today. The code below
tests whether DivisionID is actually set in the presenter.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue;"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Presenter &lt;/span&gt;{ &lt;span style="color: blue;"&gt;readonly &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;IRepository &lt;/span&gt;repository; &lt;span style="color: blue;"&gt;public &lt;/span&gt;Presenter(&lt;span style="color: rgb(43, 145, 175);"&gt;IRepository &lt;/span&gt;repository)
{ &lt;span style="color: blue;"&gt;this&lt;/span&gt;.repository = repository; } &lt;span style="color: blue;"&gt;public &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;IView &lt;/span&gt;View
{ &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;; } &lt;span style="color: blue;"&gt;public
void &lt;/span&gt;GetDivision() { View.DivisionID = repository.GetDivisionID(); } } &lt;span style="color: blue;"&gt;public
interface &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;IView &lt;/span&gt;{ &lt;span style="color: blue;"&gt;int &lt;/span&gt;DivisionID
{ &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;; }
} [&lt;span style="color: rgb(43, 145, 175);"&gt;TestFixture&lt;/span&gt;] &lt;span style="color: blue;"&gt;public
class &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;PresenterTests &lt;/span&gt;{ &lt;span style="color: rgb(43, 145, 175);"&gt;Presenter &lt;/span&gt;sut; &lt;span style="color: rgb(43, 145, 175);"&gt;IView &lt;/span&gt;view; &lt;span style="color: rgb(43, 145, 175);"&gt;IRepository &lt;/span&gt;repository;
[&lt;span style="color: rgb(43, 145, 175);"&gt;SetUp&lt;/span&gt;] &lt;span style="color: blue;"&gt;public
void &lt;/span&gt;SetUp() { view = &lt;span style="color: rgb(43, 145, 175);"&gt;MockRepository&lt;/span&gt;.GenerateMock&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;IView&lt;/span&gt;&amp;gt;();
repository = &lt;span style="color: rgb(43, 145, 175);"&gt;MockRepository&lt;/span&gt;.GenerateMock&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;IRepository&lt;/span&gt;&amp;gt;();
sut = &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Presenter&lt;/span&gt;(repository){View
= view}; } [&lt;span style="color: rgb(43, 145, 175);"&gt;Test&lt;/span&gt;] &lt;span style="color: blue;"&gt;public
void &lt;/span&gt;when_on_the_sut_GetDivisionID_is_called_it_should_set_the_divisionID_on_the_view()
{ &lt;span style="color: green;"&gt;//AAA mocking style //Arrange &lt;/span&gt;&lt;span style="color: blue;"&gt;const
int &lt;/span&gt;divisionID = 1; repository.Stub(s =&amp;gt; s.GetDivisionID()).Return(divisionID); &lt;span style="color: green;"&gt;//note:
the expectation is set when DivisionID is set to divisionID &lt;/span&gt;view.Expect(s =&amp;gt;
s.DivisionID = divisionID); &lt;span style="color: green;"&gt;//Act &lt;/span&gt;sut.GetDivision(); &lt;span style="color: green;"&gt;//Assert &lt;/span&gt;view.VerifyAllExpectations();
} }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=eedd4d22-2ac2-4e85-b62b-626cea249eb2" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,eedd4d22-2ac2-4e85-b62b-626cea249eb2.aspx</comments>
      <category>Testing</category>
    </item>
  </channel>
</rss>