Real Test Driven Development – Thinking of Money 4


The history functions, I was going to have two collections one for additions and one for subtractions, but in reality I think we can get away with only one and allow the interface code to decide how to display the information.

So the add and subtract routines need to add the money transaction object to a collection. First the test

        public void CheckHistory()
            _Engine.AddTransaction(10.10, "test category", "test description", DateTime.Now);

            List<MoneyTransaction> history = _Engine.History;

            Assert.AreEqual(1, history.Count);

We now need to add a history property to the engine class

        private List<MoneyTransaction> _History = new List<MoneyTransaction>();
        public List<MoneyTransaction> History
                return _History;

the following line is added to the add and subtract methods, after the new money transaction is created


This showed up a problem with the current code base, the money transaction class is currently declared private, which causes a build error with the property declared above, changing it to public solves this.


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