Esempio n. 1
0
def test_draw_strike_pins():
    g = Game()
    RollService.roll(g, 10)
    dc = Mock()
    d = DrawService(dc)
    d.draw(g)
    assert dc.draw_strike.call_args_list[0] == call()
Esempio n. 2
0
def test_draw_pins():
    g = Game()
    for i in range(5):
        RollService.roll(g, i)
    dc = Mock()
    d = DrawService(dc)
    d.draw(g)
    assert dc.draw_pins.call_count == 5
Esempio n. 3
0
def test_draw_spare_pins():
    g = Game()
    RollService.roll(g, 2)
    RollService.roll(g, 8)
    dc = Mock()
    d = DrawService(dc)
    d.draw(g)
    assert dc.draw_pins.call_args_list[0] == call(2)
    assert dc.draw_spare.call_count == 1
Esempio n. 4
0
def test_save():
    stream = Mock()
    g = Game()
    RollService.roll(g, 3)
    SaveService(stream).save(g)
    assert stream.write_header.call_count == 5
    assert stream.write_footer.call_count == 5
    assert stream.write_count.call_args == call(1)
    assert stream.write_body.call_args == call(3)
Esempio n. 5
0
def test_draw_score():
    g = Game()
    for i in range(5):
        RollService.roll(g, i)
    dc = Mock()
    d = DrawService(dc)
    d.draw(g)
    assert dc.draw_score.call_count == 3
    assert dc.draw_score.call_args_list[0] == call(1)
    assert dc.draw_score.call_args_list[1] == call(6)
    assert dc.draw_score.call_args_list[2] == call(10)
Esempio n. 6
0
 def do_roll(self, pins):
     RollService.roll(self.game, int(pins))
     self.draw_game()