Real Test Driven Development – Thinking of money


Right, so the program outline is

I run a balance sheet, so I know how much should be in my account at the bank, (they are never up to date) its a simple list of additions and subtractions with totals along the way.  The list only lasts a month, so its a sort of quick and dirty, balance sheet.

I want the program to reflect this, a way to input additions and subtractions, and display a balance. also it might be helpful if there was a way to have the standard bills, so at the start of the month I can request that the standard bills are added automatically.

Display should be simple, as I don’t want to have to write a help file.

as we are not going to store account details, numbers etc, I think that a simple database back end would be great, as in the future I want to have other programs that use this data for budgeting.

So its time to fire up visual studio.

I like to start with the business layer, its the easiest layer to test so its a good place to start. and by doing this I don’t have to think about how the interface or the storage will work.

after creating a c# class library project, I add a new folder to the project, called Unit Tests, I like to store the unit test classes with the project, I enclose the class definition within a #if(DEBUG) so that they are not included within a release version.

I then write a simple test, this is a safety net, if this fails then the setup for the unit tests is failing or they are not running correctly!,

I use nunit and Test Driven, to run my tests.  In visual studio I link the run tests command to [control][shift][T]. this means that my main commands are [control][shift][D] for Ghost doc, [control][shift][B] to build the project and  [control][shift][T] to run the tests. with all this I can just about develop without using the mouse.

ok so far I have a project with a single class in looking like

using NUnit.Framework;

namespace MoneyEngine.UnitTests
    public class TestMoneyEngine 
        public void Hook()
I use this format for every test class I create. so when this passes we are ready to start creating.


About Duncan Butler

Trying to be a very agile software developer, working in C# with Specflow, Nunit and Machine Specifications, and in the evening having fun with Ruby and Rails
This entry was posted in Projects. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s