-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlayerTest.java
211 lines (190 loc) · 5.94 KB
/
PlayerTest.java
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.awt.Rectangle;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author hrithvik
*/
public class PlayerTest {
public static final String CLASSNAME = "Player";
public static final String FILENAME = CLASSNAME + ".java";
private void testInterface()
{
String[] instanceVars = {"int x_coordinate", "int y_coordinate", "int width", "int height", "boolean live"};
// assertTrue("Class should not have the default constructor.", noDefaultConstructor());
}
/**
* Test of getX_Coordinate method, of class Player.
*/
@Test
public void testGetX_Coordinate() {
System.out.println("getX_Coordinate");
Player instance = new Player(50, 30, 30, 50);
int expResult = 50;
int result = instance.getX_Coordinate();
assertEquals("Expected Result:",expResult, result);
}
/**
* Test of getY_Coordinate method, of class Player.
*/
@Test
public void testGetY_Coordinate() {
System.out.println("getY_Coordinate");
Player instance = new Player(50, 30, 30, 50);
int expResult = 30;
int result = instance.getY_Coordinate();
assertEquals("Expected Result:",expResult, result);
}
/**
* Test of getWidth method, of class Player.
*/
@Test
public void testGetWidth() {
System.out.println("getWidth");
Player instance = new Player(50, 30, 30, 50);;
int expResult = 30;
int result = instance.getWidth();
assertEquals("Expected Result",expResult, result);
}
/**
* Test of getHeight method, of class Player.
*/
@Test
public void testGetHeight() {
System.out.println("getHeight");
Player instance = new Player(50, 30, 30, 50);
int expResult = 50;
int result = instance.getHeight();
assertEquals("Expected Result",expResult, result);
}
/**
* Test of getLive method, of class Player.
*/
@Test
public void testGetLive() {
System.out.println("getLive");
Player instance = new Player(50, 30, 30, 50);;
boolean expResult = true;
boolean result = instance.getLive();
assertEquals("Expected Result:",expResult, result);
}
/**
* Test of setXCoordinate method, of class Player.
*/
@Test
public void testSetXCoordinate() {
System.out.println("setXCoordinate");
int a = 80;
Player instance = new Player(50, 30, 30, 50);;
instance.setXCoordinate(a);
assertEquals("Expected Result:",80, instance.getX_Coordinate());
}
/**
* Test of setYCoordinate method, of class Player.
*/
@Test
public void testSetYCoordinate() {
System.out.println("setYCoordinate");
int a = 60;
Player instance = new Player(30,40,40,60);
instance.setYCoordinate(a);
assertEquals("Expected Result:",60, instance.getY_Coordinate());
}
/**
* Test of setLive method, of class Player.
*/
@Test
public void testSetLive() {
System.out.println("setLive");
boolean state = false;
Player instance = new Player(50, 60, 50, 60);
instance.setLive(state);
assertEquals("Expected Result:", false, instance.getLive());
}
/**
* Test of setWidth method, of class Player.
*/
@Test
public void testSetWidth() {
System.out.println("setWidth");
int aWidth = 10;
Player instance = new Player(20,60,60,70);
instance.setWidth(aWidth);
assertEquals("Expected Result:",10, instance.getWidth());
}
/**
* Test of setHeight method, of class Player.
*/
@Test
public void testSetHeight() {
System.out.println("setHeight");
int aHeight = 20;
Player instance = new Player(10, 40, 50, 40);
instance.setHeight(aHeight);
assertEquals("Expected Result:",20, instance.getHeight());
}
/**
* Test of moveRight method, of class Player.
*/
@Test
public void testMoveRight() {
System.out.println("moveRight");
int distance = 10;
Player instance = new Player(20,20,30,40);
instance.moveRight(distance);
assertEquals("Expected Result:",30, instance.getX_Coordinate());
}
/**
* Test of moveLeft method, of class Player.
*/
@Test
public void testMoveLeft() {
System.out.println("moveLeft");
int distance = 10;
Player instance = new Player(20, 30, 40, 50);
instance.moveLeft(distance);
assertEquals("Expected Result:",10, instance.getX_Coordinate());
}
/**
* Test of moveDown method, of class Player.
*/
@Test
public void testMoveDown() {
System.out.println("moveDown");
int distance = 10;
Player instance = new Player(20, 40, 50, 60);
instance.moveDown(distance);
assertEquals("Expected Result:",50, instance.getY_Coordinate());
}
/**
* Test of moveUp method, of class Player.
*/
@Test
public void testMoveUp() {
System.out.println("moveUp");
int distance = 10;
Player instance = new Player(20, 50, 60, 70);
instance.moveUp(distance);
assertEquals("Expected Result:",40, instance.getY_Coordinate());
}
/**
* Test of getUnitHitBox method, of class Player.
*/
@Test
public void testGetUnitHitBox() {
System.out.println("getUnitHitBox");
Player instance = new Player(20, 30, 40, 50);
Rectangle expResult = new Rectangle(20, 30, 40, 50);
Rectangle result = instance.getUnitHitBox();
assertEquals("Expected Result:", expResult, result);
}
}