Test to create/resume a game
This commit is contained in:
parent
a51ca5dbe3
commit
3520a76613
|
@ -26,6 +26,7 @@ class TestGame(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
old_state = self.game.save_state()
|
old_state = self.game.save_state()
|
||||||
|
|
||||||
|
self.game.handle_key_pressed(KeyValues.DOWN)
|
||||||
self.game.handle_key_pressed(KeyValues.DOWN)
|
self.game.handle_key_pressed(KeyValues.DOWN)
|
||||||
self.assertEqual(self.game.main_menu.validate(), MainMenuValues.SAVE)
|
self.assertEqual(self.game.main_menu.validate(), MainMenuValues.SAVE)
|
||||||
self.game.handle_key_pressed(KeyValues.ENTER) # Save game
|
self.game.handle_key_pressed(KeyValues.ENTER) # Save game
|
||||||
|
@ -94,6 +95,9 @@ class TestGame(unittest.TestCase):
|
||||||
self.assertEqual(self.game.main_menu.validate(),
|
self.assertEqual(self.game.main_menu.validate(),
|
||||||
MainMenuValues.START)
|
MainMenuValues.START)
|
||||||
self.game.handle_key_pressed(KeyValues.DOWN)
|
self.game.handle_key_pressed(KeyValues.DOWN)
|
||||||
|
self.assertEqual(self.game.main_menu.validate(),
|
||||||
|
MainMenuValues.RESUME)
|
||||||
|
self.game.handle_key_pressed(KeyValues.DOWN)
|
||||||
self.assertEqual(self.game.main_menu.validate(),
|
self.assertEqual(self.game.main_menu.validate(),
|
||||||
MainMenuValues.SAVE)
|
MainMenuValues.SAVE)
|
||||||
self.game.handle_key_pressed(KeyValues.DOWN)
|
self.game.handle_key_pressed(KeyValues.DOWN)
|
||||||
|
@ -124,6 +128,9 @@ class TestGame(unittest.TestCase):
|
||||||
self.assertEqual(self.game.main_menu.validate(),
|
self.assertEqual(self.game.main_menu.validate(),
|
||||||
MainMenuValues.SAVE)
|
MainMenuValues.SAVE)
|
||||||
self.game.handle_key_pressed(KeyValues.UP)
|
self.game.handle_key_pressed(KeyValues.UP)
|
||||||
|
self.assertEqual(self.game.main_menu.validate(),
|
||||||
|
MainMenuValues.RESUME)
|
||||||
|
self.game.handle_key_pressed(KeyValues.UP)
|
||||||
self.assertEqual(self.game.main_menu.validate(),
|
self.assertEqual(self.game.main_menu.validate(),
|
||||||
MainMenuValues.START)
|
MainMenuValues.START)
|
||||||
|
|
||||||
|
@ -162,6 +169,29 @@ class TestGame(unittest.TestCase):
|
||||||
self.game.handle_key_pressed(KeyValues.SPACE)
|
self.game.handle_key_pressed(KeyValues.SPACE)
|
||||||
self.assertEqual(self.game.state, GameMode.MAINMENU)
|
self.assertEqual(self.game.state, GameMode.MAINMENU)
|
||||||
|
|
||||||
|
def test_new_game(self) -> None:
|
||||||
|
"""
|
||||||
|
Ensure that the start button starts a new game.
|
||||||
|
"""
|
||||||
|
old_map = self.game.map
|
||||||
|
old_player = self.game.player
|
||||||
|
self.game.handle_key_pressed(KeyValues.ENTER) # Start new game
|
||||||
|
new_map = self.game.map
|
||||||
|
new_player = self.game.player
|
||||||
|
# Ensure that
|
||||||
|
self.assertNotEqual(old_map, new_map)
|
||||||
|
self.assertNotEqual(old_player, new_player)
|
||||||
|
|
||||||
|
self.game.handle_key_pressed(KeyValues.SPACE)
|
||||||
|
old_map = new_map
|
||||||
|
old_player = new_player
|
||||||
|
self.game.handle_key_pressed(KeyValues.DOWN)
|
||||||
|
self.game.handle_key_pressed(KeyValues.ENTER) # Resume game
|
||||||
|
new_map = self.game.map
|
||||||
|
new_player = self.game.player
|
||||||
|
self.assertEqual(old_map, new_map)
|
||||||
|
self.assertEqual(old_player, new_player)
|
||||||
|
|
||||||
def test_settings_menu(self) -> None:
|
def test_settings_menu(self) -> None:
|
||||||
"""
|
"""
|
||||||
Ensure that the settings menu is working properly.
|
Ensure that the settings menu is working properly.
|
||||||
|
@ -172,6 +202,7 @@ class TestGame(unittest.TestCase):
|
||||||
self.game.handle_key_pressed(KeyValues.DOWN)
|
self.game.handle_key_pressed(KeyValues.DOWN)
|
||||||
self.game.handle_key_pressed(KeyValues.DOWN)
|
self.game.handle_key_pressed(KeyValues.DOWN)
|
||||||
self.game.handle_key_pressed(KeyValues.DOWN)
|
self.game.handle_key_pressed(KeyValues.DOWN)
|
||||||
|
self.game.handle_key_pressed(KeyValues.DOWN)
|
||||||
self.game.handle_key_pressed(KeyValues.ENTER)
|
self.game.handle_key_pressed(KeyValues.ENTER)
|
||||||
self.assertEqual(self.game.state, GameMode.SETTINGS)
|
self.assertEqual(self.game.state, GameMode.SETTINGS)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue