Unit Testing – C# – Part 06 – Building Out the Class 4

In this blog we will continue testing our Scorer class by adding some statistics. Get the Number of Strikes and Spares We need to keep track of the number of Strikes and Spares thrown in a game. Let’s write the tests. [Test] public void Check10SparesWereThrown() { for (int _bowl = 1; _bowl <= 10; _bowl++) … More Unit Testing – C# – Part 06 – Building Out the Class 4

Unit Testing – C# – Part 05 – Building Out the Class 3

In this blog we will continue testing our Scorer class by adding Spares and Strikes. Adding Spares Looking at the rules for spares. If we knock down 10 pins with 2 bowls, we add 10 plus the value of the next bowl. Here is our failing test. [Test] public void CalculateScoreWithSpares() { _scorer.FrameScore(0, 0); Assert.That(_scorer.Score, … More Unit Testing – C# – Part 05 – Building Out the Class 3

Unit Testing – C# – Part 04 – Building Out the Class 2

This is a continuation of the last blog where we continue to create tests and code for our Tenpin Bowling Scorer class. Refactoring If you look at the code below you will notice we are instantiating the Scorer class in each test. [TestFixture] public class Scorer_NUnit_Tests { [Test] public void ShouldReturnPlayersName() { var _player = … More Unit Testing – C# – Part 04 – Building Out the Class 2

Unit Testing – C# – Part 03 – Building Out the Class 1

In the last blog I discussed the project structure and the unit testing frameworks I will use. In this blog I will begin building out the class and tests based on our business requirements. Players Name I need to enter a player’s name and have the ability to get it. I always start our defining … More Unit Testing – C# – Part 03 – Building Out the Class 1

Unit Testing – C# – Part 01 – Tenpin Bowling Scorer

In this tutorial series I will be showing how we can develop a ten pin bowling class to calculate a players score using Unit Testing. This makes a difference from the usual calculator demos you normally see. There are myriad of sources that explain Unit Testing and implementing classes using Test Driven Development (TDD), so … More Unit Testing – C# – Part 01 – Tenpin Bowling Scorer