def test_with_given_open_frame_should_return_correct_value(self): frame = Frame((0, 9)) result = frame.calculate_value() expected = 9 self.assertEqual(result, expected)
def test_with_given_tenth_frame_triple_stike_should_return_30(self): frame = Frame((10, 10, 10)) result = frame.calculate_value() expected = 30 self.assertEqual(result, expected)
def test_with_given_tenth_frame_spare_and_strike_should_return_20(self): frame = Frame((9, 1, 10)) result = frame.calculate_value() expected = 20 self.assertEqual(result, expected)
def test_with_given_spare_should_return_10(self): frame = Frame((9, 1)) result = frame.calculate_value() expected = 10 self.assertEqual(result, expected)
def test_with_given_tenth_frame_non_stike_and_non_spare_should_return_correct_value( self): frame = Frame((2, 0)) result = frame.calculate_value() expected = 2 self.assertEqual(result, expected)
def test_with_given_spare_should_create_instance(self): shots = (1, 9) frame = Frame(shots) expected_shots = shots self.assertEqual(type(frame), Frame) self.assertEqual(frame.get_shots(), expected_shots)
def test_with_given_tenth_frame_double_stike_and_non_strike_should_return_correct_value( self): frame = Frame((10, 10, 9)) result = frame.calculate_value() expected = 29 self.assertEqual(result, expected)
def __init__(self): self.layout = Layout([ Field(level, 'field', { 'normal': State.parse( 'normal:(0,0)-(1,1)'), }), ]) super().__init__() Frame.start(self, True) Keys.start(self.stage) self.layout.mapping.field.start()
def test_with_given_10_frames_and_tenth_is_with_two_shots_and_stike_in_them_should_return_false( self): frames = [ Frame((1, 4)), Frame((4, 5)), Frame((6, 3)), Frame((5, 1)), Frame((1, 0)), Frame((1, 7)), Frame((3, 6)), Frame((4, 3)), Frame((2, 1)), Frame((10, 2)) ] result = BowlingGame.validate_frames(frames) self.assertEqual(result, False)
def test_with_given_10_frames_but_tenth_is_with_one_shot_should_return_false( self): frames = [ Frame((1, 4)), Frame((4, 5)), Frame((6, 3)), Frame((5, 1)), Frame((1, 0)), Frame((1, 7)), Frame((3, 6)), Frame((4, 3)), Frame((2, 1)), Frame((1, )) ] result = BowlingGame.validate_frames(frames) self.assertEqual(result, False)
def test_with_given_10_frames_and_tenth_is_with_three_shots_and_a_spare_in_them_should_return_true( self): frames = [ Frame((1, 4)), Frame((4, 5)), Frame((6, 3)), Frame((5, 1)), Frame((1, 0)), Frame((1, 7)), Frame((3, 6)), Frame((4, 3)), Frame((2, 1)), Frame((1, 9, 10)) ] result = BowlingGame.validate_frames(frames) self.assertEqual(result, True)
def test_with_given_game_should_return_correct_frames_list(self): total_shots = [ 1, 4, 4, 5, 6, 3, 5, 1, 1, 0, 1, 7, 3, 6, 4, 3, 2, 1, 6, 2 ] frames = BowlingGame.find_frames(total_shots) expected = [ Frame((1, 4)), Frame((4, 5)), Frame((6, 3)), Frame((5, 1)), Frame((1, 0)), Frame((1, 7)), Frame((3, 6)), Frame((4, 3)), Frame((2, 1)), Frame((6, 2)) ] self.assertEqual(frames, expected)
def test_with_given_correct_game_should_create_instance(self): total_shots = [ 1, 4, 4, 5, 6, 3, 5, 1, 1, 0, 1, 7, 3, 6, 4, 3, 2, 1, 6, 2 ] frames_expected = [ Frame((1, 4)), Frame((4, 5)), Frame((6, 3)), Frame((5, 1)), Frame((1, 0)), Frame((1, 7)), Frame((3, 6)), Frame((4, 3)), Frame((2, 1)), Frame((6, 2)) ] game = BowlingGame(total_shots) self.assertEqual(type(game), BowlingGame) self.assertEqual(game.get_frames(), frames_expected)
def start(self): self.racket.start() self.ball.start() Frame.attach(self.frame)
def test_with_given_tenth_frame_should_return_false(self): frame = Frame((9, 1, 10)) result = frame.is_spare() self.assertEqual(result, False)
def test_with_given_spare_should_return_true(self): frame = Frame((9, 1)) result = frame.is_spare() self.assertEqual(result, True)
def test_with_given_strike_should_return_false(self): frame = Frame((10, )) result = frame.is_spare() self.assertEqual(result, False)
def test_with_given_strike_should_return_true(self): frame = Frame((10, )) result = frame.is_strike() self.assertEqual(result, True)
def start(self): self.initposition() Frame.attach(self.frame)
def stop(self): Frame.detach(self.frame) self.speed_x = 0 self.speed_y = 0
def stop(self): Frame.detach(self.frame) self.ball.stop() self.racket.stop()
def start(self): Frame.attach(self.frame) Keys.register(Keys.LEFT, 'racket_left') Keys.register(Keys.RIGHT, 'racket_right')
def start(self): Keys.register(Keys.LEFT, 'pacman_left') Keys.register(Keys.RIGHT, 'pacman_right') Keys.register(Keys.DOWN, 'pacman_down') Keys.register(Keys.UP, 'pacman_up') Frame.attach(self.frame)
def stop(self): Frame.detach(self.frame)