summaryrefslogtreecommitdiff
path: root/tests/test_stats.py
blob: f3fc7c7bcbb9d4d14a58f065c13e27b368a5dc04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import unittest
import pygame

from pathlib import Path

from sliceitoff.stats import Stats

class TestStats(unittest.TestCase):
    def setUp(self):
        self.stats0 = Stats()
        self.stats = Stats()

    def test_can_create(self):
        self.assertNotEqual(None, self.stats)

    def test_lose_lives(self):
        self.stats.lose_life()
        self.assertEqual(self.stats.lives + 1, self.stats0.lives)

    def test_lose_lives_return_true_when_dead(self):
        for _ in range(self.stats.lives-1):
            self.assertFalse(self.stats.lose_life())
        self.assertTrue(self.stats.lose_life())

    def test_levelup_levels_up(self):
        self.stats.level_up()
        self.assertEqual(self.stats.level + 1, self.stats0.lives)

    def test_add_score_works(self):
        self.stats.score=500
        self.stats.add_score(400)
        self.assertEqual(self.stats.score, 900)
        self.stats.add_score(-600)
        self.assertEqual(self.stats.score, 300)
        self.stats.add_score(-300)
        self.assertEqual(self.stats.score, 0)
        self.stats.add_score(-300)
        self.assertEqual(self.stats.score, 0)