summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stats.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_stats.py b/tests/test_stats.py
new file mode 100644
index 0000000..f3fc7c7
--- /dev/null
+++ b/tests/test_stats.py
@@ -0,0 +1,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)