-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayerTest.java
119 lines (95 loc) · 2.6 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
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import static org.mockito.Mockito.when;
// You could also do this to make this a little cleaner.
//import static org.mockito.Mockito.*;
public class PlayerTest {
@SuppressWarnings("unchecked")
//@Mock
Player py=Mockito.mock(Player.class);
@Before
public void setup(){
MockitoAnnotations.initMocks(py);
}
@After
public void tearDown() throws Exception {
// any necessary teardown - none needed here
}
//Test if method hasAllItems() returns false if Player has no items
@Test
public void testHasAllItems() {
assertFalse(py.hasAllItems());
}
//Test if method hasAllItems() returns true if Player has all items
@Test
public void testHasAllItems1() {
py=new Player(true,true,true);
assertTrue(py.hasAllItems());
}
//Test if method hasAllItems returns false if Player only has two items
@Test
public void testHasAllItems2() {
py=new Player(true,false,true);
assertFalse(py.hasAllItems());
}
//Test if method hasAllItems returns false if Player only has one item
@Test
public void testHasAllItems3() {
py=new Player(true,false,false);
assertFalse(py.hasAllItems());
}
//Test if method drink returns false if Player has no items
@Test
public void testDrink(){
assertFalse(py.drink());
}
/*Order for Player's items:
Player(boolean sugar, boolean cream, boolean coffee)
*/
//Test if method drink returns false if Player has two items
@Test
public void testDrink1(){
py=new Player(true,true,false);
assertFalse(py.drink());
}
//Test if method drink returns false if Player has one item
@Test
public void testDrink2(){
py=new Player(true,false,false);
assertFalse(py.drink());
}
//Test if method drink returns true if Player has all three items
@Test
public void testDrink3(){
py=new Player(true,true,true);
assertTrue(py.drink());
}
//Test if method drink returns false if Player has two items
@Test
public void testDrink4(){
py=new Player(true,false,true);
assertFalse(py.drink());
}
//Test if method drink returns false if Player has two items
@Test
public void testDrink5(){
py=new Player(false,true,true);
assertFalse(py.drink());
}
//Test if method drink returns false if Player has one item
@Test
public void testDrink6(){
py=new Player(false,false,true);
assertFalse(py.drink());
}
//Test if method drink returns false if Player has one item
@Test
public void testDrink7(){
py=new Player(false,true,false);
assertFalse(py.drink());
}
}