1 /*
2  *  CVS: $Id: GameObjectTest.java,v 1.2 2004/07/16 16:22:33 marcus Exp $
3  * 
4  *  This file is part of Zuul.
5  *
6  *  Zuul is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10 *
11 *  Zuul is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *  GNU General Public License for more details.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with Zuul; if not, write to the Free Software
18 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 * 
20 *  Copyrigth 2004 by marcus, leh
21 * 
22 */
23
24package org.jzuul.engine.test;
25
26import java.util.HashMap;
27import java.util.Map;
28
29import org.jdom.Element;
30import org.jzuul.engine.Character;
31import org.jzuul.engine.GameObject;
32import org.jzuul.engine.Item;
33
34import junit.framework.TestCase;
35
36/**
37 * 
38 */
39public class GameObjectTest extends TestCase {
40    GameObject go;
41
42    public void testSetDescription() {
43        go.setDescription("foo");
44        assertEquals(go.getDescription(), "foo");
45
46        go.setDescription("bar");
47        assertEquals(go.getDescription(), "bar");
48
49        try {
50            go.setDescription(null);
51            fail("Exception expected");
52        } catch (IllegalArgumentException e) {
53        }
54
55    }
56
57    public void testSetName() {
58        go.setName("foo");
59        assertEquals(go.getName(), "foo");
60
61        go.setName("bar");
62        assertEquals(go.getName(), "bar");
63        
64        go.setName("BAZ");
65        assertEquals(go.getName(), "baz");
66        
67        try {
68            go.setName(null);
69            fail("exception expected");
70        } catch (IllegalArgumentException e) {
71        }
72
73    }
74
75    public void testSetUsability() {
76        go.setUsability(true);
77        assertTrue(go.isUsable());
78
79        go.setUsability(false);
80        assertFalse(go.isUsable());
81    }
82
83    public void testIsCharacter() {
84        assertEquals(go.isCharacter(), go instanceof Character);
85    }
86
87    public void testIsItem() {
88        assertEquals(go.isItem(), go instanceof Item);
89    }
90
91    public void testToElement() {
92        assertNotNull(go.toElement());
93        assertTrue(go.toElement() instanceof Element);
94    }
95
96    public void testSetTakeable() {
97        go.setTakeable(true);
98        assertTrue(go.isTakeable());
99
00        go.setTakeable(false);
01        assertFalse(go.isTakeable());
02    }
03
04    public void testSetSize() {
05        go.setSize(50);
06        assertEquals(go.getSize(), 50);
07
08        go.setSize(20);
09        assertEquals(go.getSize(), 20);
10
11        try {
12            go.setSize(-10);
13            fail("Illegal argument expected");
14        } catch (IllegalArgumentException e) {
15        }
16
17    }
18
19    public void testSetProperties() {
20        Map testMap = new HashMap();
21        testMap.put("description", "test");
22
23        go.setProperties(testMap);
24
25        assertEquals(go.getDescription(), "test");
26    }
27
28    public void testGetTargetList() {
29        assertNotNull(go.getTargetList());
30    }
31
32}
33