harriyott.com

Wednesday, June 29, 2005

TeamTest and merge modules

TeamTest doesn't work if there's a setup project in the solution. I've had error messages like: "Package 'LoadTestPackage' has failed to load properly...", "Exception has been thrown by the target of an invocation" and "Illegal characters in path".

The simplest workaround is to create a new solution and include the code project and the unit test project, but not the merge module. Any changes to the code will be reflected in both solutions.

I've reported it as a bug, so we'll see what happens.

CodeSmith is becoming really useful

We have a couple of dozen objects that get passed around in XML, and need to be stored in the database. We've written a base class to do the grunt work, but at some point, each item in the XML needs to be mapped to a parameter in a stored procedure. We started with all the database tables, and all the XML schemas, but nothing in between. There are various artifacts that need producing to get the process working from end to end.

Once the first XML to database process was finished, I used each of the major artifacts as the basis for a CodeSmith template. Using these templates, I was able to generate the next set in the time it took my colleague to work out why TeamTest was crashing when testing something using the Enterprise Library (i.e. a couple of hours).

The templates generate:
  1. A stored procedure to insert a row into the table
  2. A TSqlUnit test for this stored procedure
  3. A class derived from the base class that sets up the correct configuration file
  4. A unit test class that checks this class
  5. A stored procedure used by this unit test
  6. The basis of the mapper file
  7. The extra lines to put in the database installer script
The XPath must still be pasted into the mapper file, but this takes only five minutes, and can't be automated. This step actually needs some kind of analysis; the rest is just routine stuff that we don't need to spend time on.

Tuesday, June 28, 2005

TeamTest and renaming assemblies

Having renamed the output assembly, I spent ages trying to work out where the old assembly name was being referenced from when running the unit tests. It wasn't any of the config files. It seems that the "Test View" pane needs a manual refresh to pick up the change.

@@IDENTITY and SCOPE_IDENTITY() in SQL Server

I've just been told about @@IDENTITY, and how it won't always do as expected. When running a stored procedure that does something like the following:

INSERT INTO TEST VALUES( 1, 2, 3, 4, 5)
SELECT @ReturnValue = @@IDENTITY

the @@IDENTITY returns the value of the new row's identity field. If there's a trigger on the table that inserts data into another table, then @@IDENTITY will contain the ID from that table, not the one expected. This is because @@IDENTITY is global. SCOPE_IDENTITY() is local, so the following will return the same value whether there is an insert trigger or not:

INSERT INTO TEST VALUES( 1, 2, 3, 4, 5)
SELECT @ReturnValue = SCOPE_IDENTITY()

Therefore, one should use SCOPE_IDENTITY() instead of @@IDENTITY.

Thursday, June 23, 2005

FxCop code analysis error

I've just finished getting rid of FxCop warnings in TeamTest, and I get this error:

* Object reference not set to an instance of an object.
at Microsoft.Tools.FxCop.Command.FxCopCommand.Main(String[] args)

It will be fixed in the final release, but that's not until November.

Wednesday, June 22, 2005

Geek dinner

Just had another fantastic Sussex geek dinner.

http://sussex.geekdinner.co.uk

Friday, June 17, 2005

The problem with .NET 2.0 beta...

...isn't that there's some minor changes that the compiler picks up and tells you how to fix, it's that everything else takes a long time to catch up. The Enterprise Library Configuration Console add-ins don't seem to work if written in .NET 2.0; the MSBuild SDC tasks don't work either. Also, some handy tools, particularly Resharper aren't ready yet.

Another colleague with a website

The girl I sit next to at work is an artist as well as a coder, and sells her stencil-graffiti paintings. Her partner is a freelance web designer, so naturally there's a stunning website on which the pictures are mounted.

If you don't ask...

I asked my new boss for a RAM upgrade; I had only 512Mb, and I've now got 2Gb. Compile times seem to be at least twice as fast. What should I ask for next?

Saturday, June 04, 2005

Holiday

We attempted going on holiday to Devon today. Packed up the car and everything, stopped for lunch on the way. About 5 miles from Devon, the car broke down. Seems like some kind of hardware fault, which I don't really understand, as I'm a software guy. Anyway, there's this thing at the front of the car called an engine (a bit like a CPU, from what I understand), and it crashed, and won't reboot. Might have to get another one.

So we were towed home.



Twelve hours after we left, we arrived home again. We're going to try again tomorrow in the other car, which is loads smaller. We've optimised the luggage, so we're leaving behind one suitcase, a guitar, all food, and most of the clothes.

Friday, June 03, 2005

Superbowl advertising


Some people will advertise anywhere!

Thursday, June 02, 2005

Geek dinner website

Lee has very kindly set up a Sussex section on his geek dinner site.