예제 #1
0
 def test_score_hole(self):
     """
     Tests that the score of a frame is updated directly after the hole is finished
     """
     frame = BowlingFrame("test")
     self.assertTrue(frame.getScore() is None)
     frame.registerThrowing(4)
     self.assertTrue(frame.getScore() is None)
     frame.registerThrowing(5)
     self.assertEqual(frame.getScore(), 9)
예제 #2
0
 def test_score_strike(self):
     """
     Tests that the score of a frame is updated correctly after a single strike
     """
     frame1 = BowlingFrame("test")
     frame2 = BowlingFrame("test")
     frame1.registerThrowing(10)
     self.assertTrue(frame1.getScore() is None)
     frame2.registerThrowing(2)
     self.assertTrue(frame1.getScore() is None)
     frame2.registerThrowing(5)
     frame1.computeScore(frame2)
     self.assertEqual(frame1.getScore(), 17)
예제 #3
0
 def test_previous_score_hole(self):
     """
     Tests that the score of a frame is updated directly after the hole is finished, taking into account the
     previous score
     """
     frame = BowlingFrame("test")
     self.assertTrue(frame.getScore() is None)
     frame.registerThrowing(4)
     self.assertTrue(frame.getScore() is None)
     frame.registerThrowing(5)
     self.assertEqual(frame.getScore(), 9)
     frame.setPreviousScore(10)
     self.assertEqual(frame.getScore(), 19)
예제 #4
0
 def test_score_strike3(self):
     """
     Tests that the score of a frame is updated correctly after three strikes in a row
     """
     frame1 = BowlingFrame("test")
     frame2 = BowlingFrame("test")
     frame3 = BowlingFrame("test")
     frame1.registerThrowing(10)
     self.assertTrue(frame1.getScore() is None)
     frame2.registerThrowing(10)
     self.assertTrue(frame1.getScore() is None)
     frame3.registerThrowing(10)
     frame1.computeScore(frame2, frame3)
     self.assertEqual(frame1.getScore(), 30)
예제 #5
0
 def test_score_spare2(self):
     """
     Tests that the score of a frame is updated correctly after the spare and the strike of the next frame are
     finished
     """
     frame1 = BowlingFrame("test")
     frame2 = BowlingFrame("test")
     frame1.registerThrowing(9)
     frame1.registerThrowing(1)
     self.assertTrue(frame1.getScore() is None)
     frame2.registerThrowing(10)
     frame1.computeScore(frame2)
     self.assertEqual(frame1.getScore(), 20)
     self.assertTrue(frame2.getScore() is None)