Thursday, October 26, 2006

After playing with Visual Studio Team System for a while, the biggest draw back I have seen so far in the Developer SKU is that I can't get my unit tests to run with a build. A team build requires a test list and the only way to create a test list is through Test Manager and that is only available in the Tester SKU. Fortunately, I have Team Suite so I was able to create a test list, but the downside is that where I work, I am one of the only people with Team Suite, so every time a developer creates a new unit test, I am the lucky one who gets to add it to the list. After doing this a couple of times, I found it got old very fast, so I started to look at the vsmdi file that contains the test information and found it was a pretty simple xml file. The simplicity ended very quickly, though, when I found the Guid created for each test in the list is not just generated with Guid.NewGuid(). I did some hunting on the web to figure out how this Guid is created, but came up empty, so I decided it was time to bring out my old friend ILDasm and see what happens under the covers. For anyone interested (and I can't guarantee it will stay like this since the code was not in a publicly exposed API), the below method will generate the correct Guid for a test (where FullName is the fully qualified name of the method <Namespace>.<Class>.<Method> - since test methods never take parameters, method overloading is not an issue).

private Guid GuidFromString()
{
  
SHA1CryptoServiceProvider provider = new SHA1CryptoServiceProvider();
  
byte[] buffer1 = provider.ComputeHash(Encoding.Unicode.GetBytes(FullName));
  
byte[] buffer2 = new byte[0x10];
  
Array.Copy(buffer1, buffer2, 0x10);

  
return new Guid(buffer2);
}

I am still in the process of creating an application that will create test lists like what is created with the Tester SKU, but I wanted to post this in case other people are struggling to find the same algorithm for their needs.

10/26/2006 10:12:04 AM (Pacific Daylight Time, UTC-07:00)  #    Disclaimer  |  Comments [41]  | 
Related Posts:
Test Management tool
Start and Stop Biztalk 2006 Applications