<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Third Shelf &#187; howto</title>
	<atom:link href="http://thirdshelf.com/tag/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://thirdshelf.com</link>
	<description></description>
	<lastBuildDate>Sun, 13 May 2012 17:08:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thirdshelf.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Third Shelf &#187; howto</title>
		<link>http://thirdshelf.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thirdshelf.com/osd.xml" title="Third Shelf" />
	<atom:link rel='hub' href='http://thirdshelf.com/?pushpress=hub'/>
		<item>
		<title>MassFlash v1.0</title>
		<link>http://thirdshelf.com/2011/06/26/massflash-v1-0/</link>
		<comments>http://thirdshelf.com/2011/06/26/massflash-v1-0/#comments</comments>
		<pubDate>Sun, 26 Jun 2011 18:03:03 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[productivity]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[Disk formatting]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[USB flash drive]]></category>
		<category><![CDATA[Windows PowerShell]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=639</guid>
		<description><![CDATA[Preparing many flash disks with the same data is tedious and might I add very boring. On my quest to learn Powershell, I might just as well put it to good use. With just a few lines of code I managed to cook up a script to do the mind-numbing work of preparing flash disks. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=639&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Preparing many flash disks with the same data is tedious and might I add very boring. On my quest to learn Powershell, I might just as well put it to good use. With just a few lines of code I managed to cook up a script to do the mind-numbing work of preparing flash disks. It does the work and I watch. Perfect!</p>
<p>It is a very simple script that:</p>
<ol>
<li>Formats each flash drive to FAT32;</li>
<li>Copies the contents of the specified directory recursively onto the flash drive;</li>
<li>Dismounts the volume.</li>
</ol>
<p>The script finds all removable drives between 1gb and 64gb in size. We don&#8217;t want to slip up here, now do we?</p>
<p>At the top of the script, a default directory is specified from where all files will be copied if an alternative directory was not specified on the command line.</p>
<p><pre class="brush: plain;">
Write-Host &quot;MassFlash - Version 1.0&quot;
Write-Host &quot;Author: SS du Plooy&quot;
Write-Host &quot;-----------------------&quot;

If($args.Length -eq 0)
{
    $DirectoryToCopy = &quot;c:\DefaultFromCopyLocation&quot;
}
Else
{
    $DirectoryToCopy = $args[0]
}

Write-Host &quot;Preparing flash disks with files from&quot; $DirectoryToCopy
$drives = Get-WmiObject Win32_LogicalDisk -filter &quot;DriveType=2&quot;

Foreach($drive in $drives)
{
    [int] $driveSize = $drive.Size/1073741824 #convert to gigabytes

    If($driveSize -ge 1 -and $driveSize -le 64)
    {
        $driveLetter = $drive.DeviceID
        $volume = Get-WmiObject -Class Win32_Volume -Filter &quot;DriveLetter = '$driveLetter'&quot;
        $label = &quot;TKP&quot;+$(get-date -f ssfff)

        Write-Host Formatting drive $driveLetter [$label] [$driveSize GB]
        $volume.Format(&quot;FAT32&quot;, $true, 4096, $label, $false)
        Write-Host &quot;Copying $DirectoryToCopy to $driveLetter&quot;
        Copy-Item $DirectoryToCopy $driveLetter -recurse
        Write-Host Dismounting drive $driveLetter
        $volume.Dismount($true, $false)
    }
}
Write-Host &quot;Done.&quot;
</pre></p>
<p>Now you can put your time and mind to better use instead of preparing flash drives all day long.</p>
<p><strong>Note: </strong>The script must be run with Administrator privileges.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/639/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=639&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2011/06/26/massflash-v1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
		<item>
		<title>Monitoring disk space with Powershell</title>
		<link>http://thirdshelf.com/2011/06/26/monitoring-disk-space-with-powershell/</link>
		<comments>http://thirdshelf.com/2011/06/26/monitoring-disk-space-with-powershell/#comments</comments>
		<pubDate>Sun, 26 Jun 2011 17:53:52 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[management]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[Disk Management]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows PowerShell]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=629</guid>
		<description><![CDATA[Running out of disk space all of  a sudden is just not cool. It tends to wake up men in black suits, bring on the gnashing of teeth and frothing at the mouth. I don&#8217;t like that type of drama. So, I knocked up a little Powershell script that can be scheduled to email a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=629&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Running out of disk space all of  a sudden is just not cool. It tends to wake up men in black suits, bring on the gnashing of teeth and frothing at the mouth. I don&#8217;t like that type of drama.</p>
<p>So, I knocked up a little <a href="http://en.wikipedia.org/wiki/Powershell">Powershell </a>script that can be scheduled to email a disk space report everyday. Currently the script is written to send a report on a single drive only. There are many other variations of this type of script that reports on all the drives on a server.</p>
<p><pre class="brush: plain;">
$disk = Get-WmiObject -ComputerName $env:COMPUTERNAME Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3} | Where-Object {$_.DeviceID -eq &quot;:&quot;}

[float]$totalSize = [Math]::Round($disk.Size / 1073740824, 2)
[float]$freeSpace = [Math]::Round($disk.FreeSpace / 1073740824, 2)
$deviceID = $disk.DeviceID
$percentFree = [Math]::Round(($freeSpace / $totalSize) * 100, 2);

$smtpServer = &quot;&quot;
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$emailFrom = &quot;$env:COMPUTERNAME&quot;
$emailTo = &quot;&quot;
$subject = &quot;$env:COMPUTERNAME - Disk space report&quot;
$body = &quot;$deviceID | Total: $totalSize GB | Available: $freeSpace GB | $percentFree % disk space available&quot;
$smtp.Send($EmailFrom,$emailTo,$subject,$body)
</pre></p>
<p>When it comes to management, you might just as well only print the precentage of free disk space and perhaps add that to the subject of the email. That will give all the relevant information in one look. The script can be extended to report on multiple servers and multiple drives.</p>
<p>Have fun!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/629/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/629/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/629/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/629/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/629/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/629/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/629/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=629&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2011/06/26/monitoring-disk-space-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting Fit, Uncle Bob style!</title>
		<link>http://thirdshelf.com/2011/04/23/getting-fit-uncle-bob-style/</link>
		<comments>http://thirdshelf.com/2011/04/23/getting-fit-uncle-bob-style/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 09:22:39 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Fit]]></category>
		<category><![CDATA[FitNesse]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software testing]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[Test case]]></category>
		<category><![CDATA[Wiki]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=547</guid>
		<description><![CDATA[Fit: Framework for Integrated Test Great software requires collaboration and communication. Fit is a tool for enhancing collaboration in software development. It&#8217;s an invaluable way to collaborate on complicated problems&#8211;and get them right&#8211; early in development. Fit allows customers, testers, and programmers to learn what their software should do and what it does do. It automatically compares customers&#8217; expectations to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=547&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<blockquote><p><strong>Fit: Framework for Integrated Test</strong></p>
<p>Great software requires collaboration and communication. Fit is a tool for enhancing collaboration in software development. It&#8217;s an invaluable way to collaborate on complicated problems&#8211;and get them right&#8211; early in development.</p>
<p>Fit allows customers, testers, and programmers to learn what their software <em>should</em> do and what it <em>does</em> do. It automatically compares customers&#8217; expectations to actual results. [Cunn 07]</p></blockquote>
<p>Read an <a href="http://www.testinggeek.com/index.php/testing-tools/test-execution/95-fitnesse-introduction">introduction to FitNesse</a>.</p>
<p><strong>Installing FitNesse</strong></p>
<p>To start using FitNesse with .net, you&#8217;ll need to download <a href="http://www.fitnesse.org">FitNesse</a> and <a href="http://fitsharp.github.com/">fitSharp</a>. Once downloaded, place the fitnesse.jar file in a directory, for example c:\FitNesse. Extract the files from the fitSharp archive into a subdirectory in the same folder as fitnesse.jar called fitSharp.</p>
<p>Start FitNesse using <em>java -jar fitnesse.jar -p 8080</em> where -p is the port number. FitNesse installs in a directory called FitNesseRoot. Browse to http://localhost:8080 and you should see the FitNesse front-end.</p>
<p><strong>Creating a test fixture</strong></p>
<p>To use FitNesse you&#8217;ll need to give a test fixture that FitNesse can execute. A test fixture is derived from one of the classes provided by the Fit framework. For this example, derive a test fixture from <em>ColumnFixture</em>. This will allow us to run the test case using a decision table with input and output values. Add a reference to both fit.dll and fitSharp.dll in your project.</p>
<p><pre class="brush: csharp;">
namespace Humanresources.Domain
{
  public class EmployeeTests : fit.ColumnFixture
  {
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string FullName { get { return string.Concat(FirstName, &quot; &quot;, LastName); }
  }
}
</pre></p>
<p><span class="Apple-style-span" style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;"><br />
<strong>Setting up the test case</strong></span></p>
<p>To setup the test case, you will need to create a wiki-page. On the front page of FitNesse, click on <strong>Edit</strong> and enter a wiki-word with the name of the test case. A wiki-word is a word written in Pascal-case surrounded by square brackets, i.e. [EmployeeTests]. Click <strong>Save</strong> and then click on the <strong>question mark</strong> to go to the page and click on <strong>Edit</strong>.</p>
<p>To setup the test, you &#8216;ll need to define a couple of variables, they are</p>
<ol>
<li>location of the assembly under test;</li>
<li>how to invoke the test runner;</li>
<li>location of the test runner.</li>
</ol>
<div>On edit page, enter the following:</div>
<p><pre class="brush: plain; light: true;">
!path C:\Projects\Experiments\HumanResources\HumanResources.Domain\bin\Debug\HumanResources.Domain.dll
!define COMMAND_PATTERN {%m -r fitnesse.fitserver.FitServer,c:\FitNesse\FitSharp\fit.dll %p}
!define TEST_RUNNER {c:\FitNesse\FitSharp\Runner.exe}
</pre></p>
<div>Click on <strong>Save.</strong> Next, you&#8217;ll need create the test inputs and expected output values:</div>
<div><pre class="brush: plain; light: true;">
|humanresources.domain.employeetests|
|firstname|lastname|fullname?  |
|John     |Lidin   |John Lidin |
|Joshua   |Cohen   |J Cohen    |
|Allan    |Butler  |A Butler   |
</pre></p>
<p>The first line specifies the class that is under test, the second line specifies the input values that are assigned to the properties with the same name and the following lines give the input and expected output values. The last column with the question mark is the evaluation column. This is a simple decision table. The last column name may also be the name of a method.</p>
<p>In the table, we are assigning the value John to FirstName property and Lidin to the LastName property. The expectation is that FullName is a concatenation of FirstName, a space and then followed by the LastName.</p>
<p>Before the test is run, you&#8217;ll need to tell FitNesse that this page is a page that contains tests and is not just a simple wiki-page. To change the page type to test page, click on <strong>Properties, </strong>select <strong>Test</strong> and then click <strong>Save.</strong></p>
<p>An important thing to note here is that all the property names and class names are in lower case. This is intentional as Pascal-cased words are interpreted as wiki-words. For your own sanity keep them in lowercase.</p>
<p>Your page should now look like this:</p>
<p><a href="http://thirdshelf.files.wordpress.com/2011/04/fitnessetestsetup.png"><img class="size-medium wp-image-610 alignnone" title="FitNesseTestSetup" src="http://thirdshelf.files.wordpress.com/2011/04/fitnessetestsetup.png?w=300&h=167" alt="" width="300" height="167" /></a></p>
<p><strong>Run the test case</strong></p>
<p>Click on <strong>Test</strong> and you should see the following output:</p>
<p><a href="http://thirdshelf.files.wordpress.com/2011/04/fitnessetestrun.png"><img class="alignnone size-medium wp-image-612" title="FitNesseTestRun" src="http://thirdshelf.files.wordpress.com/2011/04/fitnessetestrun.png?w=300&h=173" alt="" width="300" height="173" /></a></p>
</div>
<p>The tests can also be executed from the command line, are you thinking what I&#8217;m thinking?</p>
<p><strong>Troubleshooting</strong></p>
<ul>
<li>Fit.dll file load exception</li>
</ul>
<p><pre class="brush: plain; light: true;">
System.IO.FileLoadException: Could not load file or assembly 'file:///c:\FitNesse\FitSharp\fit.dll'
or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: 'file:///c:\FitNesse\FitSharp\fit.dll' ---&gt; System.NotSupportedException: An attempt was
made to load an assembly from a network location which would have caused the assembly to be sandboxed
in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy
by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please
enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
</pre></p>
<p>To solve this issue, simply add a configuration file to the runner that you&#8217;re using. If you are using <em>runner.exe</em> then create a file called runner.exe.config and add the following text into runner.exe.config:</p>
<p><pre class="brush: xml;">
&lt;configuration&gt;
   &lt;runtime&gt;
      &lt;loadFromRemoteSources enabled=&quot;true&quot;/&gt;
   &lt;/runtime&gt;
&lt;/configuration&gt;
</pre></p>
<ul>
<li>If you encounter any other issues you can do the <a href="http://www.asoftwarecraft.com/2010/01/troubleshooting-with-fitsharp-and.html">test run using a debugger</a>.</li>
</ul>
<p><strong>References</strong></p>
<pre><span class="Apple-style-span" style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">[Cunn 07] Cunningham, Ward. Making Fixtures. <em>Framework for Integrated Test</em>. October 12, 2007. <a href="http://fit.c2.com/?MakingFixtures">http://fit.c2.com/search.cgi?search=WelcomeVisitors</a></span></pre>
<p><a href="http://fit.c2.com/?MakingFixtures"><br />
</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/547/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/547/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/547/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/547/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/547/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/547/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/547/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/547/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/547/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/547/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/547/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/547/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/547/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/547/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=547&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2011/04/23/getting-fit-uncle-bob-style/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2011/04/fitnessetestsetup.png?w=300" medium="image">
			<media:title type="html">FitNesseTestSetup</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2011/04/fitnessetestrun.png?w=300" medium="image">
			<media:title type="html">FitNesseTestRun</media:title>
		</media:content>
	</item>
		<item>
		<title>Unit testing with Jenkins</title>
		<link>http://thirdshelf.com/2011/03/21/unit-testing-with-jenkins/</link>
		<comments>http://thirdshelf.com/2011/03/21/unit-testing-with-jenkins/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 15:51:23 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Jenkins]]></category>
		<category><![CDATA[MbUnit]]></category>
		<category><![CDATA[Microsoft Visual Studio]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[MsTest]]></category>
		<category><![CDATA[NUnit]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[Unit testing]]></category>
		<category><![CDATA[XUnit]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=511</guid>
		<description><![CDATA[Continuing to setup a build for the first time with Jenkins there is, uh, another challenge. For some reason, I thought it clever to make use of MsTest. This works wonderfully on the development machine. But, of course, when it comes to the build server, you can expect all sorts of weirdness. For example, error CS0246: The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=511&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Continuing to setup a build for the first time with Jenkins there is, uh, another challenge. For some reason, I thought it clever to make use of MsTest. This works wonderfully on the development machine. But, of course, when it comes to the build server, you can <a href="http://thirdshelf.com/2011/03/19/building-a-net-application-with-jenkins/">expect all sorts of weirdness</a>. For example, error CS0246: The type or namespace name &#8216;TestMethodAttribute&#8217; could not be found&#8230;</p>
<p>We&#8217;re sorry, but our testing tools don&#8217;t come standard with the .NET Framework, or in any other way, except TFS and Visual Studio, unless you are willing to follow this <a href="http://www.shunra.com/shunrablog/index.php/2009/04/23/running-mstest-without-visual-studio/">brave soul</a>. I share <a href="http://devlicio.us/blogs/derik_whittaker/archive/2008/09/25/clean-build-server-with-mstest-fail.aspx">Derik Whittaker&#8217;s sentiment on the MsTest and build server</a> issue.</p>
<blockquote><p>This is another issue to me because MSTest is the ONLY test framework (for .Net) that I know of that does not run with a single DLL placed into the bin (or any other output directory).  I just have to ask the genius&#8217; over in Redmond what the hell were they smoking when they decided to build MSTest.  It is pretty clear they had no prior knowledge of how to use the other tools such as NUnit, MBUnit or xUnit (I know, xUnit was not out yet).  I know this because of all the various testing frameworks MSTest is the one that does everything different.  You could argue they were on the cutting edge and were innovating, but I call BS on that.</p></blockquote>
<p>This can be solved. <em>So long MsTest&#8230; Hello NUnit!</em></p>
<p><strong>Converting from MsTest to NUnit</strong></p>
<p>Converting from MsTest is a simple case of find and replace of <a href="http://nunit.org/index.php?p=attributes&amp;r=2.5.9">attributes</a>. NUnit  has the nifty Assert.Catch&lt;T&gt; which beats <a href="http://www.mbunit.com/">MbUnit</a>, MsTest and <a href="http://xunit.codeplex.com">xUnit</a>. xUnit comes with Assert.Throws&lt;T&gt; but cannot assert the exception message whereas NUnit can. No more [ExpectedException] attributes.</p>
<p>Integrating NUnit with the build file (which is MsBuild) is pretty easy:</p>
<p>&lt;Exec Command=&#8221;$(NUnitFolder)\nunit-console-x86.exe [TestAssembly] /framework=net-4.0 /xml=$(TestResultsFolder)\TestResults.xml&#8221; /&gt;</p>
<p>A single Exec statement and out comes an Xml file. To keep the build server clean, I decided to add all the necessary files for unit testing into source control along with the project. The bare minimum files for running NUnit from the command line comes down to the following files:</p>
<ul>
<li>nunit.core.dll</li>
<li>nunit.core.interfaces.dll</li>
<li>nunit.framework.dll</li>
<li>nunit.util.dll</li>
<li>nunit.console-runner.dll</li>
<li>nunit-console-x86.exe</li>
<li>nunit-agent-x86.exe</li>
<li>nunit-agent-x86.exe.config</li>
</ul>
<p>To make it work on .Net Framework 4.0, you have to include the <em>/framework=net-4.0</em> switch on the command line.</p>
<p><strong>Setting up Jenkins with NUnit</strong></p>
<p>Install the NUnit plugin for Jenkins, point it to your test results file and after a build you&#8217;ll get the summarised test results.  It&#8217;s a neat table with all the classes and their respective timings and so on.</p>
<p><a href="http://thirdshelf.files.wordpress.com/2011/03/jenkins-test-results.png"><img class="alignnone size-full wp-image-541" title="Jenkins-Test-Results" src="http://thirdshelf.files.wordpress.com/2011/03/jenkins-test-results.png?w=720" alt=""   /></a></p>
<p>Finally, I have a working build with unit testing. If only it had an installer&#8230;</p>
<p><strong><br />
</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/511/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=511&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2011/03/21/unit-testing-with-jenkins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2011/03/jenkins-test-results.png" medium="image">
			<media:title type="html">Jenkins-Test-Results</media:title>
		</media:content>
	</item>
		<item>
		<title>Jenkins and Git</title>
		<link>http://thirdshelf.com/2011/03/16/jenkins-and-git/</link>
		<comments>http://thirdshelf.com/2011/03/16/jenkins-and-git/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 18:09:22 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[reviews]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[hudson]]></category>
		<category><![CDATA[Revision control]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=477</guid>
		<description><![CDATA[The road split for&#160;Hudson and Jenkins. It happens. Getting the source code&#8230; I don&#8217;t have&#160;Cygwin or&#160;MSysGit installed on the server for&#160;my own perverse reasons.&#160;In order for Jenkins to get hold of the source code from a git repository is usually straight forward. &#160;Well, now comes the time to get the source code from git. I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=477&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://stackoverflow.com/questions/4973981/how-to-choose-between-hudson-and-jenkins/4974032#4974032" target="_blank">road split</a> for&nbsp;<a href="http://www.infoq.com/news/2011/01/hudson-jenkins" target="_blank">Hudson and Jenkins</a>. It happens.</p>
<p><strong>Getting the source code&#8230;</strong></p>
<p>I don&#8217;t have&nbsp;<a href="http://www.cygwin.com" target="_blank">Cygwin </a>or&nbsp;<a href="http://code.google.com/p/msysgit/" target="_blank">MSysGit</a> installed on the server for&nbsp;<a href="http://thirdshelf.com/2011/03/10/git-and-hudson-brothers/" target="_blank">my own perverse reasons</a>.&nbsp;In order for Jenkins to get hold of the source code from a git repository is usually straight forward. &nbsp;Well, now comes the time to get the source code from git. I can clone repository into a local directory using &nbsp;<a href="http://www.eqqon.com/index.php/GitSharp" target="_blank">GitSharp</a>. GitSharp is the .net version of git and very cool, but not quite finished yet. &nbsp;The alternative is a Java application called&nbsp;<a href="http://eclipse.org/jgit/" target="_blank">JGit</a>. GitSharp, by the way, is a derived work of JGit.</p>
<p><strong>Setting up Jenkins&#8230;</strong></p>
<p><a href="http://eclipse.org/jgit/download/" target="_blank">Download the shell script</a> of JGit which, by the way, &nbsp;is a self-contained command line executable.&nbsp;With that, I am able to test the cloning of a repository into a new folder with the following <a href="http://sandeep.wordpress.com/2010/09/13/using-git-on-windows-without-any-of-the-cygwinmsysgit-nonsense/" target="_blank">command line</a>:</p>
<pre>C:\JGit&gt;java -cp org.eclipse.jgit.pgm-0.10.1.sh org.eclipse.jgit.pgm.Main clone&nbsp;
http://dev/git/myproject.git c:\projects\myproject

<span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">After executing the above command line, &nbsp;I have the source files in the c:\projects\myproject directory. To use this in Jenkins, I need to make use of the batch command execution since the <a href="http://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin">git plugin</a> makes use of git.exe and all the other things I didn't setup.</span></pre>
<p><a href="http://thirdshelf.files.wordpress.com/2011/03/jenkins-git-batch-command.png"><img class="size-full wp-image-482 alignnone" title="Jenkins-Git-Batch-Command" src="http://thirdshelf.files.wordpress.com/2011/03/jenkins-git-batch-command.png?w=720" alt=""   /></a></p>
<pre><span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:small;"><span style="font-size:13px;line-height:19px;white-space:normal;">
After running a build, I have the following console output in Jenkins and the source code in the build factory directory:</span></span>
<span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:small;"><span style="font-size:13px;line-height:19px;white-space:normal;">&nbsp;</span></span>
<span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:small;"><span style="font-size:13px;line-height:19px;white-space:normal;">
<pre>Started by user anonymous
[MyProject] $ cmd /c call C:\Windows\TEMP\hudson12048252217381411.bat

d:\builds\factory\MyProject&gt;"C:\Program Files\Java\jre6\bin\java.exe" -cp&nbsp;
c:\jgit\org.eclipse.jgit.pgm-0.10.1.sh&nbsp;org.eclipse.jgit.pgm.Main clone&nbsp;
  http://dev/git/myproject.git d:\Builds\Factory\MyProject

Initialized empty Git repository in d:\Builds\Factory\MyProject\.git
remote: Counting objects: 342, done
From {0}&nbsp;
* [new branch] &nbsp; &nbsp; &nbsp;master &nbsp; &nbsp; -&gt; origin/master

d:\builds\factory\MyProject&gt;exit 0&nbsp;Finished: SUCCESS</pre>
<p>&nbsp;</p>
<p></span></span><br />
by <a title="Sydney" rel="author" href="http://thirdshelf.com/about/">Sydney du Plooy</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/477/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=477&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2011/03/16/jenkins-and-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2011/03/jenkins-git-batch-command.png" medium="image">
			<media:title type="html">Jenkins-Git-Batch-Command</media:title>
		</media:content>
	</item>
		<item>
		<title>Git and Hudson Brothers</title>
		<link>http://thirdshelf.com/2011/03/10/git-and-hudson-brothers/</link>
		<comments>http://thirdshelf.com/2011/03/10/git-and-hudson-brothers/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 19:04:55 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[reviews]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[hudson]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[msysgit]]></category>
		<category><![CDATA[Revision control]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=462</guid>
		<description><![CDATA[For a while now, I&#8217;ve been thinking about creating a source control and build server for a couple of projects that I&#8217;m working on. I&#8217;ll admit, I moonlight. Anyway, a great analysis ensued. Starting with the OS; what will it be, what does it need to be? Considering that I&#8217;m building .NET projects and they&#8217;re Windows [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=462&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://thirdshelf.files.wordpress.com/2011/03/hudson-watermark.png"><img class="size-full wp-image-470 alignright" title="Hudson-Watermark" src="http://thirdshelf.files.wordpress.com/2011/03/hudson-watermark.png?w=720" alt=""   /></a>For a while now, I&#8217;ve been thinking about creating a <a href="http://en.wikipedia.org/wiki/Source_control">source control</a> and <a href="http://en.wikipedia.org/wiki/Continuous_integration">build server</a> for a couple of projects that I&#8217;m working on. I&#8217;ll admit, I moonlight. Anyway, a great analysis ensued. Starting with the OS; what will it be, what does it need to be? Considering that I&#8217;m building .NET projects and they&#8217;re Windows based; well that kind of settles that. Next up, which source control system? Oh boy, this took a while&#8230;</p>
<h3>Source Control</h3>
<p>Since everyone, OK, almost everyone, raves about <a href="http://en.wikipedia.org/wiki/Git_(software)">Git</a>, I suppose I&#8217;ll have to succumb. But, this is where the fun starts. I want Git, I want Windows. <a href="http://www.kernel.org/pub/software/scm/git/docs/git-push.html">Pushing</a>, <a href="http://www.kernel.org/pub/software/scm/git/docs/git-clone.html">cloning</a> and so on is what really I want. What a painful story&#8230; This requires the installation of <a href="http://code.google.com/p/msysgit/">MSysGit</a> or <a href="http://www.cygwin.com">Cygwin </a>and some <a href="http://en.wikipedia.org/wiki/Secure_Shell">SSH server</a>, blah blah, whatever. It was simply too much.</p>
<p>I decided to run <a href="http://www.visualsvn.com/">VisualSVN </a>on the server and then use <a href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn</a> to bridge that little dilemma. Well, that kinda sucked. After formatting and configuring and formatting and configuring, I finally found<a href="http://www.jeremyskinner.co.uk/2010/06/25/hosting-a-git-server-under-iis7-on-windows/" target="_blank"> this post by Jeremy Skinner</a>. It explains how to setup Git on Windows using IIS 7.0, without any other fancy installations and configurations. He calls it <a href="https://github.com/JeremySkinner/git-dot-aspx/downloads" target="_blank">git-dot-aspx (GitAspx)</a>. To my surprise, this worked elegantly, the first time. Push, pull and clone without any issues. Great.</p>
<h3>Continuous Integration</h3>
<p>What a mental battle this turned out to be! What should I use, what do I need to use? There is from <a href="http://sourceforge.net/projects/ccnet/" target="_blank">CruiseControl.NET</a> to <a href="http://hudson-ci.org/" target="_blank">Hudson</a>. A colleague mentioned Hudson and, being quite popular, I decided to investigate. This turned out to be a fantastic piece of software. It is a Java application, but I decided that it is well worth it. One click and it installs as a Windows service. One command line and it uninstalls cleanly. Unbelievable! Such a polished product. Also, it has many plugins from MsBuild to Git to Twitter. Talk about pressure, having your build status published to Twitter!</p>
<p>For a good Windows alternative, these two products turned out to be highly effective and user friendly.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/462/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=462&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2011/03/10/git-and-hudson-brothers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2011/03/hudson-watermark.png" medium="image">
			<media:title type="html">Hudson-Watermark</media:title>
		</media:content>
	</item>
		<item>
		<title>AutoMocking with RhinoMocks and StructureMap</title>
		<link>http://thirdshelf.com/2010/12/13/automocking-with-rhinomocks-and-structuremap/</link>
		<comments>http://thirdshelf.com/2010/12/13/automocking-with-rhinomocks-and-structuremap/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 15:04:25 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=451</guid>
		<description><![CDATA[Auto mocking is the process whereby mock objects are created and injected into an object. By using this technique we relieve ourselves from the burden of creating and injecting mocks manually. Consider the following test class that requires two dependencies; namely, IPropertyDependency and IConstructorDependency: The one dependency is provided in the constructor and the other is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=451&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/02/09/automocker-in-structuremap-2-5.aspx">Auto mocking</a> is the process whereby mock objects are created and injected into an object. By using this technique we relieve ourselves from the burden of creating and injecting mocks manually. Consider the following test class that requires two dependencies; namely, IPropertyDependency and IConstructorDependency:</p>
<p><pre class="brush: csharp;">
public class ClassToBeAutoMocked
{
	private IConstructorDependency _ConstructorInjectedDependency;

	public ClassToBeAutoMocked(IConstructorDependency dep)
	{
		_ConstructorInjectedDependency = dep;
	}

	private IPropertyDependency PropertyDependency
	{
		get;
		set;
	}

	public string PrintConstructorDependency()
	{
		return _ConstructorInjectedDependency.Print();
	}

	public string PrintPropertyDependency()
	{
		return PropertyDependency.Print();
	}
}
</pre></p>
<p>The one dependency is provided in the constructor and the other is injected via the private property. Out-of-the-box, StructureMap AutoMocker provides the ability to mock and inject the constructor dependency. Private properties, however, are not supported. This can be solved by means of an <a href="http://blogs.planbsoftware.co.nz/?p=291">extension method applied to the RhinoAutoMocker type</a>, for example:</p>
<p><pre class="brush: csharp;">
public static class RhinoAutoMockerExtensions
{
	public static void RegisterPropertyDependency&lt;TARGETCLASS&gt;(this RhinoAutoMocker autoMocker, string propertyName) where TARGETCLASS : class
	{
		var propertyInfo = typeof(TARGETCLASS).GetProperty(propertyName,
			BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

		if (propertyInfo == null)
		{
			throw new ArgumentException(string.Format(&quot;Property {0} was not found on the type {1}&quot;,
				propertyName, typeof(TARGETCLASS).Name));
		}

		var propertyType = propertyInfo.PropertyType;
		var mockDependency = MockRepository.GenerateMock(propertyType, null);
		autoMocker.Inject(propertyType, mockDependency);
		propertyInfo.SetValue(autoMocker.ClassUnderTest, mockDependency, null);
	}
}
</pre></p>
<p>We now have the necessary pieces to get an auto mocked instance of ClassToBeAutoMocked.</p>
<p>Next, create an instance of the RhinoAutoMocker class with the concrete type, which will then create the constructor dependency mock and inject it. Because the private property dependency injection is not supported we have to tell the AutoMocker that we want the private property mocked and injected as well. We accomplish this by calling the extension method RegisterPropertyDependency with the name of the property that must be mocked. To obtain a reference to the generated mock we can call the Get method with the dependency type which will return the mock instance. We are then free to stub or set expectations on that dependency as required by our unit tests.</p>
<p>For example:</p>
<p><pre class="brush: csharp;">
static void Main(string[] args)
{
	var mocks = new RhinoAutoMocker(MockMode.AAA);
	mocks.RegisterPropertyDependency(&quot;PropertyDependency&quot;);

	mocks.Get&lt;IConstructorDependency&gt;().Stub(x =&gt; x.Print()).Return(&quot;On fire with the constructor dependency!&quot;);
	mocks.Get&lt;IPropertyDependency&gt;().Stub(x =&gt; x.Print()).Return(&quot;On fire with the property dependency!&quot;);

	Console.WriteLine(&quot;Constructor dependency output: {0}&quot;, mocks.ClassUnderTest.PrintConstructorDependency());
	Console.WriteLine(&quot;Property dependency output: {0}&quot;, mocks.ClassUnderTest.PrintPropertyDependency());

	Console.ReadLine();
}
</pre></p>
<div id="_mcePaste" class="mcePaste" style="position:absolute;left:-10000px;top:749px;width:1px;height:1px;">
<pre style="font:normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">IConstructorDependency</pre>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/451/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/451/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/451/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/451/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/451/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/451/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/451/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/451/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=451&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2010/12/13/automocking-with-rhinomocks-and-structuremap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
		<item>
		<title>Resizing a virtual hard disk</title>
		<link>http://thirdshelf.com/2010/06/29/resizing-a-vhd/</link>
		<comments>http://thirdshelf.com/2010/06/29/resizing-a-vhd/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 16:00:07 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[windows]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=420</guid>
		<description><![CDATA[Recently, I had to resize a VHD (virtual hard disk) that I installed Windows Server 2008 on. I soon found out that the size of 10GB is not such a hot idea when installing Team Foundation Server 2010 and SQL Server 2008 on the same instance. Hence, I decided to resize the disk instead of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=420&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently, I had to resize a <a href="http://en.wikipedia.org/wiki/VHD_%28file_format%29">VHD (virtual hard disk)</a> that I installed Windows Server 2008 on. I soon found out that the size of 10GB is not such a hot idea when installing Team Foundation Server 2010 and SQL Server 2008 on the same instance. Hence, I decided to resize the disk instead of re-installing all of the software.</p>
<p>Below is the recipe to resize the virtual hard disk:</p>
<p><strong>Part 1:</strong></p>
<p>The first part is to resize the container of the partition, which is done by means of a sector copy. After the resize completed,  the container will have increased but the partition will not be fully extended yet.<a href="http://thirdshelf.files.wordpress.com/2010/06/vhdresizer.png"><img class="size-medium wp-image-440  alignright" title="VhdResizer" src="http://thirdshelf.files.wordpress.com/2010/06/vhdresizer.png?w=300&h=276" alt="" width="300" height="276" /></a></p>
<ol>
<li>Download <a href="http://vmtoolkit.com/files/folders/converters/entry87.aspx">VHD Resizer</a> from <a href="http://vmtoolkit.com">VMToolkit</a>.</li>
<li>Install and run VHD Resizer.</li>
<li>In the <strong>file open dialog</strong> select the VHD that you want to resize.</li>
<li>Type in the new filename to use for the extended VHD.</li>
<li>Type in the size of the new container to create.</li>
<li>Click on <strong>Resize</strong>. The process takes a few minutes&#8230;</li>
</ol>
<p><strong>Part 2:</strong></p>
<p style="text-align:left;">Now that the container is resized, we must now extend the partition to make use of the full container size.</p>
<ol>
<li><strong>Attach</strong> the new extended VHD as a <strong>non-primary drive</strong> to <em>another<strong> </strong></em>virtual machine. <em>Do not extend the partition using the virtual machine that will make use of it.</em></li>
<li>Start the virtual machine to which the extended VHD was attached as the non-primary drive and <strong>open</strong> a <strong>command prompt</strong>.</li>
<li>Type in <strong>diskpart</strong> and press <strong>Enter</strong>.</li>
<li>Type in <strong>list disk.</strong></li>
<li>Ensure that disk 1 or greater is the extended disk.</li>
<li>Type in <strong>select disk 1</strong>.</li>
<li>Type in <strong>list partition</strong>.<a href="http://thirdshelf.files.wordpress.com/2010/06/diskpart.png"><img class="size-medium wp-image-439  alignright" title="diskpart" src="http://thirdshelf.files.wordpress.com/2010/06/diskpart.png?w=300&h=162" alt="" width="300" height="162" /></a></li>
<li>Ensure that the partition sizes matches the old size.</li>
<li>Type in <strong>extend</strong>.</li>
<li>Wait for the process to complete and type <strong>exit</strong>.</li>
</ol>
<p><em>Remember to change the disk on the original virtual machine to now use the extended disk.</em> The disk is now resized and ready to be used from the original virtual machine.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/420/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/420/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/420/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=420&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2010/06/29/resizing-a-vhd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2010/06/vhdresizer.png?w=300" medium="image">
			<media:title type="html">VhdResizer</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2010/06/diskpart.png?w=300" medium="image">
			<media:title type="html">diskpart</media:title>
		</media:content>
	</item>
		<item>
		<title>Mocking multiple interfaces using Rhino Mocks</title>
		<link>http://thirdshelf.com/2010/06/06/mocking-multiple-interfaces-using-rhino-mocks/</link>
		<comments>http://thirdshelf.com/2010/06/06/mocking-multiple-interfaces-using-rhino-mocks/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 18:03:00 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[rhino-mocks]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=393</guid>
		<description><![CDATA[A while back on StackOverflow I asked a question on how to create a mock object with Rhino Mocks that implements multiple interfaces. In other words, I want to generate a mock that implements more than one interface. This baffled me for a while and I was shown the light by one of my colleagues. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=393&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A while back on StackOverflow I <a href="http://stackoverflow.com/questions/503263/how-to-determine-if-a-type-implements-a-specific-generic-interface-type">asked a question</a> on how to create a <a href="http://en.wikipedia.org/wiki/Mock_object">mock object</a> with <a href="http://www.ayende.com/projects/rhino-mocks.aspx">Rhino Mocks</a> that implements multiple interfaces. In other words, I want to generate a mock that implements more than one interface. This baffled me for a while and I was shown the light by one of my colleagues.</p>
<p>A multi-mock is created like so:</p>
<p><pre class="brush: csharp;">
var mocker = new MockRepository();
var mock = mocker.CreateMultiMock&lt;IPrimaryInterface&gt;(typeof(IFoo), typeof(IBar));
mock.Expect(x =&gt; x.AnswerToUniverse()).Return(42);
mocker.ReplayAll();
</pre><br />
Note the call to ReplayAll. Without this call the mock will not be setup with the intended values.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/393/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/393/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/393/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=393&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2010/06/06/mocking-multiple-interfaces-using-rhino-mocks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
		<item>
		<title>Unit test deployment issue when file is untrusted</title>
		<link>http://thirdshelf.com/2010/04/05/unit-test-deployment-issue-when-file-is-untrusted/</link>
		<comments>http://thirdshelf.com/2010/04/05/unit-test-deployment-issue-when-file-is-untrusted/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 15:12:52 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[visual studio]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=369</guid>
		<description><![CDATA[Recently, I decided to use NHibernate in a project so that I could achieve database affinity. That provided me with another benefit and that was the ability to create a database in-memory for testing purposes. Sounded great, but while trying to run the unit tests using MsTest and SQLite, I received the following error: &#8220;Test [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=369&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently, I decided to use <a href="http://www.nhforge.net">NHibernate</a> in a project so that I could achieve database affinity. That provided me with another benefit and that was the ability to create a <a href="http://ayende.com/Blog/archive/2006/10/14/UnitTestingWithNHibernateActiveRecord.aspx">database in-memory</a> for testing purposes. Sounded great, but while trying to run the unit tests using <a href="http://en.wikipedia.org/wiki/MSTest">MsTest</a> and <a href="http://sqlite.org/">SQLite</a>, I received the following error: &#8220;<em>Test Run deployment issue: The location of the file or directory &#8216;C:\projects\myproject\SQLite\sqlite3.dll&#8217; is not trusted.</em>&#8220;.</p>
<p>That problem was easily solved by simply unblocking the file. Below are the steps on how to unblock the file:</p>
<ol>
<li>Right-click the blocked file (sqlite3.dll), and then click 				<strong>Properties</strong>.</li>
<li>This will open the properties dialog:</li>
<p><a href="http://thirdshelf.files.wordpress.com/2010/04/unblockpropertiesdialog.png"><img title="UnblockPropertiesDialog" src="http://thirdshelf.files.wordpress.com/2010/04/unblockpropertiesdialog.png?w=377&h=515" alt="" width="377" height="515" /></a></p>
<li>In the <strong>General</strong> tab, click 				<strong>Unblock</strong>.</li>
<li>Click on <strong>OK</strong>.</li>
</ol>
<p>That&#8217;s it, the file is now trusted and the runtime should be able to load the file successfully.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/369/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/369/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/369/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=369&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2010/04/05/unit-test-deployment-issue-when-file-is-untrusted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2010/04/unblockpropertiesdialog.png" medium="image">
			<media:title type="html">UnblockPropertiesDialog</media:title>
		</media:content>
	</item>
	</channel>
</rss>
