<?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>Hugo Häggmark</title> <atom:link href="http://www.hugohaggmark.com/feed/" rel="self" type="application/rss+xml" /><link>http://www.hugohaggmark.com</link> <description>Sagas from the software trenches in the continuing battle between quality, price and time…</description> <lastBuildDate>Sun, 11 Mar 2012 11:05:00 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>Fakes, Stubs, Shims, Moles and how to verify them?</title><link>http://www.hugohaggmark.com/2012/03/11/fakes-stubs-shims-moles-how-to-verify-them/</link> <comments>http://www.hugohaggmark.com/2012/03/11/fakes-stubs-shims-moles-how-to-verify-them/#comments</comments> <pubDate>Sun, 11 Mar 2012 09:47:51 +0000</pubDate> <dc:creator>Hugo Häggmark</dc:creator> <category><![CDATA[Bootable VHD]]></category> <category><![CDATA[Fakes]]></category> <category><![CDATA[Moles]]></category> <category><![CDATA[SharePoint]]></category> <category><![CDATA[TDD]]></category> <category><![CDATA[Unit Testing]]></category> <category><![CDATA[Windows 8]]></category> <category><![CDATA[Windows]]></category><guid
isPermaLink="false">http://www.hugohaggmark.com/?p=601</guid> <description><![CDATA[Background If you have been following my posts here and here before you probably know that when I have to I use Moles from Microsoft Research. So the other day a friend of mine mentioned this new cool thing called Fakes, Stubs and Shims in Visual Studio 11 so I decided to look into that. The first [...]]]></description> <content:encoded><![CDATA[<h3>Background</h3><p>If you have been following my posts <a
title="How Do I Do Moles?" href="http://www.hugohaggmark.com/2012/01/04/how-do-i-do-moles/" target="_blank">here </a>and <a
title="How I used Moles in a real life BizTalk scenario" href="http://www.hugohaggmark.com/2011/09/12/how-i-used-moles-in-a-real-life-biztalk-scenario/" target="_blank">here </a>before you probably know that when I have to I use <a
href="http://research.microsoft.com/en-us/projects/pex/" target="_blank">Moles </a>from <a
href="http://www.microsoft.com" target="_blank">Microsoft</a> Research. So the other day a friend of mine mentioned this new cool thing called <a
href="http://msdn.microsoft.com/en-us/library/hh549175(v=vs.110).aspx" target="_blank">Fakes, Stubs and Shims</a> in <a
href="http://www.microsoft.com/visualstudio/11/en-us" target="_blank">Visual Studio 11</a> so I decided to look into that.</p><p>The first thing I actually did was to ask the following question on Twitter because I was curious to see if Moles and Fakes were similar:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2012/03/Twitter1.png" rel="prettyPhoto[601]"><img
class="wp-image-605 alignleft" title="Twitter1" src="http://www.hugohaggmark.com/wp-content/uploads/2012/03/Twitter1.png" alt="" width="529" height="230" /></a></p><h3></h3><h3></h3><h3></h3><h3></h3><h3></h3><h3></h3><h3></h3><p>Ok so Fakes in VS 11 are derived from Moles. My next question to Peter was one I&#8217;ve been thinking about alot lately:</p><h3><a
href="http://www.hugohaggmark.com/wp-content/uploads/2012/03/Twitter2.png" rel="prettyPhoto[601]"><img
class="alignnone size-full wp-image-604" title="Twitter2" src="http://www.hugohaggmark.com/wp-content/uploads/2012/03/Twitter2.png" alt="" width="529" height="263" /></a></h3><p>So Microsoft are looking into adding verify support to Fakes, great!!! this means that you don&#8217;t have to use this hack going forward <img
src='http://www.hugohaggmark.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Thanks Peter for that fast feedback!</p><p>For all you using Moles this hack will still apply. And for all you <a
title="SharePoint" href="http://sharepoint.microsoft.com/en-us/Pages/default.aspx" target="_blank">SharePoint </a>developers out there; YES this is for you guys because you need to be doing more TDD!</p><p>My next step was to create a bootable vhd with <a
title="Windows 8 Consumer Preview" href="http://windows.microsoft.com/en-US/windows-8/download">Windows 8 Consumer Preview</a> and <a
href="http://www.microsoft.com/visualstudio/11/en-us" target="_blank">Visual Studio 11</a> using my preferred method <a
title="The easiest way to Install and Boot Windows 8 Developer Preview off a VHD (Virtual Hard Disk)" href="http://www.hugohaggmark.com/2011/09/17/the-easiest-way-to-install-and-booting-windows-8-developer-preview-off-a-vhd-virtual-hard-disk/">here</a> and start hacking away.</p><h3>Step 1</h3><p>Get up to speed with Fakes, Stubs, Shims by reading &#8220;Using shims to isolate calls to non-virtual functions in unit test methods&#8221; found <a
title="Using shims to isolate calls to non-virtual functions in unit test methods" href="http://msdn.microsoft.com/en-us/library/hh549176(v=vs.110).aspx">here</a>; go on I&#8217;ll wait until you&#8217;re finished.</p><p>You&#8217;ll probably end up with a test method looking like the one shown below:</p><pre class="brush: csharp; title: ; notranslate">
    [TestClass]
    public class Y2KCheckerTests_Step1
    {
        [TestMethod]
        [ExpectedException(typeof(ApplicationException))]
        public void Check_WhenCalledWithTheDate_2000_1_1_ThenApplicationExceptionIsThrowned()
        {
            using(ShimsContext.Create())
            {
                ShimDateTime.NowGet = () =&gt; { return new DateTime(2000, 1, 1); };

                Y2KChecker.Check();
            }
        }
    }
</pre><p>Well this is all fine, but what if you have a thousand tests that want to detour DateTime.Now? If you read my previous post <a
title="How Do I Do Moles?" href="http://www.hugohaggmark.com/2012/01/04/how-do-i-do-moles/">here</a> I introduced a Testable object that encapsulates behaviour.</p><h3>Step 2</h3><p>So the next step is to encapsulate this into a Testable object that I call Y2KShimDateTime like the code below shows:</p><pre class="brush: csharp; title: ; notranslate">
[TestClass]
public class Y2KCheckerTests_Step2
{
    [TestMethod]
    [ExpectedException(typeof(ApplicationException))]
    public void Check_WhenCalledWithY2KShimDateTime_ThenApplicationExceptionIsThrowned()
    {
        using (ShimsContext.Create())
        {
            Y2KShimDateTime shim = new Y2KShimDateTime();

            Y2KChecker.Check();
        }
    }
}

public class Y2KShimDateTime
{
    public Y2KShimDateTime()
    {
        ShimDateTime.NowGet = () =&gt; { return new DateTime(2000, 1, 1); };
    }
}
</pre><p>Wow now we&#8217;re getting somewhere. We can reuse our Y2KShimDateTime in all our test methods. But hey what if we really just want to verify that a specific method has been called? You could just add some counter to the Y2KShimDateTime and call a property like the recommendation <a
href="http://stackoverflow.com/questions/6943332/how-to-assign-opt-from-multiple-delegates-for-a-moled-method/6949941#6949941">here</a>.</p><h3>Step 3</h3><p>I use <a
title="The simplest mocking library for .NET 3.5 and Silverlight with deep C# 3.0 integration" href="http://code.google.com/p/moq/">Moq</a> to Mock my code because it&#8217;s simple and I love the way I can control return values with setups but mostly I love the way I can verify that a certain method was called with a specific value! If you haven&#8217;t looked at Moq yet I strongly encourage you to do so!</p><p>To accomplish this with Fakes, Shims or Moles you will need to trick Moq a bit (a hack I know). First of all let&#8217;s take a look at my verifiable Y2KShimDateTime class called <strong>VY2KShimDateTime</strong>.</p><pre class="brush: csharp; title: ; notranslate">
public class VY2KShimDateTime
{
    public void InitFake()
    {
        ShimDateTime.NowGet = () =&gt;
        {
            return VNowGet();
        };
    }

    public virtual DateTime VNowGet()
    {
        return new DateTime();
    }
}
</pre><p>The first part of the trick is to move the initialization of the detour from the constructor to a public method. This enables us to initialize the detours from Moq as you will see soon. The next thing is to create a public virtual method (VNowGet in this case) that will be called by Moq. There you have it! Easy enough?</p><p>Lets see how we use the <strong>VY2KShimDateTime</strong> from Moq.</p><pre class="brush: csharp; highlight: [4];">using (ShimsContext.Create())
{
    Mock mock = new Mock();
    mock.Object.InitFake();
    mock.Setup(v =&gt; v.VNowGet()).Returns(new DateTime(2000, 1, 1));

    Y2KChecker.Check();
}</pre><p>As you can see from the highlighted row above we&#8217;re initializing our detours after we create our mock this way we can be sure our detours will work. And now we can use the usual setup from Moq to Control what our detour will return. Brilliant don&#8217;t you say?</p><p>Let&#8217;s throw a verify into this equation and look how that looks.</p><pre class="brush: csharp; title: ; notranslate">
using (ShimsContext.Create())
{
    Mock mock = new Mock();
    mock.Object.InitFake();
    mock.Setup(v =&gt; v.VNowGet()).Returns(new DateTime(1, 1, 1));

    Y2KChecker.Check();

    //Uncomment line below to see verify that mock.Verify throws correct message
    //Y2KChecker.Check();

    mock.Verify(v =&gt; v.VNowGet(), Times.Once());
}
</pre><p>In this case we&#8217;ll have to supply a date other than Y2K because otherwise we&#8217;ll get an exception but as you can see in the verify method we verify that DateTime.Now is called only once. If I would to uncomment the second Y2KChecker.Clean(); call the verify on our mock would throw an exception.</p><h3>Summary</h3><p>I&#8217;ve showed how to create verifiable Fakes, Stubs and Shims (works for Moles as well) using a small hack. I use this approach daily when I work with Moles because I really like the combination of Moq verify and setup and Fakes/Moles isolation and detouring.</p><p>Hopefully Microsoft will incorporate this in a near future in Fakes but until then give this a try.</p><p>All code can be downloaded from GitHub <a
title="Github" href="https://github.com/hugohaggmark/HugoHaggmark.Blog">here</a>.</p><p>Cheers,</p><p>Hugo</p> ]]></content:encoded> <wfw:commentRss>http://www.hugohaggmark.com/2012/03/11/fakes-stubs-shims-moles-how-to-verify-them/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>How Do I Do Moles?</title><link>http://www.hugohaggmark.com/2012/01/04/how-do-i-do-moles/</link> <comments>http://www.hugohaggmark.com/2012/01/04/how-do-i-do-moles/#comments</comments> <pubDate>Wed, 04 Jan 2012 12:05:00 +0000</pubDate> <dc:creator>Hugo Häggmark</dc:creator> <category><![CDATA[BDD]]></category> <category><![CDATA[Moles]]></category> <category><![CDATA[TDD]]></category><guid
isPermaLink="false">http://www.hugohaggmark.com/?p=516</guid> <description><![CDATA[Background I’ve just recently started my first Open Source project (there I said it now I definitely have to deliver it). I can go so far to say that it has something to do with TFS 2010 and a Visual Studio package. I got you curious now right! Anyway there are some challenges to be [...]]]></description> <content:encoded><![CDATA[<h4>Background</h4><p>I’ve just recently started my first Open Source project (there I said it now I definitely have to deliver it). I can go so far to say that it has something to do with <a
title="TFS" href="http://msdn.microsoft.com/en-us/vstudio/ff637362" target="_blank">TFS</a> 2010 and a <a
title="Visual Studio" href="http://www.microsoft.com/visualstudio/en-us" target="_blank">Visual Studio</a> package. I got you curious now right! Anyway there are some challenges to be solved when integrating your own code with existing APIs like the TFS Client API, it’s hard to unit test right? Well some would argue that you shouldn’t care to test your interaction with other APIs but for me that’s not an option. So I’ve chosen 2 basic strategies:</p><ol><li>Wrap the TFS Client API with my own classes and Interfaces.</li><li>Test my own classes with the help from <a
title="Pex and Moles - Isolation and White box Unit Testing for .NET" href="http://research.microsoft.com/en-us/projects/pex/">Moles</a>. Moles is a Mocking framework from <a
title="Microsoft" href="http://www.microsoft.com/en-us/default.aspx" target="_blank">Microsoft</a> Research.</li></ol><p>I’ve written about my experiences with Moles <a
title="how-i-used-moles-in-a-real-life-biztalk-scenario" href="http://www.hugohaggmark.com/2011/09/12/how-i-used-moles-in-a-real-life-biztalk-scenario/">here</a> and you should really read that post if you’ve never used Moles before and want to continue reading this post.</p><h4>A simple wrapper class</h4><p>Lets start off with a very simple wrapper class that enables you to connect to a TFS 2010 instance.</p><pre class="brush: csharp; title: ; notranslate">
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Common;

namespace HugoHaggmark.Blog.Moles.HowDoIDoMoles
{
    public class TfsConnectionWrapper
    {
        private TfsTeamProjectCollection tfsTpc;
        public TfsConnectionWrapper()
        {
        }
        public void Connect(string url)
        {
            tfsTpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(url));
            tfsTpc.Connect(ConnectOptions.None);
            tfsTpc.EnsureAuthenticated();
        }
    }
}
</pre><p>As you can see this wrapper class uses some TFS Client API like the call to <span
style="color: #2b91af;">TfsTeamProjectCollectionFactory</span>.GetTeamProjectCollection for instance. Well if we take a close look at <span
style="color: #2b91af;">TfsTeamProjectCollectionFactory </span>we’ll find the following declaration:</p><pre class="brush: csharp; title: ; notranslate">

using System;
namespace Microsoft.TeamFoundation.Client
{
    public static class TfsTeamProjectCollectionFactory
    { }
}
</pre><p>As you can clearly see <span
style="color: #2b91af;">TfsTeamProjectCollectionFactory </span>is a static class with now chance of sub classing or extending to enables some sort of mocking. So this is really where a mocking framework like Moles comes to play.</p><p>Before we start looking at any unit test code I must confess that I’ve started to categorize all my unit tests that use Moles with a test category called MolesTest. I started using the</p><p><span
style="font-family: Consolas;"><span
style="font-size: 9.8pt;">[</span></span><span
style="font-family: Consolas;"><span
style="color: #2b91af;"><span
style="font-size: 9.8pt;">TestCategory</span></span><span
style="font-size: 9.8pt;">(<span
style="color: #a31515;">"MolesTest"</span>)] </span></span></p><p>notation at first but then I just created my own TestCategoryAttribute like this:</p><pre class="brush: csharp; title: ; notranslate">
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace HugoHaggmark.Blog.Moles.HowDoIDoMoles.Tests
{
    public sealed class MolesTestAttribute : TestCategoryBaseAttribute
    {
        public override IList&lt;string&gt; TestCategories
        {
            get { return new[] { &quot;Moles&quot; }; }
        }
    }
}
</pre><p>Doing this enables me to just add MolesTest next to all my TestMethod attributes like so which makes it easy to filter Moles tests if necessary.</p><p><span
style="font-family: Consolas;"><span
style="font-size: 9.8pt;">[</span><span
style="color: #2b91af;"><span
style="font-size: 9.8pt;">TestMethod</span></span><span
style="font-size: 9.8pt;">, <span
style="color: #2b91af;">MolesTest</span>] </span></span></p><p>&nbsp;</p><h4>How I used to do Moles</h4><p>The following example illustrates how I used to use Moles as part of my unit testing. (by the way looking at this code now makes my body shiver with disgust)</p><pre class="brush: csharp; title: ; notranslate">
using System;
using System.Net;
using Microsoft.TeamFoundation.Client.Moles;
using Xunit;
namespace HugoHaggmark.Blog.Moles.HowDoIDoMoles.Tests
{
    [Microsoft.VisualStudio.TestTools.UnitTesting.TestClass]
    public class TfsConnectionWrapperTests
    {
        private const string validUrl = &quot;http://valid&quot;;
        [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethod, MolesTest]
        [Microsoft.VisualStudio.TestTools.UnitTesting.HostType(&quot;Moles&quot;)]
        public void using_an_valid_url_string_should_not_throw_the_old_way_I_used_to_do_moles()
        {
            Assert.DoesNotThrow(() =&gt;
            {
                MTfsTeamProjectCollection mole = new MTfsTeamProjectCollection();
                MTfsConnection.AllInstances.ConnectConnectOptions = (connection, options) =&gt; { };
                MTfsConnection.AllInstances.EnsureAuthenticated = (connection) =&gt; { };
                MTfsTeamProjectCollectionFactory.GetTeamProjectCollectionUri = (uri) =&gt;
                {
                    if (uri.Equals(new Uri(validUrl))) return mole;
                    throw new WebException();
                };

                TfsConnectionWrapper wrapper = new TfsConnectionWrapper(); wrapper.Connect(validUrl);
            });
        }
    }
}
</pre><p>Let’s go through a couple of things before I completely throw this in the recycle bin for ever:</p><ol><li>Yes I’m using <a
title="xUnit.net" href="http://xunit.codeplex.com/" rel="nofollow">xUnit.net</a> as my preferred Assert framework, because I think it’s more descriptive then the default in Visual Studio and it makes the transition to xUnit.net in the future simpler. And because of that I need to prefix all my attributes with Microsoft.VisualStudio.TestTools.UnitTesting. So why not use xUnit all the way? Well that’s a whole other future blog post to be written. Let’s stick with fact that the combination xUnit, Moles and TFS Build and getting stuff published back to TFS caused me some serious headache in the past and that deserves a place in an other post.</li><li>I’m not going to bother right now verifying the input to the Moles delegates except for the <span
style="color: #2b91af;">MTfsTeamProjectCollectionFactory</span>.GetTeamProjectCollectionUri delegate where I want to make sure that any invalid uri throws.</li><li>This would be my starting point then I would probably write another test method to make sure that passing invalid url would indeed throw an exception. In creating that second method I would of course refactor all my moles setups into separate methods. The end result would look something like so:</li></ol><pre class="brush: csharp; title: ; notranslate">
using System;
using System.Net;
using Microsoft.TeamFoundation.Client.Moles;
using Xunit;
namespace HugoHaggmark.Blog.Moles.HowDoIDoMoles.Tests
{
    [Microsoft.VisualStudio.TestTools.UnitTesting.TestClass]
    public class TfsConnectionWrapperTests
    {
        private const string validUrl = &quot;http://valid&quot;;
        [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethod, MolesTest]
        [Microsoft.VisualStudio.TestTools.UnitTesting.HostType(&quot;Moles&quot;)]
        public void using_an_valid_url_string_should_not_throw_the_old_way_I_used_to_do_moles()
        {
            Assert.DoesNotThrow(() =&gt;
            {
                SetupAllMoles();
                TfsConnectionWrapper wrapper = new TfsConnectionWrapper();
                wrapper.Connect(validUrl);
            });
        }

        [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethod, MolesTest]
        [Microsoft.VisualStudio.TestTools.UnitTesting.HostType(&quot;Moles&quot;)]
        public void using_an_invalid_url_string_should_throw_the_old_way_I_used_to_do_moles()
        {
            Assert.Throws&lt;WebException&gt;(() =&gt;
            {
                SetupAllMoles();
                TfsConnectionWrapper wrapper = new TfsConnectionWrapper();
                wrapper.Connect(&quot;http://invalidurl&quot;);
            });
        }

        private static void SetupAllMoles()
        {
            SetupConnectMole();
            SetupEnsureAuthenticatedMole();
            SetupGetTeamProjectCollectionUriMole();
        }

        private static void SetupConnectMole()
        {
            MTfsConnection.AllInstances.ConnectConnectOptions = (connection, options) =&gt; { };
        }

        private static void SetupEnsureAuthenticatedMole()
        {
            MTfsConnection.AllInstances.EnsureAuthenticated = (connection) =&gt; { };
        }

        private static void SetupGetTeamProjectCollectionUriMole()
        {
            MTfsTeamProjectCollection mole = CreateTeamProjectCollectionMole();
            MTfsTeamProjectCollectionFactory.GetTeamProjectCollectionUri = (uri) =&gt;
            {
                if (uri.Equals(new Uri(validUrl)))
                    return mole;
                throw new WebException();
            };
        }

        private static MTfsTeamProjectCollection CreateTeamProjectCollectionMole()
        {
            return new MTfsTeamProjectCollection();
        }
    }
}
</pre><p>So in the past I would feel reasonably happy with this and then move on with the next test case. But then I would come to a point that other test classes needed the same Moles setup and then I would create a class that all test classes derived from. Phuu…there had to be a better approach and as I never settle and always seek ways to improve my skills and code I’ve now reached an approach that for the moment feels comfortable.</p><h4>Introducing Testable Moles classes</h4><p>Nowadays I just create base classes that derive from (if possible) a Moles class. This way I can define my default behavior for my Testable Moles class and reuse it in any other test classes. And by marking the methods in the class used in the Moles delegates as virtual I can create different Testable Mole classes. Clever right? Let’s take a look at my implementation of a base class for a TestableTfsConnectionBase:</p><pre class="brush: csharp; title: ; notranslate">
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Client.Moles;
using Microsoft.TeamFoundation.Framework.Common;
namespace HugoHaggmark.Blog.Moles.HowDoIDoMoles.Tests
{
    internal abstract class TestableTfsConnectionBase : MTfsConnection
    {
        protected TestableTfsConnectionBase()
            : base(new MTfsTeamProjectCollection())
        {
            InitConnectMole();
            InitEnsureAuthenticatedMole();
        }

        private void InitEnsureAuthenticatedMole()
        {
            AllInstances.EnsureAuthenticated = (connection) =&gt;
            {
                SetupEnsureAuthenticatedMole(connection);
            };
        }

        private void InitConnectMole()
        {
            AllInstances.ConnectConnectOptions = (connection, options) =&gt;
            {
                SetupConnectMole(connection, options);
            };
        }

        protected virtual void SetupConnectMole(TfsConnection connection, ConnectOptions options)
        {
        }

        protected virtual void SetupEnsureAuthenticatedMole(TfsConnection connection)
        {
        }
    }
}
</pre><p>After this I would just go ahead and create a “default” test class</p><pre class="brush: csharp; title: ; notranslate">
namespace HugoHaggmark.Blog.Moles.HowDoIDoMoles.Tests
{
    internal class TestableTfsConnection : TestableTfsConnectionBase
    {
    }
}
</pre><p>and if I need I can create another class that implements another behavior like the following class that always throws when trying to connect:</p><pre class="brush: csharp; title: ; notranslate">
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Common;
namespace HugoHaggmark.Blog.Moles.HowDoIDoMoles.Tests
{
    internal class TfsConnectionThatThrowsOnConnect : TestableTfsConnectionBase
    {
        protected override void SetupConnectMole(TfsConnection connection, ConnectOptions options)
        {
            throw new DivideByZeroException();
        }
    }
}
</pre><p>I hope you get the picture on how the testable classes works. Now let’s return to our unit test class and see how this would look in practice:</p><pre class="brush: csharp; title: ; notranslate">
[Microsoft.VisualStudio.TestTools.UnitTesting.TestMethod, MolesTest]
[Microsoft.VisualStudio.TestTools.UnitTesting.HostType(&quot;Moles&quot;)]
public void using_a_connection_that_always_throws_should_throw_the_new_way_I_use_moles()
{
    Assert.Throws&lt;DivideByZeroException&gt;(() =&gt;
    {
        MolesFactory.SetupMole&lt;TfsConnectionThatThrowsOnConnect&gt;();
        MolesFactory.SetupMole&lt;TestableTfsTeamProjectCollection&gt;();
        MolesFactory.SetupMole&lt;TfsTeamProjectCollectionFactoryThatNeverThrows&gt;();
        TfsConnectionWrapper wrapper = new TfsConnectionWrapper();
        wrapper.Connect(&quot;http://invalidurl&quot;);
    });
</pre><p>As you can see any new test method would just simply initialize any testable mole class needed and then of you go. I made a small class called MolesFactory that simply creates an instance of the supplied type in the SetupMole just because I believe it makes my code more descriptive and readable. The complete solution with code and binaries can be downloaded from <a
title="HugoHaggmark.Blog_.Moles_.HowDoIDoMoles.zip" href="http://www.hugohaggmark.com/wp-content/uploads/2012/01/HugoHaggmark.Blog_.Moles_.HowDoIDoMoles.zip">here</a>.</p><p>This is the first time I reveal my inner thoughts and code approaches so I really hope you got a clear understanding and some inspiration. Really looking forward to get feedback from the Moles community regarding the approaches described in this post.</p><p>Until next time,</p><p>Hugo</p> ]]></content:encoded> <wfw:commentRss>http://www.hugohaggmark.com/2012/01/04/how-do-i-do-moles/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Merry X-Mas, God Jul, Feliz Natal</title><link>http://www.hugohaggmark.com/2011/12/24/501/</link> <comments>http://www.hugohaggmark.com/2011/12/24/501/#comments</comments> <pubDate>Sat, 24 Dec 2011 11:00:26 +0000</pubDate> <dc:creator>Hugo Häggmark</dc:creator> <category><![CDATA[Personal]]></category><guid
isPermaLink="false">http://www.hugohaggmark.com/?p=501</guid> <description><![CDATA[Time for X-Mas vacation! Merry X-Mas, God Jul, Feliz Natal, ¡Feliz Navidad, Καλά Χριστούγεννα,Joyeux Noël, Hyvää Joulua, Wesołych Świąt]]></description> <content:encoded><![CDATA[<p>Time for X-Mas vacation! Merry X-Mas, God Jul, Feliz Natal, ¡Feliz Navidad, Καλά Χριστούγεννα,Joyeux Noël, Hyvää Joulua, Wesołych Świąt</p> ]]></content:encoded> <wfw:commentRss>http://www.hugohaggmark.com/2011/12/24/501/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Moles issue when multiple projects reference the same moles assembly and the assembly version changes</title><link>http://www.hugohaggmark.com/2011/12/23/moles-issue-when-multiple-projects-reference-the-same-moles-assembly-and-the-assembly-version-changes/</link> <comments>http://www.hugohaggmark.com/2011/12/23/moles-issue-when-multiple-projects-reference-the-same-moles-assembly-and-the-assembly-version-changes/#comments</comments> <pubDate>Fri, 23 Dec 2011 10:15:00 +0000</pubDate> <dc:creator>Hugo Häggmark</dc:creator> <category><![CDATA[Error]]></category> <category><![CDATA[Moles]]></category> <category><![CDATA[Resolution]]></category> <category><![CDATA[Team Build]]></category><guid
isPermaLink="false">http://www.hugohaggmark.com/?p=480</guid> <description><![CDATA[Background The other day I had one of the teams at my current customer report a strange build error in TFS build. They could tell that it had something to do with Moles but they couldn’t solve it. The solution they were trying to build was pretty simple and consisted of on Class Library project [...]]]></description> <content:encoded><![CDATA[<h2>Background</h2><p>The other day I had one of the teams at my current customer report a strange build error in <a
title="TFS" href="http://msdn.microsoft.com/en-us/vstudio/ff637362" target="_blank">TFS</a> build. They could tell that it had something to do with <a
title="Pex and Moles - Isolation and White box Unit Testing for .NET" href="http://research.microsoft.com/en-us/projects/pex/">Moles</a> but they couldn’t solve it.</p><p>The solution they were trying to build was pretty simple and consisted of on Class Library project and two Test projects, one for unit testing and the second for integration testing. It looked something like the picture below:<br
/> <a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/12/image.png" rel="prettyPhoto[480]"><img
style="background-image: none; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/12/image_thumb.png" alt="image" width="640" height="326" border="0" /></a></p><h2>Challenge</h2><p>I noticed right away that both test projects had moles references to the library which doesn’t have to be a bad thing. But then I also noticed that one of the test projects had a reference to the other test project as well. Could this result in a conflict resolving the correct Moles assembly?</p><p>Well if you DO NOT change the assembly version of the library project then you WILL NOT have a problem. But if you’re like us and like to sync your AssemblyVersion and AssemblyFileVersion with the build in TFS then you will run into this trouble. You’ll probably get an error message like:</p><blockquote><p><strong>The type or namespace name &#8216;Moles&#8217; does not exist in the namespace (are you missing an assembly reference?)</strong></p></blockquote><p>Mind you that this error message is a common compile error in Moles but does also appear in this case. I’ve attached a small solution that mimics this behavior <a
title="solution containing moles issue in this post" href="http://www.hugohaggmark.com/wp-content/uploads/2011/12/HugoHaggmark.Blog_.MolesIssue.zip">here</a>. (you will need VS2010 and Moles installed to build the zipped solution)</p><h2>Solution</h2><p>You get this error because when you add a Moles reference in your test project it adds a reference to a specific version of the Moled assembly (this is of course the default behavior you want in most cases) but when two assemblies have the same Mole reference and they reference each other we get a copy conflict.</p><p>To solve this I’ve come up with these solutions:</p><ol><li>First of all you should probably break the project reference between the two test projects and then your problems will automatically go away.</li><li>When you add a Moles Reference from within <a
title="Visual Studio" href="http://www.microsoft.com/visualstudio/en-us" target="_blank">Visual Studio</a> you’ll get a reference to a specific version like so:<br
/> <span
style="font-family: Consolas;"><span><span
style="color: #0000ff;">&lt;</span></span><span><span
style="color: #a31515;">Reference</span></span><span><span
style="color: #0000ff;"> </span></span><span><span
style="color: #ff0000;">Include</span></span><span><span
style="color: #0000ff;">=</span></span><span
style="color: #000000;">&#8220;</span><span><span
style="color: #0000ff;">Type.Moles, Version=1.0.0.0, Culture=neutral<br
/> , processorArchitecture=MSIL</span></span><span
style="color: #000000;">&#8220;</span><span><span
style="color: #0000ff;"> /&gt;</span></span><br
/> </span>If you change the property Specific Version on the Moles reference to False then that will solve this issue as well.<br
/> <a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/12/image1.png" rel="prettyPhoto[480]"><img
style="background-image: none; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/12/image_thumb1.png" alt="image" width="410" height="356" border="0" /></a></li></ol><p>I wish that the command “Upgrade .Moles files..” on the solution level would automatically update the project references with the new versions of the Mole References. But I believe I have to file that request to <a
title="Microsoft" href="http://www.microsoft.com/en-us/default.aspx" target="_blank">Microsoft</a>.<br
/> <a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/12/image2.png" rel="prettyPhoto[480]"><img
style="background-image: none; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/12/image_thumb2.png" alt="image" width="292" height="480" border="0" /></a></p><p>Enjoy,</p><p>Hugo</p> ]]></content:encoded> <wfw:commentRss>http://www.hugohaggmark.com/2011/12/23/moles-issue-when-multiple-projects-reference-the-same-moles-assembly-and-the-assembly-version-changes/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Do you get a Login dialog from your client machine when connecting to SSRS using all but the IP-address?</title><link>http://www.hugohaggmark.com/2011/12/22/do-you-get-a-login-dialog-from-your-client-machine-when-connecting-to-ssrs-using-all-but-the-ip-address/</link> <comments>http://www.hugohaggmark.com/2011/12/22/do-you-get-a-login-dialog-from-your-client-machine-when-connecting-to-ssrs-using-all-but-the-ip-address/#comments</comments> <pubDate>Thu, 22 Dec 2011 12:43:00 +0000</pubDate> <dc:creator>Hugo Häggmark</dc:creator> <category><![CDATA[Reporting Services]]></category> <category><![CDATA[SSRS]]></category> <category><![CDATA[Team Foundation Server]]></category> <category><![CDATA[Error]]></category> <category><![CDATA[Resolution]]></category><guid
isPermaLink="false">http://www.hugohaggmark.com/2011/12/22/do-you-get-a-login-dialog-from-your-client-machine-when-connecting-to-ssrs-using-all-but-the-ip-address/</guid> <description><![CDATA[Background I’ll be leaving my current client soon after been there for more then a year. As a final test the person at the customer that shadowed me during all this time had to install a complete TFS environment including build server without my help. And he did it, which I personally take as the [...]]]></description> <content:encoded><![CDATA[<h2>Background</h2><p>I’ll be leaving my current client soon after been there for more then a year. As a final test the person at the customer that shadowed me during all this time had to install a complete <a
title="TFS" href="http://msdn.microsoft.com/en-us/vstudio/ff637362" target="_blank">TFS</a> environment including build server without my help.</p><p>And he did it, which I personally take as the best compliment as a coach and consultant leaving the assignment. Anyway my job in this final test was to verify that everything was working as expected.</p><h2>Challenge</h2><p>When I reached the verification part in my tests where I finally tried to connect to SSRS from my client machine I got an Login Dialog every time except when I used the IP-address of the SSRS machine.</p><p>As a seasoned installer of TFS and SSRS I thought I had seen all the silly errors you can get configuring SSRS so instantly I got the feeling that something was rotten outside the SSRS box. And there was some issues with the DNS that were outside the control of the SSRS box. After almost 1½ days (I kid you not) I stumbled upon the solution…</p><h2>Solution</h2><p>Someone had added a <font
face="Consolas"><span
style="color: "><font
color="#0000ff">&lt;</font></span><span
style="color: "><font
color="#a31515">RSWindowsNegotiate</font></span><span
style="color: "><font
color="#0000ff">/&gt; </font></span></font><span
style="color: "><font
color="#000000">tag to the authentication types section in the rsreportserver.config file (<a
title="RSReportServer Configuration File" href="http://msdn.microsoft.com/en-us/library/ms157273.aspx">located in your SSRS installation path</a>). As we’re not using kerberos in this installation a quick delete of the <font
face="Consolas"><span
style="color: "><font
color="#0000ff">&lt;</font></span><span
style="color: "><font
color="#a31515">RSWindowsNegotiate</font></span><span
style="color: "><font
color="#0000ff">/&gt; </font></span></font></font></span><font
color="#333333">tag fixed our issue. </font><span
style="color: "><font
color="#000000"> This is how our authentication types section looked like after the change.</font></span></p><pre style="font-family: ; background: white; color: "><font face="Consolas"><span style="color: "><font color="#0000ff">&lt;</font></span><span style="color: "><font color="#a31515">AuthenticationTypes</font></span><span style="color: "><font color="#0000ff">&gt;</font></span>
<span style="color: "><font color="#0000ff">  &lt;</font></span><span style="color: "><font color="#a31515">RSWindowsNTLM</font></span><span style="color: "><font color="#0000ff">/&gt;</font></span>
<span style="color: "><font color="#0000ff">&lt;/</font></span><span style="color: "><font color="#a31515">AuthenticationTypes</font></span><span style="color: "><font color="#0000ff">&gt;</font></span>
</font></pre><p><span
style="color: "><font
color="#000000">Now this configuration was probably done by the IT-ops that delivered the machine in the first place but investigation will continue to exclude my fellow shadower from blame.</font></span></p><p>Cheers,</p><p>Hugo</p> ]]></content:encoded> <wfw:commentRss>http://www.hugohaggmark.com/2011/12/22/do-you-get-a-login-dialog-from-your-client-machine-when-connecting-to-ssrs-using-all-but-the-ip-address/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>The build process could not be deserialized due to&#8230;</title><link>http://www.hugohaggmark.com/2011/10/20/the-build-process-could-not-be-deserialized-due-to/</link> <comments>http://www.hugohaggmark.com/2011/10/20/the-build-process-could-not-be-deserialized-due-to/#comments</comments> <pubDate>Thu, 20 Oct 2011 13:44:00 +0000</pubDate> <dc:creator>Hugo Häggmark</dc:creator> <category><![CDATA[Error]]></category> <category><![CDATA[Resolution]]></category> <category><![CDATA[Team Build]]></category> <category><![CDATA[Team Foundation Server]]></category><guid
isPermaLink="false">http://www.hugohaggmark.com/2011/10/20/the-build-process-could-not-be-deserialized-due-to/</guid> <description><![CDATA[Background At my current customer we’ve upgraded all our builds from TFS 2008 MSBuild tasks to TFS 2010 WorkFlow Activities. I must say that we’ve gone from several common target-files and per-build specific rsp-files to ONE build process template! That says enough about the power of the new build process in TFS 2010. Following Microsoft’s [...]]]></description> <content:encoded><![CDATA[<h3>Background</h3><p>At my current customer we’ve upgraded all our builds from <a
title="TFS" href="http://msdn.microsoft.com/en-us/vstudio/ff637362" target="_blank">TFS</a> 2008 <a
title="MSBuild tasks" href="http://msdn.microsoft.com/en-us/library/z7f65y0d.aspx" target="_blank">MSBuild tasks</a> to TFS 2010 WorkFlow Activities. I must say that we’ve gone from several common target-files and per-build specific rsp-files to ONE build process template! That says enough about the power of the new build process in TFS 2010.</p><p>Following <a
title="Microsoft" href="http://www.microsoft.com/en-us/default.aspx" target="_blank">Microsoft</a>’s recommendation <a
title="Understanding a Team Foundation Build System" href="http://msdn.microsoft.com/en-us/library/dd793166.aspx#build_controller">here</a> we’re using one Build Controller for our Default Collection and we’ve centralized our custom activities to one Team Project; lets call it <strong>Central</strong>.</p><p>In the Team Project <strong>Central</strong> the custom activities we’re using a stored at <strong>$/Central/BuildComponents</strong> and our Build Controller points out this location as the picture shows below:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image.png" rel="prettyPhoto[471]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image_thumb.png" width="535" height="484" /></a></p><p>In our Custom Activities we have some simple serializble objects that we use as part of our process to store some settings that we need in our build process. An of that would be an XCopyFileWrapper that we use to store 3 string properties:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image1.png" rel="prettyPhoto[471]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image_thumb1.png" width="316" height="138" /></a></p><p>We then use this wrapper in our Meta Data property in our DefaultTemplate.xaml file like the picture shown below:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image2.png" rel="prettyPhoto[471]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image_thumb2.png" width="445" height="484" /></a></p><p>Then we added the ParamWrapper as an array of XCopyFileWrapper and add it as an argument to DefaultTemplate.xaml like so:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image3.png" rel="prettyPhoto[471]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image_thumb3.png" width="644" height="413" /></a></p><p>This way we can have the same DefaultTemplate XCopy files depending on the input we add for each unique build definition in this rather nice centralized GUI for your build definitions:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image4.png" rel="prettyPhoto[471]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image_thumb4.png" width="644" height="322" /></a></p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image5.png" rel="prettyPhoto[471]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image_thumb5.png" width="644" height="363" /></a></p><p>And then in our DefaultTemplate.xaml we have an foreach loop that loops over our array of XCopyFileWrappers and invokes XCopy! This makes our build definitions really sweet, dynamic and expandable right!</p><h2>The challenge</h2><p>So the next Team Project comes along we can call it <strong>Project B</strong> and they want to use our Build Process. So they branch our build process template into their project and they create a new build definition and then KAPOW!</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image6.png" rel="prettyPhoto[471]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/10/image_thumb6.png" width="644" height="299" /></a></p><p>What happen here! Well my initial thoughts was another lesson I learned previously and blogged about <a
title="Stuck on “Cannot create unknown type {clr-namespace:” in TFS Build?" href="http://www.hugohaggmark.com/2011/09/08/stuck-on-cannot-create-unknown-type-clr-namespace-in-tfs-build/">here</a> but specifying the assembly in the DefaultTepmplate.xaml didn’t solve this issue.</p><h3>The solution</h3><p>The very simple solution to this problem is that you need to give users READ permissions to your BuildComponents folder in our case the <strong>$/Central/BuildComponents</strong> folder (another way is to solve this is to give other users READ permissions to the <strong>Central</strong> Team Project).</p><p>That’s it!</p><h2>Reflection</h2><ul><li>So if I want to centralize my custom build components then I have to give all users that will use these custom build components READ permission to the folder where the components are stored.</li><li>Or you could have some sort of deployment mechanism that deploys the build components to every Team Project in the Team Project Collection but then you’ll have to have one Build Controller per Team Project.</li></ul><p>Cheers,</p><p>Hugo</p> ]]></content:encoded> <wfw:commentRss>http://www.hugohaggmark.com/2011/10/20/the-build-process-could-not-be-deserialized-due-to/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>My first impressions of the Azure hosted TFS 11</title><link>http://www.hugohaggmark.com/2011/09/22/my-first-impressions-of-the-azure-hosted-tfs-11/</link> <comments>http://www.hugohaggmark.com/2011/09/22/my-first-impressions-of-the-azure-hosted-tfs-11/#comments</comments> <pubDate>Thu, 22 Sep 2011 08:17:34 +0000</pubDate> <dc:creator>Hugo Häggmark</dc:creator> <category><![CDATA[Team Foundation Server]]></category> <category><![CDATA[Windows 8]]></category><guid
isPermaLink="false">http://www.hugohaggmark.com/2011/09/22/my-first-impressions-of-the-azure-hosted-tfs-11/</guid> <description><![CDATA[Background Have you downloaded and created your own Windows 8 image yet? If not you should really do that, trust me you will love it especially if have a touch enabled laptop. You can easily do this in about 30-60 minutes if you follow my post here. So last week was the big launch week [...]]]></description> <content:encoded><![CDATA[<h3>Background</h3><p>Have you downloaded and created your own Windows 8 image yet? If not you should really do that, trust me you will love it especially if have a touch enabled laptop. You can easily do this in about 30-60 minutes if you follow my post <a
title="the-easiest-way-to-install-and-booting-windows-8-developer-preview-off-a-vhd-virtual-hard-disk" href="http://www.hugohaggmark.com/2011/09/17/the-easiest-way-to-install-and-booting-windows-8-developer-preview-off-a-vhd-virtual-hard-disk/">here</a>.</p><p>So last week was the big launch week during the <a
title="Build" href="http://www.buildwindows.com/">Build</a> event and Brian Harry announced a lot of great previews such as the Azure hosted TFS 11. You can read more about it in Brian’s post <a
title="Team Foundation Server on Windows Azure: A Preview is available!" href="http://blogs.msdn.com/b/bharry/archive/2011/09/14/team-foundation-server-on-windows-azure.aspx">here</a>.</p><p>As I’m a frequent reader of Brian’s blog I received the post immediately in my RSS reader and luckily for me I was quick enough create my own hosted instance of TFS 11 in Azure using Brian’s activation code.</p><p>The irony here is that I created my first hosted TFS 11 in Azure from my Android smartphone, talk about cloud power!</p><h3>Metro style makes an entrance</h3><p>The very first thing that stroke me was the sense of familiarity in the GUI and then of course it struck me, TFS 11 is <a
title="Metro" href="http://en.wikipedia.org/wiki/Metro_(design_language)">Metro</a> styled!</p><h4>The Team Project overview with a nice Metro look and feel:</h4><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/tfs6.png" rel="prettyPhoto[456]"><img
title="tfs6" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="tfs6" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/tfs6_thumb.png" width="644" height="249" /></a></p><h4>A work item overview with a nice Metro look and feel:</h4><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/tfs7.png" rel="prettyPhoto[456]"><img
title="tfs7" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="tfs7" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/tfs7_thumb.png" width="644" height="473" /></a></p><h3></h3><h3>The Team concept makes an entrance</h3><p>There is this long sought concept of a team in TFS 11 that I just started to play around with and it basically means that you can distribute work per team as the team have their “own” schedule, work items, backlog and homepage (landing page). You’ve Always been able to do this your self by manipulating Areas and Iterations but now it’s a first class citizen.</p><h4>Create a team dialog:</h4><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/tfs10.png" rel="prettyPhoto[456]"><img
title="tfs10" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="tfs10" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/tfs10_thumb.png" width="544" height="484" /></a></p><h4>Assignment of areas to a specific team:</h4><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/tfs11.png" rel="prettyPhoto[456]"><img
title="tfs11" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="tfs11" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/tfs11_thumb.png" width="644" height="399" /></a></p><h4>Assignment of iterations to a specific team:</h4><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/tfs12.png" rel="prettyPhoto[456]"><img
title="tfs12" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="tfs12" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/tfs12_thumb.png" width="428" height="484" /></a></p><h3>Iterations with dates enters</h3><p>As you can see above my first iteration (Sprint1) has a Start Date and an End Date which is also a really nice feature that I’ve been missing for ever. Thank you Microsoft for providing this in the box!</p><p>Then I found this Current Sprint folder in the Shared Queries section of Work Items and my guess is that there will be a job that automatically adjusts the Work Item Queries according to your dates. I haven’t been able to prove this yet, but I will update this section with my findings.</p><h4>Showing Work Items section in the new Team Explorer:</h4><h4></h4><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image24.png" rel="prettyPhoto[456]"><img
title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb24.png" width="368" height="484" /></a></p><h3>Search Work Items in Visual Studio makes an entrance</h3><p>If you read my last post about finding stuff in TFS <a
title="How do I find stuff in TFS 2010?" href="http://www.hugohaggmark.com/2011/09/09/how-do-i-find-stuff-in-tfs-2010/">here</a> you can see that I wanted a nice search for Work Items functionality directly in the IDE and now I have it. Great job! The nice thing about it is if you enter a Work Item ID that you know about Visual Studio will open it for you.</p><h4>Entering a Work Item ID in the search field will get you that Work Item:</h4><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image25.png" rel="prettyPhoto[456]"><img
title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb25.png" width="368" height="484" /></a></p><p>Another great feature is that you can turn your searches directly to a Query with the Open as Query option as shown below.</p><h4>Open as Query enables you to store your searches as queries:</h4><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image26.png" rel="prettyPhoto[456]"><img
title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb26.png" width="368" height="484" /></a></p><p>This is how far my explorations have taken me so far and will create more posts as I go along discovering more features.</p><p>Cheers,</p><p>Hugo</p> ]]></content:encoded> <wfw:commentRss>http://www.hugohaggmark.com/2011/09/22/my-first-impressions-of-the-azure-hosted-tfs-11/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>The easiest way to Install and Boot Windows 8 Developer Preview off a VHD (Virtual Hard Disk)</title><link>http://www.hugohaggmark.com/2011/09/17/the-easiest-way-to-install-and-booting-windows-8-developer-preview-off-a-vhd-virtual-hard-disk/</link> <comments>http://www.hugohaggmark.com/2011/09/17/the-easiest-way-to-install-and-booting-windows-8-developer-preview-off-a-vhd-virtual-hard-disk/#comments</comments> <pubDate>Sat, 17 Sep 2011 14:28:00 +0000</pubDate> <dc:creator>Hugo Häggmark</dc:creator> <category><![CDATA[Bootable VHD]]></category> <category><![CDATA[Development Environment]]></category> <category><![CDATA[Windows 8]]></category><guid
isPermaLink="false">http://www.hugohaggmark.com/2011/09/17/the-easiest-way-to-install-and-booting-windows-8-developer-preview-off-a-vhd-virtual-hard-disk/</guid> <description><![CDATA[This post provides the fastest way to get your Windows 8 Developer Preview booting off a VHD. If you’re interested in more details read my previous posts here, here and here. First of all download Windows 8 Developer Preview here. Download my script here. Select Properties on the zip-package and click on the Unblock button. [...]]]></description> <content:encoded><![CDATA[<p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/works-on-my-machine-starburst_3.png" rel="prettyPhoto[438]"><img
style="background-image: none; float: right; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;" title="works-on-my-machine-starburst_3" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/works-on-my-machine-starburst_3_thumb.png" alt="works-on-my-machine-starburst_3" width="200" height="193" align="right" border="0" /></a></p><p>This post provides the fastest way to get your Windows 8 Developer Preview booting off a VHD. If you’re interested in more details read my previous posts <a
title="creating-a-bootable-vhd-the-easy-way" href="http://www.hugohaggmark.com/2010/09/23/creating-a-bootable-vhd-the-easy-way/">here</a>, <a
title="creating-a-bootable-vhd-the-easy-waycontinued" href="http://www.hugohaggmark.com/2010/11/15/creating-a-bootable-vhd-the-easy-waycontinued/">here</a> and <a
title="creating-a-bootable-vhd-the-easy-wayabout-indexes" href="http://www.hugohaggmark.com/2011/04/05/creating-a-bootable-vhd-the-easy-wayabout-indexes/">here</a>.</p><ol><li>First of all download Windows 8 Developer Preview <a
title="Windows 8 Developer Preview" href="http://msdn.microsoft.com/en-us/windows/apps/br229516">here</a>.</li><li>Download my script <a
title="CreateBootableVHD_v22.zip" href="http://www.hugohaggmark.com/wp-content/uploads/2010/09/CreateBootableVHD_v22.zip">here</a>.</li><li>Select Properties on the zip-package and click on the <strong>Unblock</strong> button.</li><li>Extract the zip-package to a folder of your choice.</li><li>Mount Windows 8 Developer Preview with your favorite mounting tool, my favorite tool is Virtual Clone Drive you can find it <a
title="VirtualCloneDrive.exe" href="http://static.slysoft.com/SetupVirtualCloneDrive.exe">here</a>.</li><li>Look for the file “install.wim” in your installation media and remember the path, in my case F:\sources\install.wim.</li><li>Open a <strong>PowerShell</strong> command prompt with the <strong>run as Administrator</strong> option. You need to run the attached bat-file from a <strong>PowerShell</strong> console as an <strong>Administrator</strong> and not from the usual command prompt.</li><li>Change directory to the directory where you extracted the zip-package.</li><li>Before I show you how to use the CreateBootableVHD.bat file there is 2 important concepts that you need to know:<ul><li>The third parameter in CreateBootableVHD.bat expects you to enter the type of VHD that you want to create. If you choose <strong>EXPANDABLE</strong> you will need to make sure that you have the specified amount of GB left for the VHD even though the VHD will be small at first.</li><li>CreateBootableVHD.bat will assign your bootable VHD a drive letter, it’s very important to use a <strong>FREE drive letter</strong>.</li><li>When you enter a drive letter make sure you don’t enter a colon after the letter i.e. <strong>X</strong> and never <strong>X:</strong>.</li></ul></li><li>Now you’re ready to use the CreateBootableVHD.bat-file like this:<br
/> <strong>CreateBootableVHD_v2.bat<br
/> &lt;path where you like to store the VHD, doesn’t work on external drives&gt;<br
/> &lt;size in MB&gt;<br
/> &lt;type FIXED|EXPANDABLE&gt;<br
/> &lt;drive letter assigned to the VHD&gt;<br
/> &lt;path to the wim-file, see number 6 above&gt;<br
/> </strong><em><strong><br
/> Ex: </strong></em><em><strong><span
style="background-color: #ffff00; font-size: xx-small;">.\CreateBootableVHD_v2.bat C:\VHD\Win8.vhd 80000 FIXED X F:\sources\install.wim.</span></strong></em></li></ol><p>Sit back and enjoy as the complete automated process of getting your copy of Windows 8 Developer Preview bootable.</p><p>Hope you enjoy it!</p><p>Hugo</p> ]]></content:encoded> <wfw:commentRss>http://www.hugohaggmark.com/2011/09/17/the-easiest-way-to-install-and-booting-windows-8-developer-preview-off-a-vhd-virtual-hard-disk/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>How I used Moles in a real life BizTalk scenario</title><link>http://www.hugohaggmark.com/2011/09/12/how-i-used-moles-in-a-real-life-biztalk-scenario/</link> <comments>http://www.hugohaggmark.com/2011/09/12/how-i-used-moles-in-a-real-life-biztalk-scenario/#comments</comments> <pubDate>Mon, 12 Sep 2011 09:14:00 +0000</pubDate> <dc:creator>Hugo Häggmark</dc:creator> <category><![CDATA[BizTalk]]></category> <category><![CDATA[Moles]]></category> <category><![CDATA[TDD]]></category> <category><![CDATA[Tools]]></category><guid
isPermaLink="false">http://www.hugohaggmark.com/2011/09/12/how-i-used-moles-in-a-real-life-biztalk-scenario/</guid> <description><![CDATA[Background When you’re building BizTalk applications with TFS Build and then doing some deployment you pretty much end up with the situation where you DO NOT want to create BizTalk applications manually or automatically from some text-file. There is actually a place where this information is stored and it’s called a Bindings File. A Binding [...]]]></description> <content:encoded><![CDATA[<h2>Background</h2><p>When you’re building BizTalk applications with <a
title="TFS" href="http://msdn.microsoft.com/en-us/vstudio/ff637362" target="_blank">TFS</a> Build and then doing some deployment you pretty much end up with the situation where you DO NOT want to create BizTalk applications manually or automatically from some text-file. There is actually a place where this information is stored and it’s called a Bindings File.</p><p>A Binding File contains information specific for a BizTalk application and it’s in XML. If you really are into details I encourage you to read <a
title="Structure of a Binding File" href="http://msdn.microsoft.com/en-us/library/aa559878(BTS.70).aspx">this</a> article on MSDN. In short you should use Binding Files and only Binding Files as a part of your automatic deployment process. Thanks to <a
title="Johan Hedberg" href="http://blogical.se/blogs/johan/default.aspx">Johan Hedberg</a> and <a
title="Mikael Håkansson" href="http://blogical.se/blogs/mikael/default.aspx">Mikael Håkansson</a> for pointing this out.</p><p>Hey this has nothing to do with Moles! Be patient and start by installing Moles here are the free download links from the <a
title="Visual Studio" href="http://www.microsoft.com/visualstudio/en-us" target="_blank">Visual Studio</a> Code Gallery:</p><ul><li>x64 version of Moles <a
title="http://visualstudiogallery.msdn.microsoft.com/22c07bda-ffc9-479a-9766-bfd6ccacabd4/" href="http://visualstudiogallery.msdn.microsoft.com/22c07bda-ffc9-479a-9766-bfd6ccacabd4/">http://visualstudiogallery.msdn.microsoft.com/22c07bda-ffc9-479a-9766-bfd6ccacabd4/</a></li><li>x86 version of Moles <a
title="http://visualstudiogallery.msdn.microsoft.com/b3b41648-1c21-471f-a2b0-f76d8fb932ee/" href="http://visualstudiogallery.msdn.microsoft.com/b3b41648-1c21-471f-a2b0-f76d8fb932ee/">http://visualstudiogallery.msdn.microsoft.com/b3b41648-1c21-471f-a2b0-f76d8fb932ee/</a></li></ul><h2>Moles</h2><blockquote><p><b>Moles </b>is a lightweight framework for<b> test stubs and detours in .NET</b> that is based on delegates. Moles may be used to detour any .NET method, including non-virtual/static methods in sealed types. <strong>Moles is freely available on Visual Studio Gallery</strong> or bundled with <a
href="http://research.microsoft.com/pex">Pex</a>.</p></blockquote><p>That’s what <a
title="Microsoft" href="http://www.microsoft.com/en-us/default.aspx" target="_blank">Microsoft</a> Research introduces Moles as so now back to my real life scenario.</p><h2>Writing extensions to the BindingInfo class with Moles</h2><p>So there is actually a class in the assembly <strong>Microsoft.Biztalk.Deployment.dll</strong> that wraps the structure of a Binding File into a .Net class. So my thought was to write some helpful extensions methods that could help me in retrieving the name of the BizTalk application configured in the Binding File.</p><p>Are you still with me?</p><p>If we take a closer look at the <strong>BindingInfo</strong> class:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image13.png" rel="prettyPhoto[430]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb13.png" width="632" height="324" /></a></p><p>The <strong>BindingInfo</strong> has a default constructor that takes no parameters and then there is a LoadXml method that takes a string to the path of the Binding File. So now I have several options:</p><ul><li>I could create my own implementation of <strong>BindingInfo</strong> and create a subclass that I could mock</li><li>I could use any other Mocking framework, like <a
title="http://code.google.com/p/moq/" href="http://code.google.com/p/moq/">moq</a></li><li>I could use strictly integration tests (tests that use external resources) to test my extension methods</li></ul><p>In this case I decided to use Moles because I like to try out new stuff. (Mind you this is not the most common scenario on when to use Moles but just bare with me)</p><p>Have you installed it yet? Good lets move on.</p><h3>Adding a reference to a Moled assembly</h3><p>Right click any referenced assembly and choose Add Moles Assembly like so:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image14.png" rel="prettyPhoto[430]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb14.png" width="633" height="377" /></a></p><p>Rebuild your test project and you’ll find two new items added to your project.</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image15.png" rel="prettyPhoto[430]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb15.png" width="631" height="533" /></a></p><p>The first new item is a reference to an assembly that is the Moles representation of (in this case) <strong>Microsoft.BizTalk.Deployment.Moles</strong>.</p><p>And the second new item is a .moles file is a simple XML file telling Moles which Moles representation should be created at build time. This is how my <strong>Microsoft.BizTalk.Deployment.moles</strong> looks like:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image16.png" rel="prettyPhoto[430]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb16.png" width="639" height="77" /></a></p><p>This can have implications on build performance that I will try to write another post about soon.</p><p>Now you have everything in place to start writing your tests right? Let’s goooo! First of all you’ll need to decorate all your test methods where you’re going to use Moled objects with the <strong><a
title="HostType" href="http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&amp;l=EN-US&amp;k=k(MICROSOFT.VISUALSTUDIO.TESTTOOLS.UNITTESTING.HOSTTYPEATTRIBUTE);k(TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22);k(DevLang-CSHARP)&amp;rd=true">HostType</a></strong> attribute. I use my own code snippet for <a
title="Code snippet for Moles TestMethods" href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/testmethodmoles.snippet.zip">this</a> (based on the <strong><a
title="TestMethod" href="http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&amp;l=EN-US&amp;k=k(MICROSOFT.VISUALSTUDIO.TESTTOOLS.UNITTESTING.TESTMETHODATTRIBUTE);k(TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22);k(DevLang-CSHARP)&amp;rd=true">TestMethod</a></strong> code snippet already in Visual Studio).</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image17.png" rel="prettyPhoto[430]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb17.png" width="638" height="145" /></a></p><p>And then start writing test cases. But how do you find your Moled objects? Well I usually find my Molable object using the <strong><em>complete namespace to the stuff you want to Mole + Moles + M + intellisense</em></strong>. Look at the example below:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image18.png" rel="prettyPhoto[430]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb18.png" width="638" height="224" /></a></p><p>If you use <strong><em><strong><em>complete namespace to the stuff you want to Mole</em></strong> + Moles + S + intellisense</em></strong> then you’ll get the stubbable instances instead like so:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image19.png" rel="prettyPhoto[430]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb19.png" width="637" height="225" /></a></p><p>In my scenario I wanted to make sure that when the <strong>LoadXml</strong> method is called on any <strong>BindingInfo</strong> object in my tests it doesn’t read stuff from my disk but it just returns or initializes any properties I’m interested in. This is how I would write this:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image20.png" rel="prettyPhoto[430]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb20.png" width="638" height="190" /></a></p><p>A quick recap:</p><ul><li><strong>MBidingInfo</strong> was found using the <strong><em>complete namespace to the stuff you want to Mole + Moles + M + intellisense</em></strong> method mentioned above.</li><li><strong>AllInstances</strong> means that for all instances I want to replace some method with my own delegate.</li><li><strong>LoadXmlString</strong> is the method I want to Mole. After a while using Moles you’ll see that methods have there original name followed by the Type of the input parameters if any.</li><li>Then I’ve written my delegate declaration and body that takes in two parameters called instance and path.</li></ul><p>To make this even more interesting you can add Asserts in the delegate (I say you can, I’m not sure this is a good practice) like the following picture:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image21.png" rel="prettyPhoto[430]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb21.png" width="639" height="216" /></a></p><p>Now I can continue writing my test as if my <strong>BindingInfo</strong> objects had loaded the xml from file. But how can I verify that some Moled method has been called? Well Moles doesn’t intend to provide you with Mocking framework abilities that you might be used to. Instead you’ll have to do this yourself. Here is a simple example how to test if a method is called.</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image22.png" rel="prettyPhoto[430]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb22.png" width="638" height="357" /></a></p><p>So this was a real short introduction to Moles that I hope helps you come up to speed quickly. The final point that I would like to make is that you can use this on any .Net object even static or sealed objects like <a
title="DirectoryInfo" href="http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx"><strong>DirectoryInfo</strong></a> for instance (try using the code below without Moles):</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image23.png" rel="prettyPhoto[430]"><img
style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb23.png" width="635" height="377" /></a></p><p>Big thanks to my colleague <a
title="Marcus Hammarberg" href="http://www.marcusoft.net" target="_blank">Marcus Hammarberg</a> for challenging me to write this post!</p><p>Enjoy,</p><p>Hugo</p> ]]></content:encoded> <wfw:commentRss>http://www.hugohaggmark.com/2011/09/12/how-i-used-moles-in-a-real-life-biztalk-scenario/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>How do I find stuff in TFS 2010?</title><link>http://www.hugohaggmark.com/2011/09/09/how-do-i-find-stuff-in-tfs-2010/</link> <comments>http://www.hugohaggmark.com/2011/09/09/how-do-i-find-stuff-in-tfs-2010/#comments</comments> <pubDate>Fri, 09 Sep 2011 11:32:00 +0000</pubDate> <dc:creator>Hugo Häggmark</dc:creator> <category><![CDATA[Team Foundation Server]]></category> <category><![CDATA[Tips]]></category><guid
isPermaLink="false">http://www.hugohaggmark.com/2011/09/09/how-do-i-find-stuff-in-tfs-2010/</guid> <description><![CDATA[Background The other day I was coaching a colleague and I got the excellent question about how to find stuff in TFS 2010. So I explained to my colleague about some of the different ways you can find stuff and realized that this would be an excellent and hopefully informative post for me and others. [...]]]></description> <content:encoded><![CDATA[<h2>Background</h2><p>The other day I was coaching a colleague and I got the excellent question about how to find stuff in <a
title="TFS" href="http://msdn.microsoft.com/en-us/vstudio/ff637362" target="_blank">TFS</a> 2010. So I explained to my colleague about some of the different ways you can find stuff and realized that this would be an excellent and hopefully informative post for me and others.</p><h2>Scenario 1: you know the Id of the Work Item you’re looking for</h2><p>If you’ve ever worked with TFS for a while you’ll (hopefully) start to memorize (unconsciously) the unique Id’s for the tasks, bugs, user stories, test cases e.t.c. that you work with. If this is your case then you have 3 very fast ways of accessing these Work Items fast.</p><h3>Inside <a
title="Visual Studio" href="http://www.microsoft.com/visualstudio/en-us" target="_blank">Visual Studio</a></h3><ol><li>Right-click the Work Items node and choose Go to Work Item<a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image5.png" rel="prettyPhoto[405]"><img
style="background-image: none; border-right-width: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb5.png" width="598" height="467" /></a></li><li>…enter an Id <br
/><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image6.png" rel="prettyPhoto[405]"><img
style="background-image: none; border-right-width: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb6.png" width="252" height="125" /></a></li><li>and wooops there it is. <br
/><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image7.png" rel="prettyPhoto[405]"><img
style="background-image: none; border-right-width: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb7.png" width="601" height="342" /></a></li></ol><p>Or if mouse clicking isn’t your way of life add a keyboard shortcut that does the same thing as shown below: <br
/><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image8.png" rel="prettyPhoto[405]"><img
style="background-image: none; border-right-width: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb8.png" width="642" height="377" /></a></p><h3>Inside the Team Portal and Team Web Access</h3><p>On your Team Project Portal you should have a textbox that will do the same as the Go to Work Item above inside Visual Studio. It will look something like this:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image9.png" rel="prettyPhoto[405]"><img
style="background-image: none; border-right-width: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb9.png" width="479" height="177" /></a></p><p>The exact same textbox is present in Team Web Access and look like this:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image10.png" rel="prettyPhoto[405]"><img
style="background-image: none; border-right-width: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb10.png" width="488" height="189" /></a></p><h2>Scenario 2: you don’t know the Id of the Work Item you’re looking for</h2><p>Let’s pretend that you don’t remember your Id’s or perhaps you’re a new team member on an ongoing Team Project, what do you do then?</p><p>Well you could go through all of the work items and search for the ones you’re really interested in <img
style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Ler" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/wlEmoticon-smile1.png" /> or you could search for Work Items. This is in my experience a somewhat unknown functionality that I would really love to have inside Visual Studio but if you go your Team Web Access you can actually search for words in title or description fields as shown below:</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image11.png" rel="prettyPhoto[405]"><img
style="background-image: none; border-right-width: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb11.png" width="633" height="309" /></a></p><h2>Scenario 3: you need to filter out an massive amount of Work Items</h2><p>The best way to find, filter and structure you Work Items is to create good Team Queries, and I will not go into details how you accomplish this but I will give you a great tip.</p><ol><li>Take an existing Work Item Query and choose Edit Query</li><li>Change it the way you want it</li><li>Save it as your own Work Item Query or as a new Team Query (use folders to create even better structure)</li></ol><p>Another great tip is to open your Work Item query in Excel and then use the power of Excel to filter stuff.</p><p><a
href="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image12.png" rel="prettyPhoto[405]"><img
style="background-image: none; border-right-width: 0px; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.hugohaggmark.com/wp-content/uploads/2011/09/image_thumb12.png" width="636" height="235" /></a></p><h2>Scenario 4: use the power of search in <a
title="SharePoint" href="http://sharepoint.microsoft.com/en-us/Pages/default.aspx" target="_blank">SharePoint</a></h2><p>The best way to find information in SharePoint items and in documents on your Team Portal is to use the awesome powers of SharePoint Search. Here is a <a
title="SharePoint 2010 Search Sheet" href="http://download.microsoft.com/download/6/6/B/66B69E5C-0010-4D8E-8DB9-C7120E818654/SharePoint%202010%20Search%20Datasheet.pdf">sheet</a> explaining some of the cool features in the box.</p><p>Enjoy,</p><p>Hugo</p> ]]></content:encoded> <wfw:commentRss>http://www.hugohaggmark.com/2011/09/09/how-do-i-find-stuff-in-tfs-2010/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
<!-- Served from: www.hugohaggmark.com @ 2013-05-22 18:55:31 by W3 Total Cache -->