The blogs of Black Marble staff

An Event to Remember

On Wednesday, we ran another of our triple-event days; great range of products covered and a lot of positive feedback.  We started with m’learned colleagues Rik and John demonstrating all you need to know about Microsoft CRM 4.0.  A hearty lunch readied the room for MSDN’s Eric Nelson and Mike Taulty from Microsoft and their exploration of Visual Studio 2008.  The day culminated with Oliver Sturm from DevExpress explaining Refactor Pro! A lot of positive feedback, with many developers going home happy – in particular the gentleman who walked away with a full license from DevExpress!

Our events our free, and if you’re interested in the current state … and future impact … of Architecture then come along to our next event – visit our website for more details.


[Resource]Developer and Architecture Guides (Updated 26th April)

With the slew of great Developer and Architecture Guides appearing I have decided that a central list of them all is in order. I am now marking my resource lists to help people find them in the slew of “interesting” comments in my blog.


Enterprise Library is up to 4.1 get it HERE

Windows 7 Developer Guide – A guide for developing Windows 7 - get it here

Acceptance Test Engineering Guidance Guidance book - get it here

Application Architecture Book 2.0  – get it here

WPF/Silverlight Composite Application guide – get it here

TFS Branching Guide (2) – get it here

Web Performance and Testing guide – get it here


A new set of rather snazzy Pocket Guides are out with overview sections which most people should read

  • Rich Client Architecture Pocket Guide  Rich Client Application Architecture

    Architecture and Design Guidelines ,Presentation Layer Guidelines , Business Layer Guidelines ,Data Access Layer Guidelines ,Service Layer Guidelines , Communication Guidelines ,Deployment Patterns

  • RIA Architecture Pocket Guide

    RIA Architecture ,

    Design Guidelines  Presentation Layer Guidelines , Business Layer Guidelines ,Access Layer Guidelines,  Service Layer Guidelines ,Communication Guidelines , Deployment Patterns

  • Web Application Architecture Pocket Guide

    Web Application Architecture  Design Guidelines , Presentation Layer Guidelines , Business Layer Guidelines,  Data Access Layer Guidelines,  Service Layer Guidelines, Communication Guidelines , Deployment Patterns

  • Service Architecture Pocket Guide

    Service Architecture , Designing Services ,Service Layer Guidelines ,Communication Guidelines, Service Layer Checklist

  • Agile Architecture Method Pocket Guide

    Agile Architecture Method , Step 1 - Identify Objectives , Step 2 - Identify Key Scenarios ,Step 3 - Application Overview, Step 4 - Key Hot Spots , Step 5 - Candidate Solutions , Reviewing Your Architecture ,Communicating Your Architecture

  • Mobile Architecture Pocket Guide

    Mobile Application Architecture , Architecture and Design Guidelines , Presentation Layer Guidelines ,Business Layer Guidelines , Data Access Layer Guidelines , Service Layer Guidelines ,Communication Guidelines , Deployment Patterns


  • Entering a license key for Typemock Isolator if you are not administrator

    To license an installation of Typemock Isolator you run the Configuration tools and type in the key, you don’t get the option to enter the key during the installation. When I tried to run this tool today I got the error


    Now at first I thought it might be that I was on a64bit OS and it was looking in a portion of the registry for 32bit applications. However I was wrong it was far simpler than that.

    I am no longer running as administrator on my development box, so when I installed Typemock I was asked for elevated privileges via the UAC and all was OK. The configuration tool also needed to run at this privileges so it could update the registry, so the simple fix is that you just need to call the tool with a RunAs option and all is OK

    Windows 7 on the Dell Mini

    I don’t recommend having automatic update switched on (which is the default) for Windows 7. Yesterday my Windows 7 install decided to install 20 updates. It rebooted and then rebooted again and again. My guess is that a driver updated and killed the boot process.

    It did try to go into the automatic fix, but this just said it could not fix the issue, maybe it was a driver issue. I could not find an equivalent to safe mode to try to delete the updates, so today I am re-installing. This time making setting a system restore point so I can rollback if the same happens again

    TypeMock Isolator, SPTypeMock and SharePoint testing

    I had to work unexpectedly from home yesterday, this has given me a chance to look at TypeMock Isolator and SPTypeMock to aid in the testing of SharePoint without the normal disturbances of being in the office.

    First thing I have to say is TypeMock is an amazing tool, OK it costs some money, unlike RhinoMocks, but it’s ability to mock out sealed classes that have no public constructors is essential when testing SharePoint (which seems to contain nothing but sealed classes with no public constructors).

    I decided to try to retro-fit some tests to an old existing WebPart.This was a simple contact form that populated some combo-boxes from SPList collections then saved it’s results to another SPList. This had all been coded making direct calls to the SPList objects as required from within the WebPart. All very old school VB6 style, no MVC pattern, so a block of legacy code that is hard to test. However, the beauty of using this mocking framework is that all you production code remains unaltered (though as we will see there is a good argument for designing/refactoring to aid testing).

    I first started with the SPTypeMock library. This CodePlex project has been produced by a pair of MOSS MVPs Carlos Segura ( and Gustavo Velez ( ). It provides a set of wrapper classes in the form MockSPList etc. classes that you can use to construct the the SharePoint mocks, basically they hide some of the TypeMock constructions. This means that test logic ends as follows (using the sample from CodePlex)

    Mocking a List Collection
    -- Method to be tested:

            public static string TestMock_02()
                string strReturn = String.Empty;
                    using (SPSite mySite = new SPSite("http://MiServidor"))
                        using (SPWeb myWeb = mySite.OpenWeb())
                            int intTeller = 0;
                            foreach (SPList oneList in myWeb.Lists)
                            strReturn = intTeller.ToString();
                catch (Exception ex)
                    strReturn = ex.ToString();
                return strReturn;

    -- Mocking method:
            public void TestMethod2()
                MockSPSite mockSite = new MockSPSite("TestSite");          
                MockSPWeb mockWeb = new MockSPWeb("TestWeb");  
                MockSPList mockList0 = new MockSPList("MyList0");         
                MockSPList mockList1 = new MockSPList("MyList1");      
                MockSPList mockList2 = new MockSPList("MyList2");
                mockWeb.Lists = new MockSPListCollection(new[]             
                mockSite.Mock.ExpectGetAlways("RootWeb", mockWeb.GetInstance()); 
                SPWeb WebMocked = mockWeb.GetInstance();    
                using (RecordExpectations recorder = RecorderManager.StartRecording())    
                    SPSite SiteMocked = new SPSite("");    
                    recorder.ExpectAndReturn(SiteMocked.OpenWeb(), WebMocked);    
                string expected = "3";   
                string actual;
                actual = Program.TestMock_02();
                Assert.AreEqual(expected, actual);

    This works well, they have done a good job. You get a more readable way to express standard TypeMock structure. Yes, the SPTypeMock library is missing some bits, but is a first release and they make point out there is work to do themselves. You can always just write the mocks yourself as in basic TypeMock tests.

    However, I did not stop looking here, after doing a bit more reading I started to look at  Isolators' new AAA library (Arrange, Act, Assert) which I think first shipped with  5.1.0. This aims to hide much of the mocking process inside Isolator, by default an ‘empty fake’ is created for everything in the object tree being mocked and you just set values for the bits you care about. This makes it very easy to create a fake of a large system such as Sharepoint by using the magic Members.ReturnRecursiveFakes option

    This allowed me to greatly reduce the code required to setup by tests. I create a fake SPSite (and all the object under it) and then set the values for just the items I care about for the test.


    SPSite fakeSite = Isolate.Fake.Instance<SPSite>(Members.ReturnRecursiveFakes);

               Isolate.WhenCalled(() => fakeSite.RootWeb.Lists["Centre Locations"].Items).WillReturnCollectionValuesOf(
                   new List<SPItem> {
                       Isolate.Fake.Instance<SPItem>() });

               Isolate.WhenCalled(() => fakeSite.RootWeb.Lists["Centre Locations"].Items[0]["Title"]).WillReturn("Title1");
               Isolate.WhenCalled(() => fakeSite.RootWeb.Lists["Centre Locations"].Items[0]["Email Address"]).WillReturn("");

               Isolate.WhenCalled(() => fakeSite.RootWeb.Lists["Centre Locations"].Items[1]["Title"]).WillReturn("Title2");
               Isolate.WhenCalled(() => fakeSite.RootWeb.Lists["Centre Locations"].Items[1]["Email Address"]).WillReturn("");

               Isolate.WhenCalled(() => fakeSite.RootWeb.Lists["Centre Locations"].Items[2]["Title"]).WillReturn("Title3");
               Isolate.WhenCalled(() => fakeSite.RootWeb.Lists["Centre Locations"].Items[2]["Email Address"]).WillReturn("");

    This I think makes the unit testing of business logic within SharePoint viable without having to jump through too many hoops.

    Given the choice between the SPTypeMock and the AAA syntax I think I would stick with the latter, but you never know in the future. I suppose it will all come down to which syntax gives the quickest (and maybe more importantly easiest to read) tests in the future.

    I did say said I would come back to the application under test’s architecture. This simple WebPart, which contain a good selection of calls to SPLists and had client side validation has proved to be very hard to test, as you would expect. OK you have used TypeMock to get data into it, but how do you test it is in the right field? You can try to render the control but here are issues of WebPartManagers and script registration that frankly are not worth trying to fix. The better solution is some design for test, which I think for WebParts means MVC. In some ways this pattern would negate the need for TypeMock as you would create an IDataModel interface and have any test version you require, though of course you could mock this with TypeMock.

    All this said I am hugely impressed by TypeMock Isolator, a really powerful tool for the testing of complex platforms like SharePoint

    Strange guide to Ruby

    At the XP Club last night I was pointed at a web site that contains a very strange guide to Ruby ”Why’s (poignant) guide to Ruby”. This is one of strangest language books I have read in a while, probably since “Mr Bunny’s Guide to Active X”, which was described in its own blurb…

    “This is the first technology book by Carlton Egremont III, author of numerous lengthy grocery lists (unpublished), one or two letters to his mom (unsent), and a doodle on page 117 of the Rochester Public Library's copy of Moby Dick (overdue). Mr. Bunny's Guide to ActiveX makes a lovely gift for the nerd who has everything, and is perfect for propping up uneven table legs. For the high-tech parent there is simply no better antidote to yet another bedtime reading of "The Velveteen Rabbit" or the "OLE 2 Programmer's Reference". Just like Carlton, you and your children will come to believe in a talking bunny, a befuddled farmer, and a technology called ActiveX. “

    The strangest thing about these books is they are both a really good introduction to their subjects. As we have seen with the Head First series of books, training material can come in many forms, because people learn in many ways.