Back from holiday to find my DDD Southwest session has been accepted

Got back from holiday today to find my DDDSW (26th May) session on unit testing in Visual Studio 11 has been accepted. I see the event is already full, but hope to see some of you there

April 16, 2012 · 1 min · Richard Fennell

Fix for problem faking two SPLists in a single unit test with Typemock Isolator has been released

A blogged a while ago about a problem faking multiple SPList with Typemock Isolator in a single test. With the release of Typemock Isolator 7.0.4.0 you no longer have to use the workaround I documented. You can now use the code if the originally planned, and it works as expected 1: public partial class TestPage : System.Web.UI.Page 2: { 3: public TestPage() 4: { 5: var fakeWeb = Isolate.Fake.Instance<SPWeb>(); 7: Isolate.WhenCalled(() => SPControl.GetContextWeb(null)).WillReturn(fakeWeb); 8: 9: // return value for 1st call 10: Isolate.WhenCalled(() => fakeWeb.Lists\["Centre Locations"\].Items).WillReturnCollectionValuesOf(CreateCentreList()); 11: // return value for all other calls 12: Isolate.WhenCalled(() => fakeWeb.Lists\["Map Zoom Areas"\].Items).WillReturnCollectionValuesOf(CreateZoomAreaList()); 13: } 14: 15: private static List<SPListItem> CreateZoomAreaList() 16: { 17: var fakeZoomAreas = new List<SPListItem>(); 18: fakeZoomAreas.Add(CreateZoomAreaSPListItem("London", 51.49275, -0.137722222, 2, 14)); 19: return fakeZoomAreas; 20: } 21: 22: private static List<SPListItem> CreateCentreList() 23: { 24: var fakeSites = new List<SPListItem>(); 25: fakeSites.Add(CreateCentreSPListItem("Aberdeen ", "1 The Road, Aberdeen ", "Aberdeen@test.com", "www.Aberdeen.test.com", "1111", "2222", 57.13994444, -2.113333333)); 26: fakeSites.Add(CreateCentreSPListItem("Altrincham ", "1 The Road, Altrincham ", "Altrincham@test.com", "www.Altrincham.test.com", "3333", "4444", 53.38977778, -2.349916667)); 27: return fakeSites; 28: } 29: 30: private static SPListItem CreateCentreSPListItem(string title, string address, string email, string url, string telephone, string fax, double lat, double lng) 31: { 32: var fakeItem = Isolate.Fake.Instance<SPListItem>(); 33: Isolate.WhenCalled(() => fakeItem\["Title"\]).WillReturn(title); 34: Isolate.WhenCalled(() => fakeItem\["Address"\]).WillReturn(address); 35: Isolate.WhenCalled(() => fakeItem\["Email Address"\]).WillReturn(email); 36: Isolate.WhenCalled(() => fakeItem\["Site URL"\]).WillReturn(url); 37: Isolate.WhenCalled(() => fakeItem\["Telephone"\]).WillReturn(telephone); 38: Isolate.WhenCalled(() => fakeItem\["Fax"\]).WillReturn(fax); 39: Isolate.WhenCalled(() => fakeItem\["Latitude"\]).WillReturn(lat.ToString()); 40: Isolate.WhenCalled(() => fakeItem\["Longitude"\]).WillReturn(lng.ToString()); 41: return fakeItem; 42: } 43: 44: private static SPListItem CreateZoomAreaSPListItem(string areaName, double lat, double lng, double radius, int zoom) 45: { 46: var fakeItem = Isolate.Fake.Instance<SPListItem>(); 47: Isolate.WhenCalled(() => fakeItem\["Title"\]).WillReturn(areaName); 48: Isolate.WhenCalled(() => fakeItem\["Latitude"\]).WillReturn(lat.ToString()); 49: Isolate.WhenCalled(() => fakeItem\["Longitude"\]).WillReturn(lng.ToString()); 50: Isolate.WhenCalled(() => fakeItem\["Radius"\]).WillReturn(radius.ToString()); 51: Isolate.WhenCalled(() => fakeItem\["Zoom"\]).WillReturn(zoom.ToString()); 52: return fakeItem; 53: } 54: 55: } A check of the returned values shows ...

April 2, 2012 · 2 min · Richard Fennell

More community TFS build extensions documentation

As part of the on-going effort in documentation I have recently published more documentation for the TFS build extension project activities AssemblyInfo CodeMetric (updated) and CodeMetricHistory File Twitter

March 29, 2012 · 1 min · Richard Fennell

Unit testing in VS11Beta and getting your tests to run on the new TFSPreview build service

One of my favourite new features in VS11 is that the unit testing is pluggable. You don’t have to use MSTest, you can use any test framework that an adaptor is available for (at the release of the beta this meant the list of framworks on Peter Provost’s blog, but I am sure this will grow). So what does this mean and how do you use it? Add some tests First it is worth noting that you no longer need to use a test project to contain your MSTest, you can if you want, but you don’t need to. So you can ...

March 27, 2012 · 4 min · Richard Fennell

How I try to keep up to date

I have just added a page to the blog that lists some of the podcasts I try to listen to, in an attempt to keep up to date.

March 26, 2012 · 1 min · Richard Fennell

Keeping up to date

Ours is a fast moving industry and as times goes on I find the need to specialise more and more. However, I believe there is a great value in at least having a passing knowledge of as much of our field as possible, IT pros can learn from developers and .NET team from Java and of course the other way around. I find the best way to try to keep abreast of new ideas is to listen to podcasts; I personally find it hard read enough blogs, but I can find time to listen to a podcast whist travelling or working around the house. Here is a list of a few I find give me at least a feel for what is going on, I still feel that they are a bit Microsoft focused, so interested to hear any other suggestions ...

March 26, 2012 · 2 min · Richard Fennell

Problems editing TFS11 build templates in VS11Beta

Whilst writing documentation for TFS community build extensions (just published the Zip activity documentation) I hit upon a problem working with TFS11. The TFS community build extensions support both TFS2010 and TFS11beta, unfortunately the two versions need to be built separately (once against TFS2010 DLLs and once against TFS11 ones). As of version 1.3 of the extensions both versions are shipped in the download. In the past in the past I have tended to work in TFS2010 on this community project, but since the VS/TFS11 beta release I am trying to move over to the new build. So to write the documentation for the ZIP activity I started in TFS11. I followed the usual method to use a custom activity (there is no improvement over this frankly horrible process in VS11) so within VS11 I added the ZIP activity to a copy of the defaultprocesstemplate.xaml. All appeared OK but when I ran a build with this new template. I got the error ...

March 24, 2012 · 2 min · Richard Fennell

More thoughts on Typemock Isolator, Microsoft Fakes and Sharepoint

I posted yesterday on using Typemock and Microsoft Fakes with SharePoint. After a bit more thought I realised the key thing in using Typemock I found easier was the construction of my SPListItem dataset. Typemock allowed me to fake SPListItems and put them in a generic List then just make this the return value for the Item collection using the magic .WillReturnCollectionValuesOf() method that converts my List to the required collection type. With the Microsoft Fakes I had think about a delegate that constructed my test data at runtime. This is not a problem, just a different way of working. ...

March 24, 2012 · 2 min · Richard Fennell

Now that VS11 has a fake library do I still need Typemock Isolator to fake out SharePoint?

Updated 5 May 2012 Also see my follow up post, this corrects some of the information of faking SharePoint I have done posts in the past about how you can use Typemock Isolator to fake out SharePoint to speed design and testing. The reason you need special tooling, beyond standard mocking frameworks like Rhino or MOQ, is that SharePoint has many sealed private classes with no public constructors. So in the past you only had two options: Typemock Isolator and Moles from Microsoft research. ...

March 23, 2012 · 5 min · Richard Fennell

Typemock Isolator Version 7

Whilst travelling I had neglected to post about the new release of Typemock Isolator Version 7. This new release extends the range of the product to provide a variety of ‘test support tools’ that help you track down bugs sooner. However, the best new feature for me is that it allows support of historic versions of Isolator, this means you don’t have to upgrade all projects to V7 at the same time. The V7 engine will use the older assemblies e.g. V6 perfectly happily. Make managing build boxes far easier ...

March 22, 2012 · 1 min · Richard Fennell