November 2008 - Posts

December XPClub Meeting
Sat, Nov 29 2008 7:28

The next meeting is on the 10th of December at Victoria Hotel in central Leeds at 7pm as usual.

The speaker is Gary Short who is speaking on Design Patterns. Come to this free event to find out more about this vital subject to developers in any language from an excellent speaker.

As an added bonus we will all head off to Leeds Christmas Market, to have some wurst, sauerkraut and continental lager.

Interesting news on test SharePoint
Tue, Nov 25 2008 6:48

Typemock announced today a new product Isolator for Sharepoint – which allows unit testing of Sharepoint code without needing Sharepoint installed. Now this is something I have been using the full version of Isolator for of late, and there are more blog posts on the way from me, so watch this space.

So if you are a Sharepoint developer this is an important product you should a least have a look at.

It is also interesting to see the promotion mechanism being used to get the word out onto the blogs, free license to the first 50 bloggers. So I would like to state my position here, I already have a Typemock Isolator license so this post has been written without the carrot of a free license, just written by an very impressed user.

Back from DDD7
Mon, Nov 24 2008 4:40

Another long day over the weekend at DDD7, but worth it. An excellent selection of sessions; I particularly liked Ben Hall’s on Pex and Jon Skeet’s on Linq.

A big thank you to the organisers for putting on such a successful event. It was noticeably fuller than past events, as we know DDD7 filled up in about four hours. Maybe time for a bigger venue, but would we lose the atmosphere?

The other option is for DDD style events around the country and to this end there were a few announcements yesterday. We already know about DD Scotland in May 2009, the new ones announced for Q2 2009 were

  • SQLBits 4 (Manchester)
  • Developer Day South West (Exeter)

Look out for more details was the organiser‘s call for speakers

Call for speakers for Developer Day Scotland is open
Fri, Nov 21 2008 5:27

The call for speakers at the DDS event on the 2nd of May 2009 is now open. So get your session proposals up and see if there is any interest.

I am not sure what I will propose, maybe something about testing Sharepoint

Entering a license key for Typemock Isolator if you are not administrator
Mon, Nov 17 2008 7:44

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

image

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
Fri, Nov 14 2008 5:35

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
Thu, Nov 13 2008 7:01

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 (http://www.ideseg.com) and Gustavo Velez (http://www.gavd.net ). 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;
            try
            {
                using (SPSite mySite = new SPSite("http://MiServidor"))
                {
                    using (SPWeb myWeb = mySite.OpenWeb())
                    {
                        int intTeller = 0;
                        foreach (SPList oneList in myWeb.Lists)
                        {
                            Debug.WriteLine(oneList.Title);
                            intTeller++;
                        }
                        strReturn = intTeller.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                strReturn = ex.ToString();
            }
            return strReturn;
        }

-- Mocking method:
        [TestMethod]
        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[]             
               {
                   mockList0,
                   mockList1,
                   mockList2
               });
 
            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.Swap.NextInstance<SPSite>().With(fakeSite);

           Isolate.WhenCalled(() => fakeSite.RootWeb.Lists["Centre Locations"].Items).WillReturnCollectionValuesOf(
               new List<SPItem> {
                   Isolate.Fake.Instance<SPItem>(),
                   Isolate.Fake.Instance<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("email1@email.com");

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

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

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
Thu, Nov 13 2008 5:06

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 *** (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.

TFS Power Toys
Sun, Nov 9 2008 4:42

I am not a fan of blog posts that are just a repeat of an announcement on other blogs, but in this case I think it is worth noting that the TFS October 2008 Release of the Power Toys are out.

The power toys are always interesting but the point of note here is the new shell integration for TFS. This means you can check in/out from Windows Explorer, thus in effect making it far easier to integrate third party products with TFS, like Dreamweaver or Expression Blend (OK not third party but has no TFS integration until version 3).

by But it works on my PC!
Filed under:
XPClub meeting on 12th November
Fri, Nov 7 2008 10:44

Next weeks meeting is at the Victoria Hotel in Leeds as usual at 7pm. It is going to be group discussion sort of session, the subjects being:

Daniel Drozdzewski is going to present the future of the computing (based on the article read in recent New Scientist about processors built on logic gates utilising the chaos phenomenon)

plus

moderated conversation about design in software projects

plus the usual gossip from the industry.

Hope to see you there, remember the event is free and so it at least the first beer.

NB. Remember next months meeting on the 10th of December is Gary Short’s excellent session on Patterns in software development

The future of paid conferences and other thoughts
Thu, Nov 6 2008 10:31

Whist at PDC and the VBug conference I have heard a a good deal of chat over the future of paying for conferences and user groups. This is in the light of all the PDC sessions being available on Channel9 in under 24 hours and that the content at the Vbug conference is also available at free events like DDD.

The question boils down to can a person or company justify paying a good few thousand Pounds, Euro or Dollars to fly half way round the world when they could see the same content at home? In my previous post on the PDC I suggested it was worth it for the networking, and I still think this is so. However, I have heard an interesting slant on this from more than one person; this is go to the city were the conference is but not to the actual conference; just taking in the parties and maybe watching content via the Internet where available.

For some people I think this might be a viable option; as long as you get the right party invites! For example at TechEd Europe there many community orientated events organised outside the conference because this is the one time most relevant people are in the same city. Also if you are in this group then you may struggle to find time to go to the actual conference so maybe this plan is viable or even preferred. However, for the average developer I am not certain it is the case, too much of the networking happens randomly inside the conference corridors and at meal tables. For this ‘outside the conference’ model to work you have to know who you want to meet and get invited to the right places/parties i.e. you need some profile in the community

As to the other point whether Vbug like events will continue I think we need to consider who they are aimed it. I had expected at the Vbug conference to see a lot of faces in the audience who I see at DDD, but this was not the case. There were a few but not a majority. Then again I don’t see the same faces at DDD as Alt.net. We have a number of distinct communities going on here, there is some cross over but not that much. I think the three broad groups are:

  • People who go to events (free or otherwise) during office hours – VBug attendees, and people who come to the events we host with Microsoft.
  • People who will go an event in their own time, but it is a passive learning experience – like DDD on a Saturday or a speaker at a user group
  • People who want to discuss what they do either in a user group over a beer or at an Open Spaces format conference – like Alt.net

We are never going to get all three groups merged into one. People will move from one to another and maybe attend all three, but that is their choice.

We are lucky in the UK that we have such an active and high quality community so all three groups can be supported, it will be interesting to see if any one type prevails (judged by attendance) as time goes on. However I do not expect to see any type disappear soon.

Page views not updated in community server
Thu, Nov 6 2008 10:02

Since we added the new themes to our community server we have not been getting any updates on the Blogs control panel as to the number of times a post has been viewed (by the aggregate views via RSS are incremented OK)

After a bit of digging it seems that we missing the IncrementViewCount flag on the in the post.aspx file. It should be as shown below.

<CSBlog:WeblogPostData Property="FormattedBody" runat="server" IncrementViewCount="true" />

If you miss this flag out you page shows OK but the statistics are not updated.

My VBug conference session on TFS
Wed, Nov 5 2008 15:07

You can find the slides for my Vbug sessions on the Black Marble web site.

I hope those you attended found it useful.

Going to conferences is worth it, well the chats in the corridor certainly are.
Tue, Nov 4 2008 16:54

I am down in Reading for the VBug conference where I am speaking on TFS tomorrow.

Whilst in the bar chatting to Roy Osherove from Typemock, the keynote speaker for the conference, he asked if I had looked at the Sharepoint patterns and practices document that details using Typemock Isolator for unit testing in Sharepoint.

On a first look it seems very interesting; as usual at this point  I just wonder how I missed the announcement of this document last month! Is is just me or does everyone struggle to keep up with the the blogs and site you should read?

patterns & practices Acceptance Test Engineering Guidance
Mon, Nov 3 2008 15:11

Robert blogged about the new beta release of the patterns & practices Acceptance Test Engineering Guidance document. I have had a chance to do a quick read now and I have to say I am impressed. If nothing else it gives great comparative look at waterfall and agile methods for delivery, and a review of many types of acceptance testing.

As with many of the p&p documents it is not exhaustive in what it covers, but what it does give is an excellent and detailed starting point for you to make the decisions that are right for your project. It does not give all the answers just most of the right questions.

Post PDC 2008 thoughts
Sun, Nov 2 2008 7:29

So back home now after a reasonable journey back from LA all things considered; so I have had a bit of time to reflect, was the PDC good?

Well I think I enjoyed my previous PDC in 2005 more, your first time always sticks in your memory. I think that this might be due to the fact that at the 2005 PDC LINQ was announced and it was a real left field thing, nobody seemed to see it coming. Due to the prior announcements (leaks) there was nothing that was not expected at this years PDC.

This said, it does not mean the the announcements were not important, for the future of Microsoft probably far more important than LINQ was. You could argue that Azure is more of an IT pro announcement, on a day to day basis it will certainly effect them, due to remote hosting of core services, more than developers who will still basically be using .NET via WCF, EF etc. just altering a connection string or two. So an announcement at the Professional Developers Conference was in itself interesting, but where else would Microsoft do it?

On a more step change for developers front, will Oslo change the world? Well in my opinion not yet, but this was a PDC so we expect the new ‘real’ product to be a few years out. Next year’s PDC 2009 I think will see the Oslo and Dublin technologies productify (is that a word?). It is worth comment that a PDC two years running is rare, so Microsoft must have something up their corporate sleeve.

Since getting back I have done the conference survey and I found one question interesting ‘does the fact that the sessions were all available via www.microsoftpdc.com effect your choice to go to the conference in the future?’. I have to say yes, but on reflection it was worth the trip. A conference is more than the keynote and breakout sessions, maybe there is a future in fully online conferences but it is not there for me yet. Whether I want to travel best part of half way round the world is a interesting point; a 2 hour flight to Barcelona did seemed attractive when sitting in Heathrow Terminal 5 prior to my11 hour flight. But I was lucky I suppose, a friend was off to Hawaii for an air compressor conference the same week I was in LA (each to their own I suppose). The location for me does not warrant the travel, the inside of a conference centre is much the same in any country. I suppose a factor here is how much time you spend in the conference against the beach, for me if you are going to a conference it is to learn not have a holiday (or hunt for swag!), but I am not sure all people have the same opinion here. Some people seem to see a conference a reward for work done in the year, so at treat not a learning experience.

So will I be at PDC 2009 – I expect so. Whether Black Marble send as many to the PDC as opposed to the various TechEds I am not sure, this is a discussion we need to have post conference season. We defiantly need to cover both types of conference, as does any forward looking Microsoft partner, but the ratio is the question.

As for me next it is the Vbug conference I am speaking on VSTS; I believe there are still spaces available, maybe I will see you there.

Team System Database GDR Edition RTM Released
Sat, Nov 1 2008 17:19

While I was at the PDC I missed the announcement that the release candidate for Database Edition was made, I was not following blogs too much. You can find all the download links for the RTM at Gert Drapers Blog, you can also see his PDC session where he made the announcement.

Why did I miss the session you might ask? well I was in Agile development with Team System session – some big improvement in Office integration with TFS

Anyway I have now installed the GDR edition and it is easy and fast, at least if you are upgrading from the previous version. I have not tried a virgin install which I am sure many people will be doing given that any person with Team System Developer license can download the Database GDR edition.