The project I’m working on now has a huge need for auto-update. Strangely enough, there aren’t a whole lot of documented solutions for an auto-update application for .Net 1.1. In the 2.0 world you have ClickOnce, which handles those sorts of things for you (and in a way that isn’t terribly difficult to manage as a developer…as long as you pay attention to what your doing), but the only real option you get from MS on this is the AutoUpdater Application Block from the Patterns and Practices guys. I took a look at this when it was in it’s 1.0 version a while back, and really didn’t care for it much. The big reason was that it required you set up an AppStart.exe file, which would take a look at your config file to determine which directory to start the app from. When updates arrived, they were put in new directories based on versions. This seemed like a lot of effort, and a lot of overhead. The good news is that there is now a 2.0 version of the application block, and it looks like it is much more configurable, and has the ability to do inproc updates.
So here is my issue. I want to change the default downloader (used to retrieve the updated files) from the BITSDownloader that ships with the block to one which will allow me to copy files from a UNC path. Fortunately, a sample implementation of such a thing exists in the documentation, so there is a starting point. It is pretty rough around the edges, and isn’t testable, so I am working creating a nicer, testable version of the sample downloader. Here is the problem, though; the dependencies are insane! And it doesn’t look like even mock objects will be able to help. Initially I found this a little strange since I know that the Patterns and Practices group was headed up by some folks who were heavy into the Agile methodologies. I also know for a fact that the Enterprise Library components have test included. So I pulled up the AutoUpdater Application Block to see how they were testing things….and what do you think I found? They were not testing anything! I can only assume that the updater block came from another group, because there was no tests in sight. So, since I had the source code, I’m reduced to making modifications to the block to support testing. For the most part this involved marking public methods/properties as virtual so that Rhino.Mocks can mock them. I also added some parameters to the constructor of the UpdateTask class so that I could supply mock versions of some of the dependencies.
I can’t imagine trying to test this without the source code to modify…as it stands I don’t feel real good about shipping around a non-standard version of the library. Overall I’m quite disappointed in the P&P folks on this one. I had high hopes whenever I saw the rest of the Enterprise Library that I would be able to test my extensions fairly easily. I guess that goes to show that even in organizations (or specifically groups) where TDD is a best practice, it still is finding hurdles to acceptance.