<?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; .net</title>
	<atom:link href="http://thirdshelf.com/category/net/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; .net</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>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>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>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>XML Intellisense for NHibernate</title>
		<link>http://thirdshelf.com/2009/05/16/xml-intellisense-for-nhibernate/</link>
		<comments>http://thirdshelf.com/2009/05/16/xml-intellisense-for-nhibernate/#comments</comments>
		<pubDate>Sat, 16 May 2009 13:46:19 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[nhibernate]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=227</guid>
		<description><![CDATA[Using NHibernate requires the writing of some tedious XML-based configuration mapping files. Remembering all the tags and attributes can sometimes be overwhelming. Thankfully the contributors decided to include intellisense hints, which are in nhibernate-configuration.xsd and nhibernate-mapping.xsd. In order to have the hints available in Visual Studio 2008 copy the files into C:\Program Files\Microsoft Visual Studio [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=227&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-230" title="nhibernate-intellisense" src="http://thirdshelf.files.wordpress.com/2009/05/nhibernate-intellisense.jpg?w=720" alt="nhibernate-intellisense"   />Using <a href="http://nhforge.org/">NHibernate</a> requires the writing of some tedious XML-based configuration mapping files. Remembering all the tags and attributes can sometimes be overwhelming. Thankfully the contributors decided to include intellisense hints, which are in <strong>nhibernate-configuration.xsd</strong> and <strong>nhibernate-mapping.xsd</strong>.</p>
<p>In order to have the hints available in Visual Studio 2008 copy the files into <em>C:\Program Files\Microsoft Visual Studio 9.0\XML\Schemas</em> and restart Visual Studio.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/227/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=227&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2009/05/16/xml-intellisense-for-nhibernate/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/2009/05/nhibernate-intellisense.jpg" medium="image">
			<media:title type="html">nhibernate-intellisense</media:title>
		</media:content>
	</item>
		<item>
		<title>Proxy class design</title>
		<link>http://thirdshelf.com/2008/04/20/proxy-class-design/</link>
		<comments>http://thirdshelf.com/2008/04/20/proxy-class-design/#comments</comments>
		<pubDate>Sun, 20 Apr 2008 18:14:01 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[aop]]></category>

		<guid isPermaLink="false">http://thirdshelf.wordpress.com/?p=24</guid>
		<description><![CDATA[As part of designing our AOP.NET framework, I thought it best to start with the end in mind. What that entails is to figure out what our proxy class should look like. Let&#8217;s start with a simple interface and then design the proxy class according to the interface. If only all things in life could [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=24&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As part of designing our AOP.NET framework, I thought it best to start with the end in mind. What that entails is to figure out what our proxy class should look like. Let&#8217;s start with a simple interface and then design the proxy class according to the interface.</p>
<p><pre class="brush: csharp;">
public interface IVehicle
{
  string Make{get;set;}
  void Start();
  void Stop();
}
</pre><br />
If only all things in life could be so simple. What do we expect from our proxy class? First of all, it should proxy the call to the target instance.</p>
<p>But before the call is made to the target instance, it should first call our aspect class. Assume, for now, that our aspect just logs an entry whenever a call is made to one of the members.</p>
<p>That means that we would expect our proxy class to look something like this:<br />
<pre class="brush: csharp;">
[Proxy]
public sealed class IVehicle_LogAspect_Proxy : IVehicle
{
  private IVehicle _TargetInstance;
  private ILoggerAspect _LoggerAspect;

  public IVehicle_LogAspect_Proxy(
    IVehicle targetInstance, ILoggerAspect loggerAspect)
  {
    _TargetInstance = targetInstance;
    _LoggerAspect = loggerAspect;
  }

  public string Make
  {
    get
    {
      _LoggerAspect.Log(&quot;Make.Get&quot;);
      return _TargetInstance.Make;
    }
    set
    {
      _LoggerAspect.Log(&quot;Make.Set&quot;);
      _TargetInstance.Make = value;
    }
  }

  public void Start()
  {
    _LoggerAspect.Log(&quot;Start&quot;);
    _TargetInstance.Start();
  }

  public void Stop()
  {
    _LoggerAspect.Log(&quot;Stop&quot;);
    _TargetInstance.Stop();
  }
}
</pre></p>
<p>First, there is a Proxy attribute applied to the proxy class. This is just to identify the class as a proxy type. Sometimes it might be necessary for calling code to know whether it is dealing with a real object or a proxy. The attribute facilitates this quite nicely.</p>
<p>Naming the type is a matter of concatenating the interface names, separated by underscores together with the aspect that is injected. Finally, we simply just add the word Proxy to the type name to help with identification.</p>
<p>After all that the constructor is next. The constructor plays a vital role in the proxy as it receives the reference to the target instance as well as the reference to the aspect instance. Both these references are assigned to private variables by the constructor.</p>
<p>As you can see, the aspect method is directly injected into the member, before the call is passed to the target instance.</p>
<p>The advantages of doing it this way are that all the heavy aspect code is outside of the proxy class, which makes it a lot simpler to write and maintain.</p>
<p>Now that we have an idea of what the proxy class should look like we will <a href="http://thirdshelf.com/2008/06/01/dynamic-type-factorydynamic-type-factory/">next</a> look at the framework building blocks.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirdshelf.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirdshelf.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=24&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2008/04/20/proxy-class-design/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>Proxy aspect requirements</title>
		<link>http://thirdshelf.com/2008/04/02/proxy-aspect-requirements/</link>
		<comments>http://thirdshelf.com/2008/04/02/proxy-aspect-requirements/#comments</comments>
		<pubDate>Wed, 02 Apr 2008 17:53:37 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[aop]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=15</guid>
		<description><![CDATA[Problem: A business software package has cross-cutting functionality across its domain objects. This leads to duplicated code and needs to be generalised. Solution: Produce a general proxy aspect framework for applying aspects to domain objects. Note: The framework that we are going to construct is for a specific scenario and is not intended to compete [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=15&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Problem: </strong></p>
<p>A business software package has cross-cutting functionality across its <a href="http://en.wikipedia.org/wiki/Domain_object" target="_blank">domain objects</a>. This leads to duplicated code and needs to be generalised.</p>
<p><strong>Solution: </strong></p>
<p>Produce a general proxy aspect framework for applying aspects to domain objects.</p>
<p>Note: The framework that we are going to construct is for a specific scenario and is not intended to compete with other aspect oriented frameworks out there. It is intended to demonstrate the principles and considerations that need to be taken into account when applying aspects to domain objects.</p>
<p><strong>Prerequisite:</strong></p>
<p>Every domain object must be defined by an <a href="http://en.wikipedia.org/wiki/Interface_(computer_science)" target="_blank">interface</a>.</p>
<p><strong>Requirements:</strong></p>
<p>At a high level our requirements for the proxy aspect framework are as follows:</p>
<ul type="disc">
<li>Support multiple aspects per domain object;</li>
<li>Generated proxy must at least implement the domain objects      interface;</li>
<li>Support aspects that need to implement their own interfaces on the proxy;</li>
<li>Collections must be applied the same aspects as the domain      object it is defined on;</li>
<li>Proxy types must be <a href="http://en.wikipedia.org/wiki/Cache" target="_blank">cached</a>;</li>
<li>Support the ability to place intercepting calls before and/or      after the call to the target instance;</li>
<li>Must be able to save the assembly containing all proxy types;</li>
<li>Must be able to intercept methods, events and properties.</li>
</ul>
<p><a href="http://thirdshelf.com/2008/04/20/proxy-class-design/" target="_blank">Next</a>, we will discuss the framework design.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirdshelf.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirdshelf.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=15&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2008/04/02/proxy-aspect-requirements/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>Proxy aspect oriented approach</title>
		<link>http://thirdshelf.com/2008/03/27/proxy-aspect-oriented-approach/</link>
		<comments>http://thirdshelf.com/2008/03/27/proxy-aspect-oriented-approach/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 18:08:36 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[aop]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=9</guid>
		<description><![CDATA[A proxy aspect approach is one of many approaches in Aspect Oriented Programming. The general idea behind AOP is to deal with the problem of cross-cutting concerns. Let’s say you want to check the permissions of a user before executing a method (this is the type of aspect that we want to apply to our [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=9&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal"><span>A proxy aspect approach is one of many approaches in <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">Aspect Oriented Programming</a>. The general idea behind AOP is to deal with the problem of <a href="http://en.wikipedia.org/wiki/Cross-cutting_concern">cross-cutting concerns</a>. </span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span>Let’s say you want to check the permissions of a user before executing a method (this is the type of aspect that we want to apply to our object). You can appreciate that when a system is beyond “Hello World!” that this can turn out to be quite a thing to remember and apply on every method.</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span>To solve this problem we would need to inject this call into the methods where this security check needs to be done. This can be done in various ways, such as creating a proxy at runtime that performs the check or alter the assemblies with another tool afte</span><span>r compilation.</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span>Over the next couple of weeks, I will walk you through the requirements, design and construction of one of these approaches that I call; you guessed it; the proxy aspect approach.</span></p>
<p class="MsoNormal"><span> </span></p>
<p><img src="http://thirdshelf.files.wordpress.com/2008/03/proxyandtarget.png?w=720" alt="Target instance with Proxy object" align="left" /><span>At a high level, the idea is to create a <a href="http://en.wikipedia.org/wiki/Proxy_pattern" target="_blank">proxy</a> for every object that needs to have certain functionality executed as soon as, for example, a method is entered or a property is changed. In effect, the object will have multiple layers or proxies to which all calls; that are intended for the target instance; are directed. </span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span>One proxy is created</span><span> for each aspect that is applied, and every proxy object carries a reference to the instance of the target instance. This target instance can either be another proxy object or</span><span> the final domain object, say.</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span>When the call is made to the proxy object it will execute the aspect code and then forward the call to the target instance. If the target instance is a proxy, the same process will happen again until it reaches the inner most target instance where the call is finally handled. If there are results that need to be returned, it passes back up through every proxy until it reaches the original caller.</span></p>
<p class="MsoNormal"><span> </span></p>
<p class="MsoNormal"><span><a href="http://thirdshelf.com/2008/04/02/proxy-aspect-requirements/" target="_blank">Next</a>, we’ll have a look at the requirements.</span></p>
<p class="MsoNormal">
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirdshelf.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirdshelf.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=9&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2008/03/27/proxy-aspect-oriented-approach/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/2008/03/proxyandtarget.png" medium="image">
			<media:title type="html">Target instance with Proxy object</media:title>
		</media:content>
	</item>
		<item>
		<title>Welcome</title>
		<link>http://thirdshelf.com/2008/03/24/welcome/</link>
		<comments>http://thirdshelf.com/2008/03/24/welcome/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 15:13:16 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=5</guid>
		<description><![CDATA[Welcome to the Third Shelf! The Third Shelf is the place where I put all those hardcore things that I have to deal with in programming, hardcore things such as aspect-oriented programming and all the other not-so-commonly-used stuff in the .NET framework. I volunteered (blue pill or red pill?) to write an aspect-oriented subsystem, that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=5&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Welcome to the Third Shelf!</p>
<p>The Third Shelf is the place where I put all those hardcore things that I have to deal with in programming, hardcore things such as aspect-oriented programming and all the other not-so-commonly-used stuff in the .NET framework.</p>
<p>I volunteered (blue pill or red pill?) to write an aspect-oriented subsystem, that applies aspects to business objects. Well, needless to say that I will never be the same person again! So, I decided to start this blog to talk about and show some of the intricacies, pit falls and abysses in programming aspect-oriented systems. I will also cover some other programming things, such as native assembler, .NET security, etc.</p>
<p>So, if you are willing to explore life on the wild-side of programming, stay tuned!</p>
<p><span style="font-family:Georgia;"></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirdshelf.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirdshelf.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=5&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2008/03/24/welcome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
	</channel>
</rss>
