Monday, November 5, 2007

Test Driven Developement

To begin our first sample we start VS and create an empty solution. The we add a class library project and call it e.g. DomainObjects. We add a second class library project and call it DomainObjects.Tests. This will be our test project. It is a good practice to always keep your tests in separate projects.

Add a new class to the Test project and call it PersonFixture. I always use the naming convention which takes the name of the class to test and appends a "Fixture" postfix.

We want to start immediately with the testing and as such rely on the infrastructure provided by the Rhino Tools. Add a reference to the Rhino.Commons and the Rhino.Commons.ActiveRecord assemblies. Now the PersonFixture class should inherit from the FixtureBase class (of the namespace Rhino.Commons.ForTesting).

Set up the environment

In this first chapter I want to describe the environment I set up for my day to day developement. I use a dual core pentium with 4 GB of RAM. Initially I installed Windows Vista Ultimate 32bit edition on this machine. But unfortunately the 32bit edition of Vista can only use 3 GB of the available RAM. Since about 2 weeks now I use Vista 64bit and I am really happy with it. The only issues I had up to now is that unit test with Resharper are not working any more. This is not so dramatic since I can still use TestDriven (with either MbUnit or NUnit) for my unit testing. My overall impression is that Vista 64bit really improved the performance of the system. But I have no statistical data to confirm this... So now let's have a look at the software I installed Windows and Applications
  • Windows Vista Ultimate 64bit Edition
  • Process Explorer v11.03
  • MS Virtual PC 2007 (x64)
  • VMWare 6.02
  • AVG Antivirus 7.5 Free Edition
  • 7-ZIP
  • KeePass 1.07
  • Free Commander 2007.05a
  • Notepad2
  • Spamihilator 0.9.9.32
  • Omea Reader 2.2.1
  • Paint.Net 3.10
  • MS Office 2007 Ultimate

Developement

  • VS 2005 Professional
  • VS 2005 SP1
  • VS 2005 SP1 Update for Windows Vista
  • MS SQL Server 2005 Developer Edition
  • Visual Source Safe 2005
  • ReSharper 3.02 Full Edition
  • Reflector
  • DevExpress 7.2 (Grid, Bars, NavBar)
  • TortoiseSVN 1.4.5.10425 (64 bit)
  • NUnit 2.4.0
  • TestDriven.NET 2.7 Beta

Preparing the System

Having installed all the software mentioned above I can now start to download and compile the OSS (=Open Source Software) that I need for my developement. In all my current projects I use NHibernate as my ORM (=object relational mapping) tool. Most of the time though I use NHibernate in conjunction with ActiveRecord (from the Castle Project) which facilitates its use.

I use the Windsor Container of the Castle Project as my IoC (=inversion of control) container.

Up to now most of my projects had WinForms based clients.

Oren Eini is and has been very active in the OSS scene. He has a nice set of tools available. It's called the Rhino Tools. These tools are based on and extend the other frameworks mentioned above. As a consequence I can download and compile the Rhino Tools and I have every thing I need.

Prepare a directory where you want to download the source (e.g. c:\dev\oss\rhino-tools).

Download the source (e.g. with the TortoiseSVN client) from the following URL:

http://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk

As soon as the download is finished browse to the rhino-tools directory and build the whole collection of solutions. You can do this by just executing the "DoBuild.bat" batch command or by opening a VS command window and entering the following command

msbuild buildall.build

For my purposes I only need the rhino-commons library. I browse to the corresponding bin directory and copy all files into my SharedLibs folder which I use for my own solutions.