<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>21apps &#187; TypeMock</title>
	<atom:link href="http://www.21apps.com/tag/typemock/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.21apps.com</link>
	<description>Inspiring people to change the way they work</description>
	<lastBuildDate>Sun, 05 Feb 2012 17:23:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Interviewed by Typemock</title>
		<link>http://www.21apps.com/sharepoint/interviewed-by-typemock/</link>
		<comments>http://www.21apps.com/sharepoint/interviewed-by-typemock/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 12:52:36 +0000</pubDate>
		<dc:creator>Andrew Woodward</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[TypeMock]]></category>

		<guid isPermaLink="false">http://www.21apps.com/sharepoint/interviewed-by-typemock/</guid>
		<description><![CDATA[At the recent SharePoint Conference in Vegas I took a few minutes out to talk to Gil Zilberfeld of Typemock about what 21apps is doing with SharePoint and what I see as the next steps in the community regarding SharePoint &#8230; <a href="http://www.21apps.com/sharepoint/interviewed-by-typemock/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At the recent <a href="http://www.21apps.com/sharepoint/spc09-is-go-conference-keynote/" target="_blank">SharePoint Conference</a> in Vegas I took a few minutes out to talk to Gil Zilberfeld of <a href="http://learn.typemock.com" target="_blank">Typemock</a> about what 21apps is doing with SharePoint and what I see as the next steps in the community regarding SharePoint development.</p>
<p> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="437" height="389" id="viddler"><param name="movie" value="http://www.viddler.com/player/8e5d1ac5/" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src="http://www.viddler.com/player/8e5d1ac5/" width="437" height="389" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" name="viddler"></embed></object>
<p>Looking at what areas I see as being a focus in the SharePoint development space,&#160; how I will continue to push TDD but will also, now that people are starting to talk about good SharePoint development practices, start to look at the wide picture &#8211; looking at how we complement the Unit Tests with integration tests,&#160; looking at ways to automate use acceptance tests and generally looking at ways to make the code better so that testers can focus on the scenarios and complex tests rather than dealing with the &#8216;stupid bugs&#8217;.</p>
<p>Original post on <a href="http://learn.typemock.com/andrew-woodward-on-unit-testin/" target="_blank">Typemock Blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.21apps.com/sharepoint/interviewed-by-typemock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Small steps for testing, big steps for SharePoint testing</title>
		<link>http://www.21apps.com/sharepoint/small-steps-big-steps-for-sharepoint-testing/</link>
		<comments>http://www.21apps.com/sharepoint/small-steps-big-steps-for-sharepoint-testing/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 08:55:17 +0000</pubDate>
		<dc:creator>Andrew Woodward</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[TypeMock]]></category>

		<guid isPermaLink="false">http://www.21apps.com/?p=977</guid>
		<description><![CDATA[Following on from my rant response yesterday about the more negative views from the SharePoint community my reading this morning was so much more positive. Unit Testing Workflows In my response to a question from Aaron Weiker I said that &#8230; <a href="http://www.21apps.com/sharepoint/small-steps-big-steps-for-sharepoint-testing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Following on from my <span style="text-decoration: line-through;">rant</span> <a href="http://www.21apps.com/sharepoint/tdd-and-sharepoint-is-it-worth-doing/">response</a> yesterday about the more negative views from the SharePoint community my <a href="http://blog.typemock.com/2009/06/problem-solving-with-isolator.html" target="_blank">reading</a> this morning was so much more positive.</p>
<h3>Unit Testing Workflows</h3>
<p>In my response to a question from <a href="http://www.21apps.com/sharepoint/tdd-and-sharepoint-is-it-worth-doing/#disqus_thread">Aaron Weiker</a> I said that I would like to see much more guidance and investigation into the way we approach Unit Testing workflows in SharePoint,  so it was great to find Richard Fennell is doing a lot of work in this area.  I have been working with Typemock Isolator, CThru and SilverUnit testing recently (post coming) and was very interested to see that Richard had <a href="http://blogs.blackmarble.co.uk/blogs/rfennell/archive/2009/06/22/logging-everything-that-is-going-on-when-an-assembly-loads-using-cthru.aspx" target="_blank">picked up this</a> whilst looking for a <a href="http://blogs.blackmarble.co.uk/blogs/rfennell/archive/2009/04/07/testing-sharepoint-workflows-using-typemock-isolator-part-3.aspx" target="_blank">possible solution to the challenges</a> of Unit Testing SharePoint workflows; something I have to confess I had not even considered.</p>
<p>I&#8217;m looking forward to seeing where Richard gets with this and also the use of <a href="http://blogs.blackmarble.co.uk/blogs/rfennell/archive/2008/10/04/running-fitness-net-tests-in-unit-test-some-tips.aspx" target="_blank">Fit/Fitness</a>, although I&#8217;m personally not a big fan of the way tables are used to define the tests.</p>
<h3>Integration Testing SharePoint from MSTest</h3>
<p>Having been a bit behind with my reviews of the latest <a href="http://spg.codeplex.com/" target="_blank">Codeplex P&amp;P</a> project I missed the discussion with Francis on how they found a use for <a href="http://blogs.msdn.com/francischeung/archive/2009/06/24/using-typemock-isolator-for-integration-tests.aspx" target="_blank">Typemock Isolator to do Integration tests</a>.</p>
<p>The code is really very very simple,  many will be glad to hear, and deals with the places where your code makes a call to SPContext.Current or SPFarm.Local.</p>
<p>The simple ideas really are the best ones.</p>
<p>As you can see,  a few small steps for testing but big steps for SharePoint testing and a demonstration that in general the SharePoint community is committed to improving the way solutions are developed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.21apps.com/sharepoint/small-steps-big-steps-for-sharepoint-testing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Typemock ASP.Net Bundle &#8211; get a free license</title>
		<link>http://www.21apps.com/testing/typemock-aspnet-get-a-free-license/</link>
		<comments>http://www.21apps.com/testing/typemock-aspnet-get-a-free-license/#comments</comments>
		<pubDate>Tue, 19 May 2009 12:25:18 +0000</pubDate>
		<dc:creator>Andrew Woodward</dc:creator>
				<category><![CDATA[Testing]]></category>
		<category><![CDATA[TypeMock]]></category>

		<guid isPermaLink="false">http://www.21apps.com/?p=954</guid>
		<description><![CDATA[One of my favourite tools Typemock has just been released in a fantastic ASP.Net bundle and have once again offered this up to the blogging community to get for free. Unit Testing ASP.NET? ASP.NET unit testing has never been this &#8230; <a href="http://www.21apps.com/testing/typemock-aspnet-get-a-free-license/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of my favourite tools Typemock has just been released in a fantastic ASP.Net bundle and have once again offered this up to the blogging community to get for free.</p>
<p><a href="http://www.typemock.com/">Unit Testing</a> ASP.NET? <a href="http://www.typemock.com/ASP.NET_unit_testing_page.php">ASP.NET unit testing</a> has never been this easy.<br />
Typemock is launching a new product for ASP.NET developers &#8211; the <strong>ASP.NET Bundle</strong> &#8211; and for the launch will be giving out <strong>FREE licenses</strong> to bloggers and their readers.<br />
The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both <a href="http://www.typemock.com/">Typemock Isolator</a>, a <a href="http://www.typemock.com/">unit test</a> tool and <a href="http://sm-art.biz/Ivonna.aspx">Ivonna</a>, the Isolator add-on for <a href="http://sm-art.biz/Ivonna.aspx">ASP.NET unit testing</a>, for a bargain price.<br />
Typemock Isolator is a leading <a href="http://www.typemock.com/">.NET unit testing</a> tool (C# and VB.NET) for many &#8216;hard to test&#8217; technologies such as <a href="http://typemock.com/sharepointpage.php">SharePoint</a>, <a href="http://www.typemock.com/ASP.NET_unit_testing_page.php">ASP.NET</a>, <a href="http://www.typemock.com/ASP.NET_unit_testing_page.php">MVC</a>, <a href="http://www.typemock.com/wcfpage.php">WCF</a>, WPF, <a href="http://www.typemock.com/Silverlight_unit_testing_page.php">Silverlight</a> and more. Note that for <a href="http://www.typemock.com/Silverlight_unit_testing_page.php">unit testing Silverlight</a> there is an open source Isolator add-on called <a href="http://www.typemock.com/Silverlight_unit_testing_page.php">SilverUnit</a>.<br />
The first 60 bloggers who will blog this text in their blog and <a href="http://blog.typemock.com/2009/05/get-free-typemock-licenses-aspnet.html">tell us about it</a>, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET <strong>dedicated</strong> blog, you&#8217;ll get a license automatically (even if more than 60 submit) during the first week of this announcement.<br />
Also 8 bloggers will get an <strong>additional 2 licenses</strong> (each) to give away to their readers / friends.<br />
Go ahead, click the following link for <a href="http://blog.typemock.com/2009/05/get-free-typemock-licenses-aspnet.html">more information </a>on how to get your free license.</p>
<p>I&#8217;ve not had the chance to try out the Ivonna or SilverUnit add-ons to the framework yet, but will be looking at these in the near future and they can help you test more of your SharePoint solutions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.21apps.com/testing/typemock-aspnet-get-a-free-license/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>More great Unit Testing SharePoint Examples</title>
		<link>http://www.21apps.com/sharepoint/unit-testing-sharepoint-examples/</link>
		<comments>http://www.21apps.com/sharepoint/unit-testing-sharepoint-examples/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 12:21:31 +0000</pubDate>
		<dc:creator>Andrew Woodward</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[TypeMock]]></category>

		<guid isPermaLink="false">http://www.21apps.com/?p=927</guid>
		<description><![CDATA[Great to see that more people are publishing their experiences with unit testing SharePoint.   Here are some of examples I have found that are really worth looking at: Richard Fennell &#8211; Testing SharePoint Workflows using TypeMock Isolator (part 1, part &#8230; <a href="http://www.21apps.com/sharepoint/unit-testing-sharepoint-examples/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Great to see that more people are publishing their experiences with unit testing SharePoint.   Here are some of examples I have found that are really worth looking at:</p>
<blockquote><p>Richard Fennell &#8211; Testing SharePoint Workflows using TypeMock Isolator (<a href="http://blogs.blackmarble.co.uk/blogs/rfennell/archive/2009/04/03/testing-sharepoint-workflows-using-typemock-isolator.aspx" target="_blank">part 1</a>, <a href="http://blogs.blackmarble.co.uk/blogs/rfennell/archive/2009/04/06/testing-sharepoint-workflows-using-typemock-isolator-part-2.aspx" target="_blank">part 2</a> and <a href="http://blogs.blackmarble.co.uk/blogs/rfennell/archive/2009/04/07/testing-sharepoint-workflows-using-typemock-isolator-part-3.aspx" target="_blank">part 3</a>) &#8211; Richard is also going to be talking at a few <a href="http://www.nxtgenug.net/ViewEvent.aspx?EventID=216" target="_blank">NextGen</a> meetings on the subject.</p></blockquote>
<blockquote><p>SharePoint Dev Wiki is really starting to get some good content not just on <a href="http://www.sharepointdevwiki.com/display/public/SharePoint%20Development%20with%20Unit%20Testing" target="_blank">unit testing</a> but on the whole development field.</p></blockquote>
<blockquote><p>Jeremy Thake (creator of SharePoint Dev Wiki) did a great usergroup meeting web cast on <a href="http://wss.made4the.net/archive/2009/03/25/sharepoint-development-with-unit-testing-webcast.aspx" target="_blank">SharePoint Development with Unit Testing</a></p></blockquote>
<blockquote><p>I&#8217;ve previously mentioned the <a href="http://msdn.microsoft.com/en-us/library/dd206923.aspx" target="_blank">Patterns and Practices</a> work and they have started to do some great <a href="http://channel9.msdn.com/posts/akMSFT/pp-SharePoint-Development-Guidance-v2-Whats-in-Drop-7/" target="_blank">Channel 9 videos</a> which really do make this so much more accessible.  Brilliant Job!</p></blockquote>
<p>If you have any links or posts on the subject please share by adding a link in the comments, and if you&#8217;ve done something new and exciting help the SharePoint Dev Wiki by posting details.</p>
<p>Looks like my predictions are starting to come true,  people really are doing SharePoint development better <img src='http://www.21apps.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.21apps.com/sharepoint/unit-testing-sharepoint-examples/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Best Practices: Test Driven Development with SharePoint Slide Deck</title>
		<link>http://www.21apps.com/sharepoint/tdd-at-spbpc-slidedeck/</link>
		<comments>http://www.21apps.com/sharepoint/tdd-at-spbpc-slidedeck/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 01:12:10 +0000</pubDate>
		<dc:creator>Andrew Woodward</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[TypeMock]]></category>

		<guid isPermaLink="false">http://www.21apps.com/?p=802</guid>
		<description><![CDATA[In contrast to the Agile SharePoint development with Scrum session this was very light on the slides.  In good Agile tradition I adopted a Pair Programming approach with me at the keyboard and the audience been my code buddy.  Everyone &#8230; <a href="http://www.21apps.com/sharepoint/tdd-at-spbpc-slidedeck/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In contrast to the <a href="/sharepoint/agile-development-with-scrum/">Agile SharePoint development with Scrum</a> session this was very light on the slides.  In good Agile tradition I adopted a Pair Programming approach with me at the keyboard and the audience been my code buddy.  Everyone was provided with a copy of Uncle Bobs <a href="http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd" target="_blank">Three rules of TDD</a> to help with during the pairing process.  The rules state:</p>
<ol>
<li>You are not allowed to write any production code unless it is to make a failing unit test pass.</li>
<li>You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.</li>
<li>You are not allowed to write any more production code than is sufficient to pass the one failing unit test.</li>
</ol>
<p>I did have some slides to set the scene (see below), to give some background to TDD and raise the issues around the use of the word TEST.  We also looked at <a href="http://www.blueskyonmars.com/2004/03/19/top-ten-reasons-that-tdd-sucks/" target="_blank">10 reasons TDD sucks</a>, with a slight SharePoint slant,  and quickly got into Visual Studio where the real learning was to happen.</p>
<p>The user story was to develop a Magic 8 Ball web part that could have custom answers defined in a SharePoint list.  The finished code is available on <a href="http://www.codeplex.com/SP8Ball" target="_blank">CodePlex</a> and it is planned to extend this solution over time to expand on the ideas.  My main issue with just getting the finished code is the learning is in the process and it can be hard to see how the design was driven by the code.   I am planning to do a web cast on this to show this process.</p>
<blockquote><p>CodePlex project now available  <a href="http://www.codeplex.com/sp8ball">http://www.codeplex.com/sp8ball</a></p></blockquote>
<h3>Winners</h3>
<p>The guys at <a href="http://www.typemock.com/" target="_blank">Typemock</a> we very generous in donating 3 copies of <a href="http://www.typemock.com/sharepointpage.php" target="_blank">Isolator for SharePoint</a> which is an essential component for anyone doing unit testing in a SharePoint environment.  The lucky winners were</p>
<p>Mark Freeman<br />
Shahar Tamari<br />
Kennedy Duncan</p>
<p>Each of you will receive a free license for Isolator for SharePoint,  for those that did not win Typemock are running a special discount.</p>
<div id="__ss_1009982" style="text-align: left; width: 425px;"><a style="margin: 12px 0px 3px; display: block; font: 14px helvetica,arial,sans-serif; text-decoration: underline" title="Test Driven Development with SharePoint" href="http://www.slideshare.net/AndrewWoody/test-driven-development-with-sharepoint?type=powerpoint">Test Driven Development with SharePoint</a><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=woodwarddev371testdrivensharepointdevelopment-1234227656983258-2&amp;stripped_title=test-driven-development-with-sharepoint" /><embed type="application/x-shockwave-flash" width="425" height="355" src="http://static.slideshare.net/swf/ssplayer2.swf?doc=woodwarddev371testdrivensharepointdevelopment-1234227656983258-2&amp;stripped_title=test-driven-development-with-sharepoint" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<div style="font-family: tahoma,arial; height: 26px; font-size: 11px; padding-top: 2px;">View more <a style="text-decoration: underline" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration: underline" href="http://www.slideshare.net/AndrewWoody">Andrew Woodward</a>. (tags: <a style="text-decoration: underline" href="http://slideshare.net/tag/tdd">tdd</a> <a style="text-decoration: underline" href="http://slideshare.net/tag/sharepoint">sharepoint</a>)</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.21apps.com/sharepoint/tdd-at-spbpc-slidedeck/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>TDD Using Dependency Injection &#8211; Step 1. Refactoring</title>
		<link>http://www.21apps.com/sharepoint/tdd-with-di-step1/</link>
		<comments>http://www.21apps.com/sharepoint/tdd-with-di-step1/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 11:45:53 +0000</pubDate>
		<dc:creator>Andrew Woodward</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[TypeMock]]></category>

		<guid isPermaLink="false">http://www.21apps.com/?p=737</guid>
		<description><![CDATA[This post is part of a series on Test Driven Development &#8211; Using Dependency Injection We introduced some terms previously to help describe some of the things we need to do in order to make our code more testable.  In &#8230; <a href="http://www.21apps.com/sharepoint/tdd-with-di-step1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<blockquote><p>This post is part of a series on <a href="http://www.21apps.com/sharepoint/tdd-using-di/">Test Driven Development &#8211; Using Dependency Injection</a></p></blockquote>
<p>We introduced some terms <a href="http://www.21apps.com/sharepoint/tdd-with-di-vocabulary/">previously</a> to help describe some of the things we need to do in order to make our code more testable.  In this step we are going to start the refactor to  support Dependency Injection in the RandomMessage class.</p>
<p>The code that is causing us a problem when using <a href="http://www.typemock.com/sharepointpage.php">Isolator for SharePoint</a> is in the GetRandomMessage method.</p>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span> GetRandomMessage(<span style="color: #0000ff;">string</span> WebUrl)</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        {</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            <span style="color: #0000ff;">string</span> message = "";</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            <span style="color: #0000ff;">try</span></pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            {</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">                <span style="color: #0000ff;">using</span> (SPSite site = <span style="color: #0000ff;">new</span> SPSite(WebUrl))</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">                {</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">                    <span style="color: #0000ff;">using</span> (SPWeb web = site.OpenWeb())</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">                    {</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">                        SPList messages = web.Lists["<span style="color: #8b0000;">Messages</span>"];</pre>
<pre style="margin: 0em; background-color: #ffff00; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">                        <span style="color: #0000ff;">int</span> rndMessage = GetRandomNumber(messages.ItemCount);</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">                        message = messages.Items[rndMessage].Title;</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">                    }</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">                }</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            }</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"><span style="color: #008000;">//*... snipped for brevity ...*//
</span></pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        }</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    }</pre>
<p>What we need to do is use Dependency Inversion, that is we want to allow our calling code to decide what is used to get the random number.  To achieve this we need to create an interface for a class that we will allow us set define the way get our random number.</p>
<p>Visual Studio was really designed with agile developers in mind.   In order to achieve our refactoring we can do the following.</p>
<p>Highlight the method GetRandomNumber, right click on the code and choose Refactor.  Should see something similar to the image below</p>
<p><a href="http://www.21apps.com/wp-content/uploads/2009/01/image.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.21apps.com/wp-content/uploads/2009/01/image-thumb.png" border="0" alt="image" width="644" height="295" /></a></p>
<p>Choose the Extract Interface option which will provide you with a dialog to define the new interface name (IRandomNumber), the .cs file and also the methods that will be extracted.</p>
<p><a href="http://www.21apps.com/wp-content/uploads/2009/01/image1.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.21apps.com/wp-content/uploads/2009/01/image-thumb1.png" border="0" alt="image" width="405" height="336" /></a></p>
<p>Click OK and Visual Studio will do some of the work for us.  It does not however do everything so we will continue to fix up the code.</p>
<p>1. In the newly created IRandomNumber.cs files make the interface Public</p>
<p>As we are doing TDD we need to review our tests as the ones for the GetRandonNumber method will now be against a new object.  You may want to split out the tests into another class or .cs file but for now we will just refactor the tests that will change.</p>
<p>The tests should look something like below,  the code won&#8217;t at this point compile as we don&#8217;t yet have this class.</p>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        [Test]</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> GetRandomNumber_PostiveRange_ReturnValueInRange()</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        {</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            ObjectModel.RandomNumber randomNumber = <span style="color: #0000ff;">new</span> ObjectModel.RandomNumber();</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            <span style="color: #0000ff;">int</span> messageId = randomNumber.GetRandomNumber(1);</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            Assert.AreEqual(0,messageId);</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        }</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        [Test, ExpectedException(<span style="color: #0000ff;">typeof</span>(ArgumentOutOfRangeException))]</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> GetRandomNumber_Zero_ThrowException()</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        {</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            ObjectModel.RandomNumber randomNumber = <span style="color: #0000ff;">new</span> ObjectModel.RandomNumber();</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            <span style="color: #0000ff;">int</span> messageId = randomNumber.GetRandomNumber(0);</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        }</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        [Test, ExpectedException(<span style="color: #0000ff;">typeof</span>(ArgumentOutOfRangeException))]</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> GetRandomNumber_Negative_ThrowException()</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        {</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            ObjectModel.RandomNumber randomNumber = <span style="color: #0000ff;">new</span> ObjectModel.RandomNumber();</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            <span style="color: #0000ff;">int</span> messageId = randomNumber.GetRandomNumber(-1);</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        }</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        [Test]</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> GetRandomNumber_MaxValue_ReturnValueInRange()</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        {</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            ObjectModel.RandomNumber randomNumber = <span style="color: #0000ff;">new</span> ObjectModel.RandomNumber();</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            <span style="color: #0000ff;">int</span> messageId = randomNumber.GetRandomNumber(<span style="color: #0000ff;">int</span>.MaxValue);</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            Assert.GreaterOrEqual(messageId, 0);</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            Assert.LessOrEqual(messageId, <span style="color: #0000ff;">int</span>.MaxValue);</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        }</pre>
<p>Add a new class to the UnitTest.ObjectModel project called RandomNumber.  Make this class public and implement the interface IRandomNumber.  Next we need to remove the code from the RandomMessage class.   This involves removing the implementation of the IRandomNumber interface that Visual Studio added and also moving the GetRandomNumber code into our new class which should look similar to the code below.</p>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"><span style="color: #0000ff;">using</span> System;</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"><span style="color: #0000ff;">using</span> System.Collections.Generic;</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"><span style="color: #0000ff;">using</span> System.Linq;</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"><span style="color: #0000ff;">using</span> System.Text;</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"><span style="color: #0000ff;">namespace</span> UnitTest.ObjectModel</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">{</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> RandomNumber : IRandomNumber</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    {</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">int</span> GetRandomNumber(<span style="color: #0000ff;">int</span> max)</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        {</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            <span style="color: #0000ff;">if</span> (max &lt; 1)</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">                <span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">new</span> ArgumentOutOfRangeException(</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">                    "<span style="color: #8b0000;">max</span>", max, "<span style="color: #8b0000;">Maximum value must be greater than or equal to 1</span>");</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            Random rnd = <span style="color: #0000ff;">new</span> Random();</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">            <span style="color: #0000ff;">return</span> rnd.Next(max);</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">        }</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    }</pre>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">}</pre>
<p>At the moment our code will be in a state of flux,  it still won&#8217;t compile as the GetRandomMessage method needs to be updated,  we will add a new instance of the RandomNumber class and call this method on this.  We&#8217;re not doing the dependency injection just yet.</p>
<p>Once this change is implemented we should be able to compile the UnitTest.ObjectModel project.   To compile the tests we need to comment out the call we make to mock out this method (this was the method that caused us issues testing with Isolator for SharePoint).</p>
<p>In the method GetRandomMessage_MultipleMessages_ReturnMessage comment out the line</p>
<pre style="margin: 0em; background-color: #ffffff; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"><span style="color: #008000;">//Isolate.WhenCalled(() =&gt; message.GetRandomNumber(1000)).WillReturn(99);</span></pre>
<p>Our solution should now compile and running the tests all except the one above should pass.</p>
<p>A quick recap shows that we have refactored our solution, extracting the RandonNumber method into it&#8217;s own class based on an interface and run all the tests to show the code works as expected.   This is one of the big values of doing TDD,  we can make some major refactors in our code and know when we&#8217;re complete because the tests pass.</p>
<p>In the next next step we are going to use the IRandomNumber interface to implement Dependency Injection.</p>
<p><a href="http://www.21apps.com/sharepoint/tdd-with-di-step2">Step 2. Implementing dependency injection into GetRandomMessage</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.21apps.com/sharepoint/tdd-with-di-step1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TDD in SharePoint &#8211; Using Dependency Injection</title>
		<link>http://www.21apps.com/sharepoint/tdd-using-di/</link>
		<comments>http://www.21apps.com/sharepoint/tdd-using-di/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 23:02:18 +0000</pubDate>
		<dc:creator>Andrew Woodward</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[TypeMock]]></category>

		<guid isPermaLink="false">http://www.21apps.com/?p=658</guid>
		<description><![CDATA[In our previous white paper Unit Testing SharePoint &#8211; Getting into the Object Model we introduced the concept of mocking, looked at the new Typemock Isolator AAA API to demonstrate testing against SPSite, SPWeb, SPList and SPListItem objects and reinforced &#8230; <a href="http://www.21apps.com/sharepoint/tdd-using-di/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In our previous white paper <a href="http://www.21apps.com/agile/unit-testing-sharepoint-getting-into-the-object-model/">Unit Testing SharePoint &#8211; Getting into the Object Model</a> we introduced the concept of mocking, looked at the new <a href="http://blog.typemock.com/2008/08/isolator-aaa-api-basics.html">Typemock Isolator</a> AAA API to demonstrate testing against SPSite, SPWeb, SPList and SPListItem objects and reinforced the benefit of using TDD.</p>
<p>In order to keep the white paper easy to follow we used the Isolator features to fake the call to our GetRandomNumber() method as part of the test GetRandomMessage_MultipleMessages_ReturnMessage.</p>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">[Test]</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> GetRandomMessage_MultpleMessages_ReturnMessage()</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">{</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    <span style="color: #008000;">//Arrange</span></pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    SPSite site = Isolate.Fake.Instance&lt;SPSite&gt;(Members.ReturnRecursiveFakes);</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    Isolate.Swap.NextInstance&lt;SPSite&gt;().With(site);</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    Isolate.WhenCalled(() =&gt; site.OpenWeb().Lists["<span style="color: #8b0000;">Messages</span>"].ItemCount).WillReturn(1000);</pre>
<pre style="margin: 0em; background-color: #ffff00; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    Isolate.WhenCalled(() =&gt; message.GetRandomNumber(1000)).WillReturn(99);</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    Isolate.WhenCalled(() =&gt; site.OpenWeb().Lists["<span style="color: #8b0000;">Messages</span>"].Items[99].Title).WillReturn("<span style="color: #8b0000;">Message One Hundred</span>");</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    <span style="color: #008000;">//Act</span></pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    <span style="color: #0000ff;">string</span> rndMessage = message.GetRandomMessage("<span style="color: #8b0000;">http://validsiteurl</span>");</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    <span style="color: #008000;">//Assert</span></pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">    Assert.AreEqual("<span style="color: #8b0000;">Message One Hundred</span>", rndMessage);</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>This makes for a simple test and helped us focus on the objective of testing the SharePoint object model, however this test does not work if we use <a href="http://www.typemock.com/sharepointpage.php" target="_blank">Isolator for SharePoint</a> which can only fake SharePoint objects. With this version you will get an error advising of the need to upgrade to the commercial version.</p>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">UnitTest.ObjectModel.Test.RandomMessage.GetRandomMessage_MultpleMessages_ReturnMessage:</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">TypeMock.TypeMockException :</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">*** Can not fake non-SharePoint type UnitTest.ObjectModel.RandomMessage with current license.</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">In order to fake non SharePoint types please upgrade to Typemock Isolator Commercial license</pre>
<pre style="margin: 0em; background-color: #fbfbfb; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 11px;">See more information at <a href="http://www.typemock.com/sharepointpage.php">http:<span style="color: #008000;">//www.typemock.com/sharepointpage.php</span></a>.</pre>
<p>There are a few solutions to the problem</p>
<ol>
<li>Upgrade to the Full version of <a href="http://www.typemock.com/learn_about_typemock_isolator.html" target="_blank">Typemock Isolator</a></li>
<li>Introduce another mocking framework like NMock to mock this method</li>
<li>Redesign you application to be more testable and make this test possible without using Typemock Isolator</li>
</ol>
<p><a href="http://www.google.co.uk/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fwww.nmock.org%2F&amp;ei=o7ZMSezSMeLEjAeH8KDxDg&amp;usg=AFQjCNH1ZowW0DGlK6gY4220XReusHkPkg&amp;sig2=GwU4SvCG3fO1VdoTdHBsBQ" target="_blank">NMock</a> is an open source mocking framework that provides similar functionality to Typemock however NMock (or any other mocking framework) is unable to fake SharePoint objects as they make use of sealed classes.  We would recommend that you don&#8217;t attempt to work with two different mocking frameworks at the same time as this will make you testing much more difficult to follow and maintain.</p>
<blockquote><p>There has been a lot of debate around <a href="http://weblogs.asp.net/rosherove/archive/2008/01/17/is-typemock-too-powerful-will-it-kill-design-for-testability.aspx" target="_blank">Typemock being too powerful</a> and if the value of <a href="http://www.typemock.com/community/viewtopic.php?t=694" target="_blank">designing testable</a> code is as important now that Typemock can solve these issues.</p></blockquote>
<p>We&#8217;re not going to argue the case for or against here; We&#8217;ll work on the assumption that you have Isolator for SharePoint and will redesign for testability.</p>
<p>Our refactoring of the project has been broken down into 3 steps proceeded by an introduction to some common vocabulary will be published over the next few days.</p>
<ul>
<li><a href="http://www.21apps.com/sharepoint/tdd-with-di-vocabulary/">Introduction to common TDD vocabulary</a></li>
<li><a href="http://www.21apps.com/sharepoint/tdd-with-di-step1/">Step 1. Refactoring</a></li>
<li><a href="http://www.21apps.com/sharepoint/tdd-with-di-step2">Step 2. Implementing dependency injection into GetRandomMessage</a></li>
<li><a href="/sharepoint/tdd-using-di-summar/">Step 3. Review and whats next</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.21apps.com/sharepoint/tdd-using-di/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Unit Test SPSite construction Exceptions with new Isolator method</title>
		<link>http://www.21apps.com/sharepoint/new-isolator-feature-helps-test-spsite-construction-exceptions/</link>
		<comments>http://www.21apps.com/sharepoint/new-isolator-feature-helps-test-spsite-construction-exceptions/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 07:46:15 +0000</pubDate>
		<dc:creator>Andrew Woodward</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[TypeMock]]></category>

		<guid isPermaLink="false">http://www.21apps.com/?p=645</guid>
		<description><![CDATA[In our white paper Unit Testing SharePoint Solutions &#8211; Getting into the Object Model we needed to use Natural Mocks to allow the testing exceptions that are thrown as part of the the SPSite constructor.&#160; Our test code looked like &#8230; <a href="http://www.21apps.com/sharepoint/new-isolator-feature-helps-test-spsite-construction-exceptions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In our white paper <a href="../agile/unit-testing-sharepoint-getting-into-the-object-model/">Unit Testing SharePoint Solutions &#8211; Getting into the Object Model</a> we needed to use Natural Mocks to allow the testing exceptions that are thrown as part of the the SPSite constructor.&#160; Our test code looked like this and although not complicated it introduced another concept that could complicate things for newbies more than necessary.</p>
<pre class="code">[<span style="color: #2b91af">Test</span>]
<span style="color: blue">public void </span>GetRandomMessage_SiteNotFound_ReturnErrorMessage()
{
    <span style="color: green">//Arrange
    </span><span style="color: blue">using </span>(<span style="color: #2b91af">RecordExpectations </span>expections = <span style="color: #2b91af">RecorderManager</span>.StartRecording())
    {
        expections.ExpectAndThrow(<span style="color: blue">new </span><span style="color: #2b91af">SPSite</span>(<span style="color: #a31515">&quot;http://invalid_url&quot;</span>),  <span style="color: blue">new </span><span style="color: #2b91af">FileNotFoundException</span>());
    }

    <span style="color: green">//Act
    </span><span style="color: blue">string </span>rndMessage = message.GetRandomMessage(<span style="color: #a31515">&quot;http://invalid_url&quot;</span>);

    <span style="color: green">//Assert
    </span><span style="color: #2b91af">Assert</span>.That(rndMessage.StartsWith(<span style="color: #a31515">&quot;Error&quot;</span>));
    <span style="color: #2b91af">Assert</span>.That(rndMessage.Contains(<span style="color: #a31515">&quot;Site could not be found&quot;</span>));
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>With the release of V5.1.2 of <a href="http://www.typemock.com/sharepointpage.php" target="_blank">Isolator for SharePoint </a>a <a href="http://www.typemock.com/Docs/UserGuide/newGuide/Documentation/ReleaseNotes512.html" target="_blank">new API</a> has been added to the AAA syntax to support just this scenario.</p>
<p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal">
<p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal">
<p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal"><span style="font-style: italic"><strong>Isolate.Swap.NextInstance&lt;T&gt;().ConstructorWillThrow();</strong></span></p>
<p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal"><span style="font-style: italic"></span>Our tests will now look like this:</p>
<p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal">&#160;</p>
<pre class="code">[<span style="color: #2b91af">Test</span>]
<span style="color: blue">public void </span>GetRandomMessage_SiteNotFound_ReturnErrorMessage()
{
    <span style="color: green">//Arrange
    </span><span style="color: #2b91af">Isolate</span>.Swap.NextInstance&lt;<span style="color: #2b91af">SPSite</span>&gt;().ConstructorWillThrow(<span style="color: blue">new </span><span style="color: #2b91af">FileNotFoundException</span>());

    <span style="color: green">//Act
    </span><span style="color: blue">string </span>rndMessage = message.GetRandomMessage(<span style="color: #a31515">&quot;http://invalid_url&quot;</span>);

    <span style="color: green">//Assert
    </span><span style="color: #2b91af">Assert</span>.That(rndMessage.StartsWith(<span style="color: #a31515">&quot;Error&quot;</span>));
    <span style="color: #2b91af">Assert</span>.That(rndMessage.Contains(<span style="color: #a31515">&quot;Site could not be found&quot;</span>));
}</pre>
<p>You will agree this is a much easier API and helps to lower the barrier to Test Driven SharePoint development a little bit more.&#160;&#160; We will be updating our white paper to reflect this change and updating out code over the next few days.</p>
<p><strong>Update 25 Nov 08:</strong></p>
<p>You will also need to add the [ClearMocks] directive to the start of you Test Fixture to ensure Isolator clears up after each test.</p>
<pre class="code">[<span style="color: #2b91af">TestFixture</span>]
[<span style="color: #2b91af">ClearMocks</span>]
<span style="color: blue">public class </span><span style="color: #2b91af">RandomMessage</span></pre>
<p>Also one of the tests will now fail if you are using the new Isolator for SharePoint with the following error:</p>
<p>TypeMock.TypeMockException:<br />
  <br />*** Can not fake non-SharePoint type UnitTest.ObjectModel.RandomMessage with current license. In order to fake non SharePoint types please upgrade to Typemock Isolator Commercial license</p>
<p>See more information at <a href="http://www.typemock.com/sharepointpage.php">http://www.typemock.com/sharepointpage.php</a>.</p>
<p>I will be following up with the Guys at Typemock to see how much room there will be to support non SharePoint objects in the SharePoint Edition for just these scenarios.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.21apps.com/sharepoint/new-isolator-feature-helps-test-spsite-construction-exceptions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Isolator for SharePoint</title>
		<link>http://www.21apps.com/sharepoint/isolator-for-sharepoint/</link>
		<comments>http://www.21apps.com/sharepoint/isolator-for-sharepoint/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 23:13:32 +0000</pubDate>
		<dc:creator>Andrew Woodward</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[TypeMock]]></category>

		<guid isPermaLink="false">http://www.21apps.com/?p=642</guid>
		<description><![CDATA[Another great day for SharePoint developers.   Typemock have announced the introduction of Isolator for SharePoint. Take a look at our white paper showing Isolator in action and how this really does make Unit Testing your SharePoint solutions that much easier. &#8230; <a href="http://www.21apps.com/sharepoint/isolator-for-sharepoint/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Another great day for SharePoint developers.   Typemock have announced the introduction of Isolator for SharePoint.</p>
<p>Take a look at our white paper showing Isolator in action and how this really does make Unit Testing your SharePoint solutions that much easier.</p>
<p><a href="../agile/unit-testing-sharepoint-getting-into-the-object-model/">Unit Testing SharePoint Solutions &#8211; Getting into the Object Model</a></p>
<p>Quote from Typemock Blog:</p>
<blockquote><p>Typemock are offering their new product for <a href="http://www.typemock.com/sharepointpage.php?utm_source=sp_bb&amp;utm_medium=blog_4sp&amp;utm_campaign=sp_bb">unit testing SharePoint</a> called Isolator For SharePoint, for a special introduction price. it is the only tool that allows you to <a href="http://blog.typemock.com/2008/11/newisolatorforsharepointtoolforunittest.html?utm_source=typeblog&amp;utm_medium=sp_bb&amp;utm_campaign=typeblog">unit test SharePoint</a> without a SharePoint server. To learn more <a href="http://www.typemock.com/sharepointpage.php?utm_source=sp_bb&amp;utm_medium=blog_4sp&amp;utm_campaign=sp_bb">click here</a>.   <strong>The first 50 bloggers </strong>who blog this text in their blog and tell us about it, will get <span style="color: #ff0000;">a Full Isolator license, Free</span>. for rules and info <a href="http://blog.typemock.com/2008/11/newisolatorforsharepointtoolforunittest.html">click here</a>.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.21apps.com/sharepoint/isolator-for-sharepoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit Testing SharePoint &#8211; Getting into the Object Model</title>
		<link>http://www.21apps.com/agile/unit-testing-sharepoint-getting-into-the-object-model/</link>
		<comments>http://www.21apps.com/agile/unit-testing-sharepoint-getting-into-the-object-model/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 10:54:21 +0000</pubDate>
		<dc:creator>Andrew Woodward</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[TypeMock]]></category>

		<guid isPermaLink="false">http://www.21apps.com/?p=592</guid>
		<description><![CDATA[The white paper and associated code can be found here Unit Testing SharePoint Solutions &#8211; Getting into the Object Model The first document in the Beginners Guide to Test Driven Web Part Development Series provided an introduction to unit testing, &#8230; <a href="http://www.21apps.com/agile/unit-testing-sharepoint-getting-into-the-object-model/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<blockquote><p>The white paper and associated code can be found here <a href="http://www.21apps.com/tdd-getting-into-sharepoint-om">Unit Testing SharePoint Solutions &#8211; Getting into the Object Model</a></p></blockquote>
<p>The first <a href="http://www.21apps.com/agile/beginners-guide-to-test-driven-web-part-development/">document</a> in the <strong>Beginners Guide to Test Driven Web Part Development Series</strong> provided an introduction to unit testing, a look at how TDD influences your design and makes your code testable. That document deliberately avoided testing the SharePoint Object Model as in order to do this we need to introduce the concept of mocking.<span style="mso-spacerun: yes"> </span></p>
<p>This second document in the series will cover the concept of mocking, specifically looking at the new <a href="http://blog.typemock.com/2008/08/isolator-aaa-api-basics.html" target="_blank">Typemock Isolator</a> (V5.1.1 or later) AAA API to demonstrate testing against SPSite, SPWeb, SPList and SPListItem objects.</p>
<p>Some of the key things you should get from this white paper are</p>
<ul>
<li>How to unit test the object model</li>
<li>These unit tests are much less brittle using the new Isolator AAA API</li>
<li>You do not need a specific SharePoint configuration on your development machine, we are not Integration testing</li>
<li>Reinforce TDD approach to SharePoint development</li>
</ul>
<p>The white paper is part of the Beginners Series but introduces some fairly advanced concepts, as with SharePoint the learning curve can be fairly steep.  You can work through this white paper on it&#8217;s own but I recommend looking at the first part as this goes into more detail about TDD.</p>
<p>The white paper and associated code can be found here <a href="http://www.21apps.com/tdd-getting-into-sharepoint-om">Unit Testing SharePoint Solutions &#8211; Getting into the Object Model</a></p>
<p>We welcome you comments and suggestion for improving the current white papers and also ideas for the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.21apps.com/agile/unit-testing-sharepoint-getting-into-the-object-model/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

