<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>GojiSoft » Blog</title>
	
	<link>http://gojisoft.com</link>
	<description />
	<lastBuildDate>Wed, 03 Nov 2010 17:40:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/gojisoftblog" /><feedburner:info uri="gojisoftblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>51.501210</geo:lat><geo:long>0.141964</geo:long><item>
		<title>ReSharper test runner – hidden thread exceptions</title>
		<link>http://feedproxy.google.com/~r/gojisoftblog/~3/1WNClJ2fM78/</link>
		<comments>http://gojisoft.com/blog/2010/05/14/resharper-test-runner-hidden-thread-exceptions/#comments</comments>
		<pubDate>Fri, 14 May 2010 15:31:00 +0000</pubDate>
		<dc:creator>Tim Lloyd</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ReSharper]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://gojisoft.com/?p=820</guid>
		<description><![CDATA[We use the ReSharper test runner here at GojiSoft to run NUnit tests from within Visual Studio. It’s a great test runner, but doesn’t play nicely with multi-threaded components where exceptions may occur on non-test threads. Unhandled exceptions on non-test threads are hidden and tests which should fail, instead pass. Here’s a very very contrived [...]]]></description>
				<content:encoded><![CDATA[<p>We use the <a href="http://www.jetbrains.com/resharper/features/unit_testing.html" target="_blank">ReSharper test runner</a> here at <a href="http://gojisoft.com/" target="_blank">GojiSoft</a> to run NUnit tests from within Visual Studio. It’s a great test runner, but doesn’t play nicely with multi-threaded components where exceptions may occur on non-test threads. Unhandled exceptions on non-test threads are hidden and tests which should fail, instead pass. Here’s a very very contrived example:</p>
<p> <span id="more-820"></span>
</p>
<pre class="brush: csharp;">[Test]
public void NonTestThreadException()
{
    Thread thread = new Thread(obj =&gt; { throw new Exception(&quot;Oops...&quot;); });
    thread.Start();
    thread.Join();
}</pre>
<p>If an exception isn’t raised on the test thread, the test passes – Oops!</p>
<p><a title="ReSharper test runner: Test passes incorrectly." href="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperTestPassesIncorrectly.png" rel="lightbox"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ReSharper test runner: Test passes incorrectly." border="0" alt="ReSharper test runner: Test passes incorrectly." src="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperTestPassesIncorrectly_thumb.png" width="644" height="203" /></a></p>
<p>The problem lies in the fact that the ReSharper test runner is configured to behave in the same way as .Net 1.0 and 1.1 apps where unhandled exceptions on non-main threads were swallowed. The situation improves from .Net 2.0 where all unhandled exceptions flatten the process. However, Microsoft had to allow existing .Net 1.0 and 1.1 apps the option of behaving as before on new .Net frameworks. They introduced the app.config setting: <a href="http://msdn.microsoft.com/en-us/library/ms228965.aspx" target="_blank">legacyUnhandledExceptionPolicy</a>.</p>
<p>The ReSharper test runner is configured by default to use the .Net 1.0 and 1.1 policy, so if there is an unhandled non-test thread exception it does not bubble up and cause the test to fail – the test passes, and we get a false positive instead.</p>
<p>If unhandled exceptions on non-test threads should fail tests, the app.config for the ReSharper test runner has to be updated.</p>
<h4><strong>Configuring the test runner to fail on unhandled thread exceptions</strong></h4>
<p><strong>1.</strong> Firstly find out which test runner executable is actually being used. Run a test in debug mode and look in the Visual Studio output window: </p>
<p><a title="Visual Studio: Finding the ReSharper task runner executable." href="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperTaskRunner.png" rel="lightbox"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Visual Studio: Finding the ReSharper task runner executable." border="0" alt="Visual Studio: Finding the ReSharper task runner executable." src="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperTaskRunner_thumb.png" width="644" height="180" /></a></p>
</p>
<p><strong>2.</strong> Locate the executable’s app.config file, e.g.:</p>
<p>C:\Program Files\JetBrains\ReSharper\v5.0\Bin\JetBrains.ReSharper.TaskRunner.CLR4.MSIL.<strong>exe.config</strong></p>
<p><strong>3.</strong> Turn the legacy unhandled exception policy off by editing legacyUnhandledExceptionPolicy:</p>
<p>&lt;legacyUnhandledExceptionPolicy enabled=&quot;<strong>0</strong>&quot; /&gt;</p>
<p><strong>4.</strong> Now multi-threaded tests fail as expected when they raise exceptions on non-test threads:</p>
<p><a title="ReSharper test runner: Test fails as expected." href="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperTestFailsAsExpected.png" rel="lightbox"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ReSharper test runner: Test fails as expected." border="0" alt="ReSharper test runner: Test fails as expected." src="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperTestFailsAsExpected_thumb.png" width="644" height="204" /></a></p>
<h4>Buyer beware…</h4>
<p>There is a caveat to this. Exceptions on non-test threads will now flattened the test runner and test suite execution will be halted when they happen. This is in contrast to normal test runs where failed tests are marked as failed, and the test runner continues. A pain – annoying? Maybe, but failed multi-threaded tests should be a pain and fixed ASAP. Of course, if they’re not your tests, you can always delete them from the test runner session - move along, nothing to see here, dum-de-dum-de-dum… <img src='http://gojisoft.com/_blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=1WNClJ2fM78:kBl3cBeFsn4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=1WNClJ2fM78:kBl3cBeFsn4:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=1WNClJ2fM78:kBl3cBeFsn4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=1WNClJ2fM78:kBl3cBeFsn4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=1WNClJ2fM78:kBl3cBeFsn4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=1WNClJ2fM78:kBl3cBeFsn4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/gojisoftblog/~4/1WNClJ2fM78" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gojisoft.com/blog/2010/05/14/resharper-test-runner-hidden-thread-exceptions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://gojisoft.com/blog/2010/05/14/resharper-test-runner-hidden-thread-exceptions/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=resharper-test-runner-hidden-thread-exceptions</feedburner:origLink></item>
		<item>
		<title>C# Coding standards using ReSharper</title>
		<link>http://feedproxy.google.com/~r/gojisoftblog/~3/E9KBUor7UCM/</link>
		<comments>http://gojisoft.com/blog/2010/05/10/coding-standards-using-resharper/#comments</comments>
		<pubDate>Mon, 10 May 2010 17:41:00 +0000</pubDate>
		<dc:creator>Tim Lloyd</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ReSharper]]></category>

		<guid isPermaLink="false">http://gojisoft.com/?p=732</guid>
		<description><![CDATA[Having coding standards can help improve code readability and maintenance across a team, but they can be a pain if they have to be manually followed and enforced. This article describes how we used ReSharper 5 to make applying coding standards a lot less painful. This article: Assumes your dev team uses the excellent refactoring [...]]]></description>
				<content:encoded><![CDATA[<p>Having coding standards can help improve code readability and maintenance across a team, but they can be a pain if they have to be manually followed and enforced. This article describes how we used <a href="http://www.jetbrains.com/resharper/" target="_blank">ReSharper 5</a> to make applying coding standards a lot less painful.</p>
</p>
<p> <span id="more-732"></span>
<p>This article:</p>
<ul>
<li>Assumes your dev team uses the excellent refactoring and all-round code goodness tool that is ReSharper. If you’re not familiar, then please do check it out. It really is <strong>very</strong> good… </li>
<li>Describes how to get ReSharper settings automatically propagated around the team. </li>
<li>Does <strong>not</strong> discuss coding standards. That’s up to your team to <strike>argue bitterly</strike> come to an amicable agreement about. <img src='http://gojisoft.com/_blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </li>
</ul>
<p>Whilst ReSharper is not a panacea for coding standards, it is very effective for defining rules such as:</p>
<ul>
<li><strong>Naming standards:</strong> Private instance variables should be named like “_camelCase”. </li>
<li><strong>Code formatting:</strong> Braces should appear on the next line after a statement. </li>
<li><strong>Language usage:</strong> Warn on redundant use of the “.this” qualifier. </li>
<li><strong>Many Many </strong>other settings… </li>
</ul>
<p>There are a large number of settings that can be configured in ReSharper, and then automatically applied using ReSharper’s excellent <a href="http://www.jetbrains.com/resharper/features/code_formatting.html" target="_blank">Code Cleanup</a> feature, or used to analyze source code to find misdemeanours. Bind Code Cleanup to a keyboard shortcut, and a lot of issues such as formatting and redundant code can be taken care of in an instant. With a little bit of investment (we spent a couple of hours), standards can be configured, and more importantly they can be automatically propagated around the development team through source control.</p>
<p>These are the steps we went through to set up <a href="http://www.jetbrains.com/resharper/" target="_blank">ReSharper</a>:</p>
<ol>
<li>Configuring coding standards. </li>
<li>Automating code cleanup. </li>
<li>Fine tuning. </li>
<li>Sharing ReSharper settings with the team. </li>
<li>Sorting the existing codebase out. </li>
</ol>
<h4>Configuring coding standards</h4>
<p>First of all a set of coding standards has to be agreed on. Whilst these may grow and be refined over time, getting the bulk of them agreed and configured up-front is the most productive way of doing it.</p>
<p>What we did:</p>
<ul>
<li>Got the big points-of-difference discussed and agreed upon e.g. should we use the ‘var’ and ‘this’ keywords? These topics should come easily to most teams, but reaching agreement and compromise is often another matter… </li>
<li>Got the team together and loaded up our Visual Studio solution. We used a single machine for the initial stages so we could see how settings affected our code. </li>
<li>Went through ReSharper settings (e.g. <a href="http://www.jetbrains.com/resharper/webhelp/Code_Analysis__Configuring_Warnings.html" target="_blank">Inspection Severities</a> and <a href="http://www.jetbrains.com/resharper/webhelp/Reference__Options__Languages__CSharp__Formatting_Style.html" target="_blank">Formatting Style</a>) changing them until they matched the agreed coding standards. </li>
<li>Ensured agreed standards were enforced in ReSharper through code formatting rules and displaying warnings (“ReSharper Amber”) for non-compliance. </li>
</ul>
<p>Coding standards are now configured in ReSharper. If a code file doesn’t get the ReSharper <font color="#008000"><strong>green</strong> </font>light, then it isn’t following the standards.</p>
<p>Having ReSharper give amber and red lights for code that fails rules is all well and good, but can ReSharper help us to automate any of this at all? Yes, with ReSharper’s Code Cleanup functionality.</p>
<h4>Automating code cleanup</h4>
<p>One of the great features in ReSharper is <a href="http://www.jetbrains.com/resharper/features/code_formatting.html" target="_blank">Code Cleanup</a>. This allows code formatting rules, and a selection of code re-writing rules to be automated on a: single file, folder, project, solution, or a mixture of these. It’s really quite flexible.</p>
<p>ReSharper ships with a couple of code cleanup profiles, but a custom profile can be more easily shared amongst the team. Custom profiles can be created in ReSharper options. Add a new code cleanup profile, and set “Profile to use with silent cleanup” to it, as below:</p>
<p><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperSettings_CodeCleanup1.png" rel="lightbox"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ReSharper Settings: Custom code cleanup profile" border="0" alt="ReSharper Settings: Custom code cleanup profile" src="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperSettings_CodeCleanup_thumb1.png" width="227" height="244" /></a> </p>
<p>The above screenshot shows the code cleanup profile we use here at <a href="http://gojisoft.com/" target="_blank">GojiSoft</a>. Amongst other things it will remove redundant code (basically anything that is configured in ReSharper as “Redundant”) and automatically apply code formatting rules. Who wants to go through code manually removing unused using statements, namespace qualifiers and other general crud – exactly - use Code Cleanup instead.</p>
<p>Setting “Profile to use with silent cleanup” to your new custom profile means that a ReSharper keyboard shortcut will invoke it and clean up your code automatically. Great, but also very dangerous. Depending on what the context is at the time, it can either clean up your current file or start to clean up your whole project or solution!</p>
<p>We removed the global ReSharper code cleanup shortcut, and replaced it with the Visual Studio shortcut “Format Document Ctrl K, Ctrl D”. This way it’s easy to format a *<strong>single</strong>* file as you go along. This shortcut can be set up in Visual Studio options:</p>
<p align="center">Tools –&gt; Options –&gt; Environment –&gt; Keyboard</p>
<p align="center"><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperSettings_CodeCleanupShorcut_Remove.png" rel="lightbox"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ReSharper Settings: Remove gloabl code cleanup shortcut" border="0" alt="ReSharper Settings: Remove gloabl code cleanup shortcut" src="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperSettings_CodeCleanupShorcut_Remove_thumb.png" width="284" height="165" /></a>Remove ReSharper global “code cleanup” shortcut</p>
<p align="center"><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperSettings_CodeCleanupShorcut_Assign.png" rel="lightbox"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ReSharper Settings: ReplaceVisual Studio document format shortcut" border="0" alt="ReSharper Settings: ReplaceVisual Studio document format shortcut" src="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperSettings_CodeCleanupShorcut_Assign_thumb.png" width="284" height="165" /></a>&#160; </p>
<p align="center">Replace Visual Studio “document format” shortcut</p>
<p>Make sure that the “Use shortcut in” drop-down has “Text Editor” set as the context. This reins code cleanup to the text editor, and prevents any more of its megalomaniacal tendencies to cleanup every file in your solution…</p>
<h4>Fine tuning</h4>
<p>Ok, so now a fair amount of time has been spent setting up ReSharper, but will automated code cleanup act on our files just the way we like it? It’s time to fine tune those settings.</p>
<ul>
<li>Select a bunch of files in solution explorer, right-click and select “Cleanup code…”. </li>
<li>Use your source control client\favourite diffing tool to see what changes have been made. </li>
<li>If you’re not happy with the results of automated code cleanup, revisit the ReSharper settings. </li>
<li>Rinse and repeat until happy. </li>
</ul>
<p>We now have ReSharper and code cleanup set up just the way we want it, but only on a single machine. How do we go about automatically sharing these settings with the rest of the team?</p>
<h4>Sharing ReSharper settings with the team</h4>
<p>The built-in support for sharing ReSharper settings is a little patchy, and can’t really be done completely without having to go through a manual settings export/import loop. Getting the whole team in sync with a manual solution isn’t really going to work very well in the long run.</p>
<p>Fortunately ReSharper has plugin support, and <a href="http://rsm.codeplex.com/" target="_blank">ReSharper Settings Manager</a> comes to the rescue. This plugin allows all ReSharper settings to be saved to a single file which can be placed under source control. The plugin will automatically update ReSharper settings if an updated settings file is detected e.g. when an updated settings file is gotten through source control.</p>
<ul>
<li>Download and install <a href="http://rsm.codeplex.com/" target="_blank">ReSharper Settings Manager</a>. </li>
<li>Open the Visual Studio solution on the machine used to set up the coding standards rules. </li>
<li>Open ReSharper options and configure <a href="http://rsm.codeplex.com/" target="_blank">ReSharper Settings Manager</a> to use a single configuration file per solution: </li>
</ul>
<p><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperSettingsManager_ConfiguringASharedSettingsFile1.png" rel="lightbox"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ReSharper Settings Manager: Configuring a shared settings file" border="0" alt="ReSharper Settings Manager: Configuring a shared settings file" src="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperSettingsManager_ConfiguringASharedSettingsFile_thumb1.png" width="244" height="147" /></a></p>
<ul>
<li>Click OK, to close the ReSharper options dialog. </li>
<li>To verify that a shared settings file is being used, open the settings manager dialog from the Visual Studio menu: </li>
</ul>
<p align="center">ReSharper –&gt; Tools –&gt; Manage Settings… </p>
<p><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperSettingsManager_Configuration1.png" rel="lightbox"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ReSharper Settings Manager: Configuration" border="0" alt="ReSharper Settings Manager: Configuration" src="http://gojisoft.com/_blog/wp-content/uploads/2010/05/ReSharperSettingsManager_Configuration_thumb1.png" width="244" height="135" /></a> </p>
</p>
<ul>
<li>Select the shared settings for your solution from the “Manage Settings” dialog and click Save. </li>
<li>You should now have a shiny new shared ReSharper settings file in the root of your solution e.g. “MySolution.R#Settings”. This file contains all of your ReSharper settings. </li>
<li>Add the new settings file to source control. </li>
<li>Get everyone on the team to install the <a href="http://rsm.codeplex.com/" target="_blank">ReSharper Settings Manager</a> and get latest from source control to get the shared configuration file. </li>
<li>Settings will now be automatically propagated around the team. </li>
<li>Spread the word about automated code cleanup and setting up the shortcut. </li>
<li>Everyone must now “Ctrl K, Ctrl D” and make sure files are ReSharper <strong><font color="#008000">green</font></strong> before checking into source control. Failure to do so will result in having an arm ripped off and being beaten around the head with the soggy end. <img src='http://gojisoft.com/_blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </li>
</ul>
<p><strong>NB</strong> When you want to change the shared ReSharper settings: first change the settings, then open the “Manage Settings” dialog (ReSharper –&gt; Tools –&gt; Manage Settings…), select the shared settings file and click Save. The changes can then be committed to source control for sharing with the rest of the team.</p>
<h4>Sorting the existing codebase out</h4>
<p>This step is optional, but you may wish to sort out the existing code base to make sure it meets the coding standards. The ReSharper feature “Find Code Issues” can be used from solution explorer to find code files where ReSharper rules have failed.&#160; We used divide and conquer to work through folders in our projects, and fixed up all the warnings. If you have a team member with a conspicuously tidy desk with nicely lined up pencils, they may even enjoy doing this task all on their own… <img src='http://gojisoft.com/_blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=E9KBUor7UCM:CyhHY-chG0k:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=E9KBUor7UCM:CyhHY-chG0k:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=E9KBUor7UCM:CyhHY-chG0k:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=E9KBUor7UCM:CyhHY-chG0k:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=E9KBUor7UCM:CyhHY-chG0k:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=E9KBUor7UCM:CyhHY-chG0k:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/gojisoftblog/~4/E9KBUor7UCM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gojisoft.com/blog/2010/05/10/coding-standards-using-resharper/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://gojisoft.com/blog/2010/05/10/coding-standards-using-resharper/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=coding-standards-using-resharper</feedburner:origLink></item>
		<item>
		<title>Event Sequence Unit Testing – Conclusion</title>
		<link>http://feedproxy.google.com/~r/gojisoftblog/~3/jinfIuNPMO4/</link>
		<comments>http://gojisoft.com/blog/2010/04/27/event-sequence-unit-testing-conclusion/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 00:25:52 +0000</pubDate>
		<dc:creator>Tim Lloyd</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IL]]></category>
		<category><![CDATA[MSIL]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://gojisoft.com/?p=652</guid>
		<description><![CDATA[A lot of the development we’ve been doing here at GojiSoft has involved event driven component development. This four part article describes how we went about developing a generalized event testing framework to more easily write unit tests that codified event firing sequences. Part 1 Unit testing event sequences. Part 2 Developing an event monitor [...]]]></description>
				<content:encoded><![CDATA[<p>A lot of the development we’ve been doing here at <a href="http://gojisoft.com/" target="_blank">GojiSoft</a> has involved event driven component development. This four part article describes how we went about developing a generalized event testing framework to more easily write unit tests that codified event firing sequences.</p>
<p> <span id="more-652"></span>
</p>
<ul>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-1/" target="_blank">Part 1</a> Unit testing event sequences. </li>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-2/" target="_blank">Part 2</a> Developing an event monitor to test an object’s events. </li>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-3/" target="_blank">Part 3</a> Using Reflection and MSIL (Intermediate Language) to implement a generic event monitor. </li>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-4/" target="_blank">Part 4</a> Reflection and MSIL code for dynamic event subscription in detail. </li>
<li><a href="http://gojisoft.com/blog/2010/04/27/event-sequence-unit-testing-conclusion/" target="_blank">Conclusion</a> Using the EventMonitor to write [Test]s. </li>
</ul>
<p align="center"><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/04/EventSequenceUnitTesting4.zip"></a></p>
<p align="center"><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/04/EventSequenceUnitTesting4.zip">Download Source Code</a></p>
</p>
<hr />
<h3>Conclusion</h3>
<p>In <a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-1/" target="_blank">Part 1</a> of this series we saw some of the challenges of writing event unit tests. The challenges mainly revolved around writing lots of repetitive boilerplate code, e.g.:</p>
<pre class="brush: csharp;">[Test]
public void EventSequenceTest()
{
    bool eventARaised, eventBRaised;

    eventARaised = eventBRaised = false;

    EventPublisher publisher = new EventPublisher();

    publisher.EventA += delegate { eventARaised = true; };
    publisher.EventB += delegate { eventBRaised = true; };

    //Do some stuff to the state of publisher.
    publisher.RaiseA();
    Assert.IsTrue(eventARaised, &quot;Event A raised.&quot;);

    //Do some stuff to the state of publisher.
    publisher.RaiseB();    
    Assert.IsTrue(eventBRaised, &quot;Event B raised.&quot;);
}</pre>
<p>To add to the mix we saw slight variations with INotifyPropertyChanged events, and further complications with asynchronous events. This all starts getting repetitive and messy when you’ve got lots of tests to write.</p>
<p>In parts 2-4, we went over the gory details of implementing an event monitor which could test the events of any object, and so be used to write unit tests more easily.</p>
<p>So how exactly can the event monitor be used to write unit tests?</p>
<h3>EventMonitor.Assert</h3>
<p>The EventMonitor class has two static methods:</p>
<pre class="brush: csharp; gutter: false;">Assert(Action test, object publisher, IEnumerable&lt;string&gt; expectedSequence)

Assert(Action test, object publisher, IEnumerable&lt;string&gt; expectedSequence, int timeoutMS)</pre>
<p>Where:</p>
<ul>
<li><strong>test</strong> Code which manipulates the state of the test object and causes events to be raised. </li>
<li><strong>publisher</strong> The test object - any object that publishes events. </li>
<li><strong>expectedSequence</strong> A list of event names in the order they are expected to be raised. </li>
<li><strong>timeoutMS</strong> For asynchronous events, the maximum amount of time to wait for each event. </li>
</ul>
<p>The following show examples of using the EventMonitor with: synchronous, asynchronous and INotifyPropertyChanged events. The event monitor can be used to test an object that has a mixture of these events types.</p>
<h4>Synchronous</h4>
<pre class="brush: csharp;">[Test]
public void EventTest()
{
    var publisher = new EventPublisher();

    Action test = () =&gt; { publisher.RaiseA(); publisher.RaiseB(); };

    var expectedSequence = new[] { &quot;EventA&quot;, &quot;EventB&quot; };

    EventMonitor.Assert(test, publisher, expectedSequence);
}</pre>
<h4>Asynchronous</h4>
<p>Pretty much the same as testing synchronous events, but with the edition of specifying a timeout value.</p>
<pre class="brush: csharp;">[Test]
public void EventTest()
{
    var publisher = new AsyncEventPublisher();

    Action test = () =&gt; { publisher.RaiseA(); publisher.RaiseB(); };

    var expectedSequence = new[] { &quot;EventA&quot;, &quot;EventB&quot; };

    EventMonitor.Assert(test, publisher, expectedSequence, TimeoutMS);
}</pre>
<h4>INotifyPropertyChanged</h4>
<p>For events that are published via an INotifyPropertyChanged implementation, the event name should be the name of the associated property.</p>
<pre class="brush: csharp;">[Test]
public void EventTest()
{
    var publisher = new PropertyChangedEventPublisher();

    Action test = () =&gt; { publisher.X = 1; publisher.Y = 2; };

    var expectedSequence = new[] { &quot;X&quot;, &quot;Y&quot; };

    EventMonitor.Assert(test, publisher, expectedSequence);
}</pre>
<p align="center"><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/04/EventSequenceUnitTesting4.zip">Download Source Code</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=jinfIuNPMO4:A2yfsP6Lx3Q:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=jinfIuNPMO4:A2yfsP6Lx3Q:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=jinfIuNPMO4:A2yfsP6Lx3Q:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=jinfIuNPMO4:A2yfsP6Lx3Q:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=jinfIuNPMO4:A2yfsP6Lx3Q:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=jinfIuNPMO4:A2yfsP6Lx3Q:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/gojisoftblog/~4/jinfIuNPMO4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gojisoft.com/blog/2010/04/27/event-sequence-unit-testing-conclusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gojisoft.com/blog/2010/04/27/event-sequence-unit-testing-conclusion/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=event-sequence-unit-testing-conclusion</feedburner:origLink></item>
		<item>
		<title>Event Sequence Unit Testing – Part 4</title>
		<link>http://feedproxy.google.com/~r/gojisoftblog/~3/xsE6ZJglYww/</link>
		<comments>http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-4/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 16:07:00 +0000</pubDate>
		<dc:creator>Tim Lloyd</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IL]]></category>
		<category><![CDATA[MSIL]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://gojisoft.com/?p=433</guid>
		<description><![CDATA[A lot of the development we’ve been doing here at GojiSoft has involved event driven component development. This four part article describes how we went about developing a generalized event testing framework to more easily write unit tests that codified event firing sequences. Part 1 Unit testing event sequences. Part 2 Developing an event monitor [...]]]></description>
				<content:encoded><![CDATA[<p>A lot of the development we’ve been doing here at <a href="http://gojisoft.com/" target="_blank">GojiSoft</a> has involved event driven component development. This four part article describes how we went about developing a generalized event testing framework to more easily write unit tests that codified event firing sequences.</p>
<p> <span id="more-433"></span>
</p>
<ul>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-1/" target="_blank">Part 1</a> Unit testing event sequences. </li>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-2/" target="_blank">Part 2</a> Developing an event monitor to test an object’s events. </li>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-3/" target="_blank">Part 3</a> Using Reflection and MSIL (Intermediate Language) to implement a generic event monitor. </li>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-4/" target="_blank">Part 4</a> Reflection and MSIL code for dynamic event subscription in detail. </li>
<li><a href="http://gojisoft.com/blog/2010/04/27/event-sequence-unit-testing-conclusion/" target="_blank">Conclusion</a> Using the EventMonitor to write [Test]s. </li>
</ul>
<p align="center"><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/04/EventSequenceUnitTesting4.zip"></a></p>
<p align="center"><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/04/EventSequenceUnitTesting4.zip">Download Source Code</a></p>
</p>
<hr />
<h3>Part 4</h3>
<p>In <a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-3/" target="_blank">Part 3</a> of this series we saw how we could use the DynamicEvent class to create event proxies to allow our event monitor to dynamically subscribe to any type’s events. In this last part of the series we describe the DynamicEvent code in detail showing how Reflection and IL are used to create an event handler proxy for implementing dynamic event subscription.</p>
<p>&#160;</p>
<p align="center"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Dynamic event proxy pattern" border="0" alt="Dynamic event proxy pattern" src="http://gojisoft.com/_blog/wp-content/uploads/2010/04/DynamicEventProxy.png" width="453" height="362" /></p>
<p align="center">Dynamic event proxy pattern.</p>
<p align="center">&#160;</p>
<h2>The DynamicEvent Class</h2>
<p>Subscribing events dynamically is straightforward using DynamicEvent, but the following steps detail what's going on under the hood...</p>
<pre class="brush: csharp;">EventPublisher publisher = new EventPublisher();

foreach (EventInfo eventInfo in publisher.GetType().GetEvents())
{
    DynamicEvent.Subscribe(eventInfo, publisher, (sender, e, eventName) =&gt;
    {
        Console.WriteLine(&quot;Event raised: &quot; + eventName);
    });
}</pre>
<ol>
<li>
<div align="left">Create the event proxy.</div>
</li>
<li>
<div align="left">Create a dynamic method.</div>
</li>
<li>
<div align="left">Inject the event name and call the event handler.</div>
</li>
<li>
<div align="left">Wrapping it all up.</div>
</li>
</ol>
<h4>1. Create The Event Proxy</h4>
<p>Firstly, the creation of the event proxy is orchestrated when calling CreateProxyEventHandler.</p>
<pre class="brush: csharp;">public delegate void ProxyEventHandler(object sender, EventArgs e, string eventName);

//Useful if we need a reference to the delegate for unscribing an event.
public static Delegate CreateProxyEventHandler(
    EventInfo eventInfo, object eventPublisher, ProxyEventHandler handler)
{
    Type eventType = eventInfo.EventHandlerType;
    bool isStatic = handler.Method.IsStatic;
    Type owner = isStatic ? handler.GetType() : handler.Target.GetType();
    string eventName = eventInfo.Name;

    //Step 2 - Create a dynamic method
    DynamicMethod proxyMethod = CreateDynamicMethod(eventType, eventName, proxyOwner);

    //Step 3 - Inject the event name and call to our event handler
    EmitCode(proxyMethod, isStatic, eventName, handler);

    //Step 4 - Wrap the whole thing up in a delegate
    Delegate proxyHandler = proxyMethod.CreateDelegate(eventType, handler.Target);

    return proxyHandler;
}

//Directly subscribe an event handler.
public static void Subscribe(
    EventInfo eventInfo, object eventPublisher, ProxyEventHandler eventHandler)
{
    Delegate proxyEventHandler = CreateProxyEventHandler(
        eventInfo, eventPublisher, eventHandler);

    eventInfo.GetAddMethod().Invoke(eventPublisher, new[] { proxyEventHandler });
}</pre>
<h4>2. Create a Dynamic Method</h4>
<p align="left">Our event proxy is two-sided. Side 1 is called by our event, and side 2 calls into our event handler. For the event side, we must have a method whose signature exactly matches that of the event. As we are dynamically discovering events at runtime, we do not have a matching method in our code, so how do we conjure up a method that has the same signature as our event? We use a <a href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.dynamicmethod.aspx" target="_blank">dynamic method</a><strong>*</strong>.</p>
<p align="left">In preparation for creating our dynamic method, we use reflection to get matching information about the signature of the target event. Having prepared our signature information, we construct our dynamic method. We now have a dynamic method with the same signature as our event.</p>
<p align="left">That’s side 1 of our proxy sorted.</p>
<pre class="brush: csharp;">private static DynamicMethod CreateDynamicMethod(
    Type eventType, bool isStatic, string eventName, Type owner)
{
    const includePrivate = true;

    string proxyName = (&quot;Generated proxy for event: &quot; + eventName + &quot;.&quot;);
    Type returnType = typeof(void);

    List&lt;type&gt; eventParameterTypes = new List&lt;type&gt;();

    ParameterInfo[] eventParameters = eventType.GetMethod(&quot;Invoke&quot;).GetParameters();

    eventParameterTypes.Add(proxyOwner);

    eventParameterTypes.AddRange(eventParameters.Select(x =&gt; x.ParameterType));

    Type[] parameters = eventParameterTypes.ToArray();

    DynamicMethod proxyMethod = new DynamicMethod(
        proxyName, returnType, parameters, proxyOwner, includePrivate);

    return proxyMethod;
}</pre>
<p><em><strong>*</strong> Dynamic methods are created at runtime and provide a shell into which we can emit custom code using IL. Dynamic methods can be wrapped in a delegate and called by any other code – just like a regular delegate. This allows parts of a program to be written whilst the application is actually running – self-modifying code.</em></p>
<h4>3. Inject The Event Name and Call The Event Handler</h4>
<p>Now we tackle side 2 of the proxy: the call to our event handler. This is accomplished using <a href="http://en.wikipedia.org/wiki/Common_Intermediate_Language" target="_blank">IL</a> as we have to generate custom code at runtime.</p>
<p>The IL code sets the call stack up with the arguments to our event handler<strong>*</strong> (matching the signature of ProxyEventHandler), and then instructs the runtime to call it. Most importantly it is the device used to handle the injection of our event name so that our tests can do their asserting.</p>
<p>The two sides of the event proxy are now completed.</p>
<pre class="brush: csharp;">private static void EmitCode(DynamicMethod proxyMethod, bool isStatic, string eventName, ProxyEventHandler handler)
{
    ILGenerator il = proxyMethod.GetILGenerator();

    if (!isStatic)
    {
        il.Emit(OpCodes.Ldarg_0);           //target object for non-static calls.
    }

    il.Emit(OpCodes.Ldarg_1);               //arg0 - sender
    il.Emit(OpCodes.Ldarg_2);               //arg1 - eventArgs
    il.Emit(OpCodes.Ldstr, eventName);      //arg2 - *injected event name*
    il.Emit(OpCodes.Call, handler.Method);  //call proxy event handler
    il.Emit(OpCodes.Ret);
}</pre>
<p><em><strong>*</strong> Preparing the arguments for the call stack takes into consideration whether the event subscriber is a static or instance method. All calls to instance methods must have an argument at the first position in the call stack that holds a reference to the instance being called. In a nutshell, the instance reference is passed along by the runtime to the code being executed so it knows what “this” is (static methods do not have a concept of “this”). This is managed by the runtime internally and not exposed at a high level e.g. when programming in C#.</em></p>
<h4>Step 4 - Wrapping It All Up</h4>
<p>Now that we have created the dynamic method and emitted our IL code into it, we create a delegate from it. This delegate can be subscribed to an event using reflection.</p>
<pre class="brush: csharp;">Delegate proxyHandler = proxyMethod.CreateDelegate(eventType, handler.Target);

eventInfo.GetAddMethod().Invoke(eventPublisher, new[] { proxyHandler });</pre>
<p align="left">The signature of the delegate matches the signature of our target event, whilst the arguments pushed onto the stack in our IL match the signature of our test method – the proxy event handler. This combination gives us a proxy that bridges an arbitrary event and our common event handler (see diagram). The injection of the event name into our IL gives us the information about which event has been raised and so allows us to do our testing.</p>
<h4>Conclusion</h4>
<p align="left">Now we’ve gone over the gory details, we describe how to use the EventMonitor to write unit tests:</p>
<p align="center"><a href="http://gojisoft.com/blog/2010/04/27/event-sequence-unit-testing-conclusion/" target="_blank">Event Sequence Unit Testing – Conclusion</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=xsE6ZJglYww:ywDHYIahxhc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=xsE6ZJglYww:ywDHYIahxhc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=xsE6ZJglYww:ywDHYIahxhc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=xsE6ZJglYww:ywDHYIahxhc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=xsE6ZJglYww:ywDHYIahxhc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=xsE6ZJglYww:ywDHYIahxhc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/gojisoftblog/~4/xsE6ZJglYww" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-4/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=event-sequence-unit-testing-part-4</feedburner:origLink></item>
		<item>
		<title>Event Sequence Unit Testing – Part 3</title>
		<link>http://feedproxy.google.com/~r/gojisoftblog/~3/Jycs1xg4mFc/</link>
		<comments>http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-3/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 16:06:00 +0000</pubDate>
		<dc:creator>Tim Lloyd</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IL]]></category>
		<category><![CDATA[MSIL]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://gojisoft.com/?p=434</guid>
		<description><![CDATA[A lot of the development we’ve been doing here at GojiSoft has involved event driven component development. This four part article describes how we went about developing a generalized event testing framework to more easily write unit tests that codified event firing sequences. Part 1 Unit testing event sequences. Part 2 Developing an event monitor [...]]]></description>
				<content:encoded><![CDATA[<p>A lot of the development we’ve been doing here at <a href="http://gojisoft.com/" target="_blank">GojiSoft</a> has involved event driven component development. This four part article describes how we went about developing a generalized event testing framework to more easily write unit tests that codified event firing sequences.</p>
<p> <span id="more-434"></span>
</p>
<ul>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-1/" target="_blank">Part 1</a> Unit testing event sequences. </li>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-2/" target="_blank">Part 2</a> Developing an event monitor to test an object’s events. </li>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-3/" target="_blank">Part 3</a> Using Reflection and MSIL (Intermediate Language) to implement a generic event monitor. </li>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-4/" target="_blank">Part 4</a> Reflection and MSIL code for dynamic event subscription in detail. </li>
<li><a href="http://gojisoft.com/blog/2010/04/27/event-sequence-unit-testing-conclusion/" target="_blank">Conclusion</a> Using the EventMonitor to write [Test]s. </li>
</ul>
<p align="center"><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/04/EventSequenceUnitTesting4.zip"></a></p>
<p align="center"><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/04/EventSequenceUnitTesting4.zip">Download Source Code</a></p>
</p>
<hr />
<h3>Part 3</h3>
<p>In <a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-2/" target="_blank">Part 2</a> of this series we saw how an event monitor (a test harness) could test event firing sequences for a specific type. This removed repetitive boilerplate code from unit tests and allowed the test specifics to be concentrated on. Great, but we were stuck with strong coupling between the event monitor and the specific event publishing type. What we wanted was a way of generalizing the event monitor so that it could be re-usable across different types without having to maintain convoluted inheritance schemes. We wanted something that would just work.</p>
<p>To generalize the pattern, hard-coding of event subscriptions in the event monitor needs to be removed. Instead, we need to dynamically subscribe a standard event handler to all of a type’s events and also need to know which event has been raised (via the event’s name). To accomplish this a combination of Reflection and IL was used.</p>
<p>The key steps in implementing dynamic event subscription in the event monitor were:</p>
<ol>
<li>
<div>Discover all the events of a type.</div>
</li>
<li>
<div>Create a proxy event handler for each discovered event which proxies to the real event handler. </div>
</li>
<li>
<div>Allow the injection of an event name into the proxy call for asserting event firing in tests.</div>
</li>
<li>
<div>Wrap the whole thing up in a delegate that can be subscribed to an event, and which points to our real event handler.</div>
</li>
</ol>
<p>The above steps give us a dynamic proxy that we can use in our event monitor to glue a target type’s event to our real event handler:</p>
<p align="center"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Dynamic event proxy pattern" border="0" alt="Dynamic event proxy pattern" src="http://gojisoft.com/_blog/wp-content/uploads/2010/04/DynamicEventProxy.png" width="453" height="362" /> Dynamic event proxy pattern as used in the EventMonitor class.</p>
<p>The dynamic event proxy gives us an interface that is compatible with the event we wish to subscribe to, and an interface that is compatible with the real event handler in our event monitor. The interfaces are compatible, plus we have injected the event’s name.</p>
<p>Below we can see how the dynamic event subscription code now looks in EventMonitor, rather than the hard-coded subscription we had in <a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-2/" target="_blank">Part 2</a>. Straightforward Reflection is used to discover event information, and the DynamicEvent class (discussed in <a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-4/" target="_blank">Part 4</a>) is used to create a dynamic event proxy. Finally, the event proxy is subscribed to the event using reflection.</p>
<pre class="brush: csharp;">private void SubscribeToEvents() 
{ 
    //Use reflection to get all the events in the event publisher 
    foreach (EventInfo eventInfo in _eventPublisher.GetType().GetEvents()) 
    { 
        //Create a proxy event handler for the event 
        Delegate proxyEventHandler = DynamicEvent.CreateProxyEventHandler( 
            eventInfo, _eventPublisher, EventHandler); 

        //Use reflection to subscribe our proxy event handler 
        eventInfo.GetAddMethod().Invoke(_eventPublisher, new[] { proxyEventHandler }); 
    } 
} 

private void EventHandler(object sender, EventArgs e, string eventName) 
{ 
    //The event has been raised, and we have the event name. 
    //Do some test asserting... 
}</pre>
<p align="center">Excerpt from EventMonitor.cs</p>
<p align="left">We can now test asynchronous event patterns for arbitrary event publishing types with the event monitor as follows:</p>
<pre class="brush: csharp; ">Action test = () =&gt; { /*Code to change publisher twice, then delete it. */ } }; 

var eventSequence = new[] { &quot;Changed&quot;, &quot;Changed&quot;, &quot;Deleted&quot; }; 

EventMonitor.Assert(test, publisher, eventSequence, TimeoutMS);</pre>
<p>Reflection and IL code used to create the dynamic event proxy in class DynamicEvent is discussed in detail in the last part of this series:</p>
<p align="center"><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-4/" target="_blank">Event Sequence Unit Testing – Part 4</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=Jycs1xg4mFc:YHbj4jr4Sv0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=Jycs1xg4mFc:YHbj4jr4Sv0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=Jycs1xg4mFc:YHbj4jr4Sv0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=Jycs1xg4mFc:YHbj4jr4Sv0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=Jycs1xg4mFc:YHbj4jr4Sv0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=Jycs1xg4mFc:YHbj4jr4Sv0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/gojisoftblog/~4/Jycs1xg4mFc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-3/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=event-sequence-unit-testing-part-3</feedburner:origLink></item>
		<item>
		<title>Event Sequence Unit Testing – Part 2</title>
		<link>http://feedproxy.google.com/~r/gojisoftblog/~3/IidqpK-7ynw/</link>
		<comments>http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-2/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 16:05:00 +0000</pubDate>
		<dc:creator>Tim Lloyd</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IL]]></category>
		<category><![CDATA[MSIL]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://gojisoft.com/?p=362</guid>
		<description><![CDATA[A lot of the development we’ve been doing here at GojiSoft has involved event driven component development. This four part article describes how we went about developing a generalized event testing framework to more easily write unit tests that codified event firing sequences. Part 1 Unit testing event sequences. Part 2 Developing an event monitor [...]]]></description>
				<content:encoded><![CDATA[<p>A lot of the development we’ve been doing here at <a href="http://gojisoft.com/" target="_blank">GojiSoft</a> has involved event driven component development. This four part article describes how we went about developing a generalized event testing framework to more easily write unit tests that codified event firing sequences.</p>
<p> <span id="more-362"></span>
</p>
<ul>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-1/" target="_blank">Part 1</a> Unit testing event sequences. </li>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-2/" target="_blank">Part 2</a> Developing an event monitor to test an object’s events. </li>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-3/" target="_blank">Part 3</a> Using Reflection and MSIL (Intermediate Language) to implement a generic event monitor. </li>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-4/" target="_blank">Part 4</a> Reflection and MSIL code for dynamic event subscription in detail. </li>
<li><a href="http://gojisoft.com/blog/2010/04/27/event-sequence-unit-testing-conclusion/" target="_blank">Conclusion</a> Using the EventMonitor to write [Test]s. </li>
</ul>
<p align="center"><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/04/EventSequenceUnitTesting4.zip"></a></p>
<p align="center"><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/04/EventSequenceUnitTesting4.zip">Download Source Code</a></p>
</p>
<hr />
<h3>Part 2</h3>
<p>In <a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-1/" target="_blank">Part 1</a> of this series we explored unit testing event sequences, both synchronous and asynchronous. We saw that it involved writing a lot of repetitive boilerplate test code:</p>
<pre class="brush: csharp;">using (FileWatcher fileWatcher = new FileWatcher(fileToMonitor))
using (AutoResetEvent changedEvent = new AutoResetEvent(false))
using (AutoResetEvent renamedEvent = new AutoResetEvent(false))
using (AutoResetEvent deletedEvent = new AutoResetEvent(false))
{
    fileWatcher.Changed += delegate { changedEvent.Set(); };
    fileWatcher.Renamed += delegate { renamedEvent.Set(); };
    fileWatcher.Deleted += delegate { deletedEvent.Set(); };

    //Do some stuff to the file...
    
    //  * Change the file.
    Synchronization.WaitWithTimeout(changedEvent, TimeoutMS, &quot;Changed event failed.&quot;);

    //  * Rename the file.
    Synchronization.WaitWithTimeout(renamedEvent, TimeoutMS, &quot;Renamed event failed.&quot;);

    //  * Delete the file.
    Synchronization.WaitWithTimeout(deletedEvent, TimeoutMS, &quot;Deleted event failed.&quot;);
}</pre>
<p>When you’re writing a lot of unit tests, this really starts to grind. What we are really interested in when writing these tests is:</p>
<ul>
<li>“Do some stuff to the state of x.” </li>
<li>Defining an expected sequence of events. </li>
<li>Having something else take care of running and asserting the event sequence. </li>
</ul>
<p>To cut down on repetitive code and give flexibility for implementing features such as reporting test failure with helpful diagnostic messages, <a href="http://gojisoft.com/blog/author/frederik/" target="_blank">Frederik</a> began writing an event monitoring test harness for his FileWatcher component. The event monitor handled event hooking and synchronization, plus asserting the expected event sequence. This enabled developing unit tests that concentrated on “Do some stuff to the state of x.”. Unit testing with an event monitor looks like this:</p>
<pre class="brush: csharp;">Action action = () =&gt; { /* Code to create a file, then change it. */ }; 

var expectedSequence = new List&lt;EventName&gt; { EventName.Created, EventName.Changed }; 

using (var monitor = new EventMonitor(file, TimeoutMS, expectedSequence)) 
{ 
    monitor.Start(action); 
}</pre>
<p>In the unit test pattern above we can see the code that makes the state changes is defined in: action<strong>,</strong> and the expected event sequence is defined in: expectedSequence. These are used in conjunction with the EventMonitor which:</p>
<ol>
<li>Constructs an instance of the component to be tested: a FileWatcher. </li>
<li>Subscribes to its events so that it is notified when events are raised. </li>
<li>Executes the state changing code (defined in: action). </li>
<li>Asserts that the raised event sequence (subscribed to in 2) is adhered to. </li>
<li>Prints a helpful diagnostic message if the test fails, e.g. </li>
</ol>
<p><em>&#160;&#160;&#160;&#160; GojiSoft.TestFramework.Events.EventMonitoringException: Out of order execution at event 2.</em></p>
<p><em>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Expected sequence&#160; - (start) (1)Changed (2)Renamed (3)Deleted</em></p>
<p><em>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Actual sequence&#160;&#160;&#160;&#160;&#160; - (start) (1)Changed (2)Changed.</em></p>
<p>As I was also writing asynchronous event raising components, and had the same sort of boilerplate unit test code, I liked the look of this pattern a lot. However, the implementation required writing a specialized monitor for each component as event subscriptions had to be hard-coded within the monitor:</p>
<pre class="brush: csharp;">private void AssignEvents() 
{ 
    _fileWatcher.Changed += ((sender, args) =&gt; 
    { 
        //Handle event... 
    }); 

    _fileWatcher.Deleted += ((sender, args) =&gt; 
    { 
        //Handle event... 
    }); 

    //etc, etc… 
}</pre>
<p align="center">Code excerpt from EventMonitor.cs</p>
<p>As we can see from the above code snippet, the EventMonitor directly subscribes to the FileWatcher component events – it is hard-coded. I liked the overall technique and wanted to use it with my components, so I looked at generalizing it to provide an event monitor that could monitor the events of any type.</p>
<p>Generalizing the event monitor required the use of Reflection and IL (Intermediate Language). This is the subject of the next part in the series:</p>
<p align="center"><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-3/" target="_blank">Event Sequence Unit Testing – Part 3</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=IidqpK-7ynw:QlZABM6R5mo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=IidqpK-7ynw:QlZABM6R5mo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=IidqpK-7ynw:QlZABM6R5mo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=IidqpK-7ynw:QlZABM6R5mo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=IidqpK-7ynw:QlZABM6R5mo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=IidqpK-7ynw:QlZABM6R5mo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/gojisoftblog/~4/IidqpK-7ynw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=event-sequence-unit-testing-part-2</feedburner:origLink></item>
		<item>
		<title>Event Sequence Unit Testing – Part 1</title>
		<link>http://feedproxy.google.com/~r/gojisoftblog/~3/HZM-Itvzyac/</link>
		<comments>http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-1/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 16:04:00 +0000</pubDate>
		<dc:creator>Tim Lloyd</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IL]]></category>
		<category><![CDATA[MSIL]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://gojisoft.com/?p=363</guid>
		<description><![CDATA[A lot of the development we’ve been doing here at GojiSoft has involved event driven component development.&#160; We didn’t like the endless boiler plate unit test code that we had to write to unit test classes that raise events, so we came up with a few helper classes that make it effortless.&#160; A test now [...]]]></description>
				<content:encoded><![CDATA[<p>A lot of the development we’ve been doing here at <a href="http://gojisoft.com/" target="_blank">GojiSoft</a> has involved event driven component development.&nbsp; We didn’t like the endless boiler plate unit test code that we had to write to unit test classes that raise events, so we came up with <a href="http://gojisoft.com/_blog/wp-content/uploads/2010/04/EventSequenceUnitTesting4.zip" target="_blank">a few helper classes</a> that make it effortless.&nbsp; A test now looks like this:</p>
<pre class="brush: csharp;">[Test] 
public void TestEventRaisingSequence() 
{ 
      var myClass = new MyEventRaisingClass(); 
 
      Action test = () =&gt; { myClass.RaiseA(); myClass.RaiseB(); }; 

      var expectedSequence = new[] { "EventA", "EventB" }; 

      EventMonitor.Assert(test, myClass, expectedSequence); 
} 
</pre>
<p>The framework handles synchronous &amp; asynchronous event raising, as well as property change notification (INotifyPropertyChanged).</p>
<p><span id="more-363"></span></p>
<p align="center"><a href="http://gojisoft.com/_blog/wp-content/uploads/2010/04/EventSequenceUnitTesting4.zip">Download Source Code</a> – <a href="http://gojisoft.com/blog/2010/04/27/event-sequence-unit-testing-conclusion/">Documentation</a></p>
<p>This four part article describes how the framework works and how it evolved from boilerplate unit tests to a pain-free framework that generates IL on the fly.</p>
<ul>
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-1/" target="_blank">Part 1</a> Unit testing event sequences.
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-2/" target="_blank">Part 2</a> Developing an event monitor to test an object’s events.
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-3/" target="_blank">Part 3</a> Using Reflection and MSIL (Intermediate Language) to implement a generic event monitor.
<li><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-4/" target="_blank">Part 4</a> Reflection and MSIL code for dynamic event subscription in detail.
<li><a href="http://gojisoft.com/blog/2010/04/27/event-sequence-unit-testing-conclusion/" target="_blank">Conclusion</a> Using the EventMonitor to write [Test]s. </li>
</ul>
<hr />
<h3>Part 1</h3>
<p>An aspect of developing components that raise events is writing unit tests to codify expected event sequences e.g. when I change state s1 and then s2, I expect event e1 then event e2 to be raised. This style of testing helps to codify event firing expectations and then to keep those expectations locked down as the system evolves - classic unit testing goals.</p>
<p>Given a shortened example of an event publishing type EventPublisher:</p>
<pre class="brush: csharp;">public class EventPublisher
{
    public event EventHandler EventA, EventB;

    public void RaiseA()
    {
        EventA(this, EventArgs.Empty);
    }

    public void RaiseB()
    {
        EventB(this, EventArgs.Empty);
    }
}</pre>
<p>We can write unit tests against it as follows:</p>
<pre class="brush: csharp;">[Test]
public void EventSequenceTest()
{
    bool eventARaised, eventBRaised;

    eventARaised = eventBRaised = false;

    EventPublisher publisher = new EventPublisher();

    publisher.EventA += delegate { eventARaised = true; };
    publisher.EventB += delegate { eventBRaised = true; };

    //Do some stuff to the state of publisher.
    publisher.RaiseA();
    Assert.IsTrue(eventARaised, "Event A raised.");

    //Do some stuff to the state of publisher.
    publisher.RaiseB();    
    Assert.IsTrue(eventBRaised, "Event B raised.");
}</pre>
<p>Here we test that when we change state A followed by state B, event A and then event B is raised.</p>
<p>The implementation is a little different when we have a type that implements the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx" target="_blank">INotifyPropertyChanged</a> pattern:</p>
<pre class="brush: csharp;">public class PropertyChangedEventPublisher : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    private int a, b;

    public int A
    {        
        set
        {
            this.a = value;
            this.PropertyChanged(this, new PropertyChangedEventArgs("A"));
        }
    }

    public int B
    {
        set
        {
            this.b = value;
            this.PropertyChanged(this, new PropertyChangedEventArgs("B"));
        }
    }
}</pre>
<p>We can write unit tests against it as follows:</p>
<pre class="brush: csharp;">[Test]
public void EventSequenceTest()
{
    bool eventARaised, eventBRaised;

    eventARaised = eventBRaised = false;

    PropertyChangedEventPublisher publisher = new PropertyChangedEventPublisher();

    publisher.PropertyChanged += (sender, e) =&gt; 
    {
        if (e.PropertyName == "A")
        {
            eventARaised = true;
        }
        else if (e.PropertyName == "B")
        {
            eventBRaised = true;
        }
    };

    //Do some stuff to the state of publisher.
    publisher.A = 1;
    Assert.IsTrue(eventARaised, "Event A raised.");

    //Do some stuff to the state of publisher.
    publisher.B = 2;
    Assert.IsTrue(eventBRaised, "Event B raised.");
}</pre>
<p>Matters are further complicated when we have a type that raises events asynchronously i.e. on multiple threads:</p>
<pre class="brush: csharp;">public class AsyncEventPublisher
{
    public event EventHandler EventA, EventB;

    public void RaiseA()
    {
        ThreadPool.QueueUserWorkItem(delegate { EventA(this, EventArgs.Empty); });
    }

    public void RaiseB()
    {
        ThreadPool.QueueUserWorkItem(delegate { EventB(this, EventArgs.Empty); });
    }
}</pre>
<p>Our previous unit testing pattern no longer works as the test starts asserting the event raising conditions before our threads have raised the events. For the same test, but with asynchronous events, we need to introduce thread synchronization:</p>
<pre class="brush: csharp;">[Test]
public void AsyncEventSequenceTest()
{
    AsyncEventPublisher publisher = new AsyncEventPublisher();

    using (AutoResetEvent eventA = new AutoResetEvent(false))
    using (AutoResetEvent eventB = new AutoResetEvent(false))
    {
        publisher.EventA += delegate { eventA.Set(); };
        publisher.EventB += delegate { eventB.Set(); };

        //Do some stuff to the state of publisher.
        publisher.RaiseA();
        AssertEvent(eventA, 1000, "Event A failed.");

        //Do some stuff to the state of publisher.
        publisher.RaiseB();
        AssertEvent(eventB, 1000, "Event B failed.");
    }
}

private static void AssertEvent(WaitHandle waitHandle, int timeoutMS, string message)
{
    if (!waitHandle.WaitOne(timeoutMS))
    {
        message += " Timed out after waiting " + timeoutMS + "ms.";
        throw new TimeoutException(message);
    }
}</pre>
<p>In this variation of the test we use AutoResetEvents to synchronize our test thread with our event threads, thus ensuring that we wait for the event threads to execute. If events are not raised, then we timeout and an exception fails the test.</p>
<p>My partner in dev <a href="http://gojisoft.com/blog/author/frederik/" target="_blank">Frederik</a> was developing a file system monitoring component and found that we were both writing this sort of boilerplate unit testing code again and again. To simplify unit testing he started developing an event monitoring test harness which could be used to generalize event sequence testing for his component and reduce the boilerplate coding.</p>
<p>This series of posts will describe how a generic event monitor pattern can be used to allow much more straightforward unit tests of synchronous, asynchronous and INotifyPropertyChanged style events:</p>
<pre class="brush: csharp;">[Test]
public void EventTest()
{
    var publisher = new MyEventPublisher();

    Action test = () =&gt; { publisher.RaiseA(); publisher.RaiseB(); };

    var expectedSequence = new[] { "EventA", "EventB" };

    EventMonitor.Assert(test, publisher, expectedSequence);
}</pre>
<p align="left">Or:</p>
<pre class="brush: csharp;">[Test]
public void EventTest()
{
    var publisher = new MyPropertyChangedEventPublisher();

    Action test = () =&gt; { publisher.X = 1; publisher.Y = 2; };

    var expectedSequence = new[] { "X", "Y" };

    EventMonitor.Assert(test, publisher, expectedSequence);
}</pre>
<p align="center"><a href="http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-2/" target="_blank">Event Sequence Unit Testing – Part 2</a></p>
<pre></pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=HZM-Itvzyac:RSvYOZzaAyk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=HZM-Itvzyac:RSvYOZzaAyk:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=HZM-Itvzyac:RSvYOZzaAyk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=HZM-Itvzyac:RSvYOZzaAyk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?i=HZM-Itvzyac:RSvYOZzaAyk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/gojisoftblog?a=HZM-Itvzyac:RSvYOZzaAyk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/gojisoftblog?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/gojisoftblog/~4/HZM-Itvzyac" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gojisoft.com/blog/2010/04/22/event-sequence-unit-testing-part-1/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=event-sequence-unit-testing-part-1</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.257 seconds. --><!-- Cached page generated by WP-Super-Cache on 2013-06-15 15:19:18 --><!-- Compression = gzip -->
