示例#1
0
 def test_apres_un_lancer_dix_quilles_un_lancer_cinq_quilles_un_lancer_une_quille_un_lancer_deux_quilles(
         self):
     scorer = Scorer()
     scorer.effectuer_un_lancer(10)
     scorer.effectuer_un_lancer(5)
     scorer.effectuer_un_lancer(1)
     scorer.effectuer_un_lancer(2)
     self.assertEqual(scorer.afficher_score(), 24)
示例#2
0
 def test_apres_un_lancer_trois_quilles_un_lancer_sept_quilles_et_un_lancer_cinq_quilles(
         self):
     scorer = Scorer()
     scorer.effectuer_un_lancer(3)
     scorer.effectuer_un_lancer(7)
     scorer.effectuer_un_lancer(5)
     self.assertEqual(scorer.afficher_score(), 20)
示例#3
0
 def test_apres_deux_lancers_nuls_le_score_est_zero(self):
     scorer = Scorer()
     scorer.effectuer_un_lancer()
     scorer.effectuer_un_lancer()
     self.assertEqual(scorer.afficher_score(), 0)
示例#4
0
 def test_au_debut_le_score_est_zero(self):
     scorer = Scorer()
     self.assertEqual(scorer.afficher_score(), 0)
示例#5
0
 def test_apres_un_lancer_deux_et_un_lancer_trois_quilles_le_score_est_cinq(
         self):
     scorer = Scorer()
     scorer.effectuer_un_lancer(2)
     scorer.effectuer_un_lancer(3)
     self.assertEqual(scorer.afficher_score(), 5)
示例#6
0
 def setup_method(self):
     self.scorer = Scorer()
示例#7
0
 def test_apres_un_lancer_une_quille_et_un_lancer_nul(self):
     scorer = Scorer()
     scorer.effectuer_un_lancer(1)
     scorer.effectuer_un_lancer()
     self.assertEqual(scorer.afficher_score(), 1)
示例#8
0
 def test_normal(self):
     result = Scorer('Х4/34-4-5X17X1/5-')
     score = result.get_score()
     self.assertEqual(score, 119)
示例#9
0
class Test:
    def setup_method(self):
        self.scorer = Scorer()

    def teardown_method(self):
        del self.scorer

    def test_getScore_null(self):
        assert self.scorer.getScore() == 0

    def test_getScore_1_shoot(self):
        shoot = 5
        self.scorer.do_shoot(shoot)

        assert self.scorer.getScore() == shoot

    def test_getScore_2_shoot(self):
        shoot1 = 5
        self.scorer.do_shoot(shoot1)

        shoot2 = 3
        self.scorer.do_shoot(shoot2)

        assert self.scorer.getScore() == shoot1 + shoot2

    def test_getScore_spare(self):
        shoot1 = 4
        self.scorer.do_shoot(shoot1)
        shoot2 = 6
        self.scorer.do_shoot(shoot2)
        shoot3 = 1
        self.scorer.do_shoot(shoot3)

        assert self.scorer.getScore() == 12

    def test_getScore_false_spare(self):
        shoot1 = 2
        self.scorer.do_shoot(shoot1)
        shoot2 = 5
        self.scorer.do_shoot(shoot2)
        shoot3 = 5
        self.scorer.do_shoot(shoot3)
        shoot4 = 3
        self.scorer.do_shoot(shoot4)
        shoot5 = 7
        self.scorer.do_shoot(shoot5)

        assert self.scorer.getScore() == 22

    def test_getScore_strike(self):
        shoot1 = 10
        self.scorer.do_shoot(shoot1)
        shoot2 = 4
        self.scorer.do_shoot(shoot2)
        shoot3 = 3
        self.scorer.do_shoot(shoot3)

        assert self.scorer.getScore() == 24
示例#10
0
 def test_int(self):
     result = Scorer(11111111111111111111)
     score = result.get_score()
     self.assertEqual(score, 20)
示例#11
0
 def test_less_symbols(self):
     with self.assertRaisesRegex(BaseException, 'Количество фреймов должно быть равно десяти!'):
         Scorer('11223344443322').get_score()
示例#12
0
 def test_invalid_symbols(self):
     with self.assertRaisesRegex(BaseException, 'Результат содержит недопустимые символы'):
         Scorer('12asdxp132').get_score()
示例#13
0
 def test_spare(self):
     with self.assertRaisesRegex(BaseException, 'Неверно указан результат: '):
         Scorer('////////////////////').get_score()
示例#14
0
 def test_x(self):
     result = Scorer('xxxxxxxxxx')
     score = result.get_score()
     self.assertEqual(score, 200)