summaryrefslogtreecommitdiff
path: root/test_game_object.py
blob: 3c4b30c8618f7b27aab38c9d9e8cd65e75dff994 (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
import unittest
from GameObject import GameObject

class TestGameObject(unittest.TestCase):
    
    def test_game_object_creation(self):
        obj = GameObject("sword", 1, True, True, False, "A sharp sword")
        
        self.assertEqual(obj.name, "sword")
        self.assertEqual(obj.location, 1)
        self.assertTrue(obj.movable)
        self.assertTrue(obj.visible)
        self.assertFalse(obj.carried)
        self.assertEqual(obj.description, "A sharp sword")
    
    def test_game_object_attributes_modification(self):
        obj = GameObject("shield", 2, False, False, True, "A sturdy shield")
        
        obj.carried = False
        obj.visible = True
        obj.location = 3
        
        self.assertFalse(obj.carried)
        self.assertTrue(obj.visible)
        self.assertEqual(obj.location, 3)

if __name__ == '__main__':
    unittest.main()