Unit Test Case Stub Generator for 100% Code Coverage

I've been a fan of Jonathan de Halleux's blog for a while now. He takes Unit testing to a new level with his mbUnit project. He's done some funky stuff with graphs. I really like his Reflector add in for generating call graphs and assembly references. For me, his add-ins were the reason for me to switch from an Anakrino to Reflector as my reverse engineering tool of choice (although I should have done that anyway).

I'm totally impressed with how much code this guy turns out in a given day. On Friday I was intrigued by his Automatic Unit Test Case generator - that is a Reflector add-in. He uses an IL graph to extract a code path to get full code coverage. OK so you still have to write the guts, but if  “the man” is making you write unit tests to demonstrate high %'s of code coverage, then this is what you need. Thanks Jonathan.

No wonder MS hired this guy.

BizTalk 2004 Presentation

I am doing a BizTalk 2004 presentation on Wed. June 16 at the Metro Toronto .NET User Group. So if you can make it please come.




ASP.NET apps account difference between IIS 5.0 and IIS 6.0

In 5.0 you use ASPNET account for your ASP.NET applications when you want access to certain items. In 6.0 you need to use the IIS_WPG account. 
In our particular case, we were configuring ADAM(Active Directory Application Mode) to be able to connect with calls coming from a webservice.  On the developer's box using Window XP and IIS 5, the ASPNET account was added.  Everything worked fine.   We then did a promotion to another machine, but this one was running Windows Server 2003 and hence IIS 6.  We added the ASPNET account as we thought we had to but to no avail in Windows Server 2003.  After spending a bit of time trying to figure out the problem, and using the frequent developer used phrase, “IT WORKED ON MY MACHINE“, the IIS_WPG account was added.
After everything was working, I looked on MSDN concerning the IIS_WPG account, and it is specified all over the place that you need to use this account in IIS 6.0.
I guess it pays to read the manual. :)

Recursion…the xsl way

Working with xsl, I found that there were a lot of examples containing a deeply nested xml such as the below sample xml where you can get any number of nodes any number of levels.  The examples really only showed where all of the nodes contained different names.










What I was looking to do was transform an xml that contained many nested levels of the same node with the same name.  Here is the sample xml.






                                                <Service />



                        <Service />


            <Service />     




After looking at different examples and working with them, I finally figured it out and worked out the below solution. 

<xsl:template match="TOPNODE">

            <xsl:for-each select="./Service">

                        <xsl:apply-templates select="."/>



<xsl:template match="Service">

            <xsl:if test="./Service">

                        <xsl:for-each select="./Service">

                                    <xsl:apply-templates select="."/>





All that needs to be done, is within the template of the node that is being used, just apply the same template again.  Easy, right?!?  I thought so.

Solved with just plain good ‘ol recursion.

.NET Rocks: Test Driven Development

I'm doing the .NET Rocks thing tonight regarding Test Driven Development with John Alexander. Now where is my harp.

Update: This show is now available for download. Click Here.

White-box Unit Testing - in whidbey

James Newkirk shows how to write a white-box test in Whidbey He shows how to test the value in a private field and invoke a private method. While you can (not so) easily do that today in NUnit, he demonstrates the PrivateObject class that lets you easily invoke private methods and look at private fields.

Could this “PrivateObject“ class be used for evil? Yes it could be used for evil - I imagine - but no more evil than that of reflection.

James has some great holy war type feedback about Should I or Shouldn't I white-box test. Those who say no probably haven't fought with unit testing a singleton class where we have to test it under multiple configurations that *normally* get set during the initial (private) constructor and/or the private methods called by the constructor. So yes, I can see a use. Is this an excuse? I haven't really thought of another technique....but to quote Michaelangelo, “I am still learning...” (via a silly set of fridge magnets I saw at Chapters today). The silly part of course is how one can learn from (and quote) a famous historical figure through something as silly as a fridge magnet.

DataSet Serialization: Smaller & Faster

DataSets serialize naturally to XML quite well and you have lots of control over that. Typed DataSets have the XSD with some properties that control that (and of course you can do it programmatically too). But one of the common problems with remoting DataSets is that the default binary serialization is actually just the XML Serialization ASCII. Crude. Some people have even used this fact to extrapolate that the DataSet is internally XML - which isn't true.

This is improved in Whidbey. But until then, what's a Serializer to do?

Lots of people have done some great work to do customized binary serialization of datasets. To mention a few:

  • Microsoft Knowledge Base Article 829740 by Ravinder Vuppula where he demonstrates his DataSetSurrogate class which wraps up a DataSet and converts the internal items into array lists which can then be Binary Serialized by the framework by default. It also contains a ConvertToDataSet so that you can reverse the process of a De-serialized surrogate back into a dataset.
  • Dino Esposito has demonstrates a GhostSerializer in his MSDN Article for a DataTable which does a similar ArrayList conversion thing.
  • Richard Lowe's Fast Binary Serialization
  • Dominic Cooney's Pickle
  • Angelo Scotto's CompactFormatter goes a step further with a serializable technique that doesn't rely on the Binary Formatter so it works on the Compact Framework which is event more Compact than the BinaryFormatter
  • Peter Bromberg builds on top of the CompactFormatter to support compression using Mike Krueger's ICSharpCode SharpZiplib in-memory zip libraries


Oh Canada, our home and....

You tell 'em Danny!

Google is king

If you open a browser on any of the 6 computers (including an IPAQ)  in my house, you will see www.Google.ca. It's safe to say Google is the official search engine of the Lloyd household. One of them actually defaults to French.

The other day my 10 year old son asked me if I knew that Google could help you shop on the internet.

I said “Yeah it's called Froogle.” "That's it", he said "Can you show me?" So I did.

While we were there I showed him a bunch of other cool features. He was amazed. So I thought maybe I should Blog some of my favorite Google Features.

If you know of others I don't mentioned please tell me. I love a good Google feature.

  1. Spelling: I'm sure people know about this feature. Those of us who can't spell sure do. If you type in something Google doesn't recognize Google will suggest a spelling correction to you. I get a lot of use out of this feature.
  2. Calculator: Did you know you can type a calculation into Google and it will give you an answer. Try typing this into Google: 5 * 5 and hit search. 
  3. More Google Calculator: The coolest thing the calculator does is conversions. If you want to know how many kilometers are in a mile just type into Google km in a mile and hit search, try ounces in a cup or cubits in a meter. Is that cool or what?      More about the Google Calculator.
  4. Define: Google is a dictionary. You can type define: someword and Google will return all the definitions it can find for that word. For fun type in define: Google
  5. Google Sets: I love this, but have not thought of a really useful application for it. Go to Google Sets  and type in a different related word in each textbox then click one of the set buttons below. Google goes out and finds other related items. Try this, enter Ross, Phoebe, Monica and see what you get. Now try DataSet and DataTable. This is really part of Google labs, see below.

There are others I would like to take advantage of but only seem to work in the US like Local search, phone book, maps.  Here is a complete list of Google search features .

Google Labs:

If you go to labs.Google.com you will find other google ideas that are not quite ready for main stream yet. They are ideas in progress.

  1. Personalized Web Search - Get personalized search results based on your interests
  2. Web Alerts - Find out about new web pages on a topic of interest  ( I subscribe to this. Any time ObjectSharp is mentioned on the web I get an email)
  3. Web Quotes - View search results with quotes about them from other sites
  4. Voice Search -Search on Google by voice with a simple telephone call
  5. Google Compute - Donate your computer's idle time to help scientific research
  6. Froogle Wireless - Search for products from your cell phone using Froogle
  7. Google Groups - Create and join searchable discussion groups and mailing lists

Did you notice not an add anywhere. :)

Happy Goggling

Code Reviews

Code Reviews

I suggest that we standardize on the tag REVIEW and we should append our username to make it clear who did the review. Here is an example for C# code.

// REVIEW: dunlop - Add copyright notice

Here is a link to how to create a custom annotation tag:


which requires VS and MSDN to work, or here is the important info from that link.

To create a custom comment token

A comment token is a character string that can be used in addition to the pre-defined tokens TODO, HACK, or UNDONE as your personal marker for notes in your code.

Note Characters permitted as comment tokens include alphanumeric characters, $, _, (, and ).

1. On the Tools menu, choose Options.
2. Choose Environment, and then choose Task List.
3. In the Comment tokens area, type a Name for your custom token.
4. From the Priority list, choose Normal, Low, or High.
5. Click Add, and then choose OK.

Note: Comments in HTML, .CSS, and .XML markup are not displayed in the Task List.

After adding the custom annotation tag then you will still need to enable 'comments' in the View : Show Tasks menu

What about Jeff Cooper's tool that he reviewed?