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

        [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
        {
            get
            {
                return _History;
            }
        }

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

_History.Add(trans);

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.

Unknown's avatar

About Duncan Butler

I’m Duncan, an entrepreneur and co-founder behind nth.digital and The Puzzle Board, where I combine heritage‑focused creativity with modern technology. My work spans AI development, C# engineering, and collaborative problem‑solving with Squad, building smarter tools, streamlined workflows, and engaging digital experiences. Whether refining puzzle production systems or exploring new AI capabilities, I’m driven by creating practical, intuitive solutions that make technology feel effortless.
This entry was posted in Projects. Bookmark the permalink.

Leave a comment