-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStateTest.java
More file actions
46 lines (35 loc) · 1.12 KB
/
StateTest.java
File metadata and controls
46 lines (35 loc) · 1.12 KB
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
package behavioral.state;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
public class StateTest {
@Test
public void startGame_Should_start_state_FlyingState() {
FlappyBird bird = new FlappyBird();
bird.startGame();
assertThat(bird.getState(),instanceOf(FlyingState.class));
}
@Test
public void collision_Should_change_FlyingState_to_IdleState() {
FlappyBird bird = new FlappyBird();
bird.startGame();
bird.collision();
assertThat(bird.getState(),instanceOf(IdleState.class));
}
@Test
public void animate_In_FlyingState_Should_Set_isAlive_True() {
FlappyBird bird = new FlappyBird();
bird.startGame();
bird.animate();
assertEquals(true, bird.isAlive);
}
@Test
public void animate_In_IdleState_Should_Set_isAlive_False() {
FlappyBird bird = new FlappyBird();
bird.startGame();
bird.collision();
bird.animate();
assertEquals(false, bird.isAlive);
}
}