DotNetSaps: Unit Testing

It was my turn to present to the DotNetSaps. Here are the slides and code to score bowling games that I wrote during the presentation.  Get NUnit, FitNesse and look at XProgramming.com for more information on unit testing.

Note on the code: This code is not done. There are at least three bugs in it, but it passes all of the tests. This means that there are more tests to write.  Here are some that would fail:

public void testNonStrikeAfterDoubles()
{
  game.bowl(10);
  game.bowl(10);
  game.bowl(5);
  game.bowl(5);
  assertEquals(game.getScore(), 55);
}

public void testSimpleEndOfGame()
{
  for (int i = 0; i < 10; ++i) { 
    game.bowl(0); 
    game.bowl(0); 
  } 
  assert(game.getIsOver()); 
} 

public void testEndOfGameStrikeInTenth() 
{ 
  game = new BowlingGame(); 
  for (int i = 0; i < 10; ++i) { 
    game.bowl(10); 
  } 
  assert(!game.getIsOver()); 
}

Not to mention scoring the tenth frame correctly. Fixing those tests and finding others is left as an exercise to the reader.