|
@@ -7,6 +7,8 @@ import org.junit.Assert;
|
7
|
7
|
|
8
|
8
|
public class SlotTest {
|
9
|
9
|
|
|
10
|
+ Player player = new Player("Bob", 400);
|
|
11
|
+
|
10
|
12
|
@Test
|
11
|
13
|
public void testSlotResult1(){
|
12
|
14
|
int betAmount=10;
|
|
@@ -14,7 +16,7 @@ public class SlotTest {
|
14
|
16
|
String word2="MOUSE";
|
15
|
17
|
String word3="MOUSE";
|
16
|
18
|
//given
|
17
|
|
- SlotMachine slotmachine = new SlotMachine(betAmount);
|
|
19
|
+ SlotMachine slotmachine = new SlotMachine(betAmount, player);
|
18
|
20
|
slotmachine.setWord1(word1);
|
19
|
21
|
slotmachine.setWord2(word2);
|
20
|
22
|
slotmachine.setWord3(word3);
|
|
@@ -34,7 +36,7 @@ public class SlotTest {
|
34
|
36
|
|
35
|
37
|
|
36
|
38
|
//given
|
37
|
|
- SlotMachine slotmachine = new SlotMachine(betAmount);
|
|
39
|
+ SlotMachine slotmachine = new SlotMachine(betAmount, player);
|
38
|
40
|
|
39
|
41
|
slotmachine.setWord1(word1);
|
40
|
42
|
slotmachine.setWord2(word2);
|
|
@@ -54,7 +56,7 @@ public class SlotTest {
|
54
|
56
|
String word3="CAT";
|
55
|
57
|
|
56
|
58
|
//given
|
57
|
|
- SlotMachine slotmachine = new SlotMachine(betAmount);
|
|
59
|
+ SlotMachine slotmachine = new SlotMachine(betAmount, player);
|
58
|
60
|
|
59
|
61
|
slotmachine.setWord1(word1);
|
60
|
62
|
slotmachine.setWord2(word2);
|
|
@@ -64,4 +66,36 @@ public class SlotTest {
|
64
|
66
|
int payout=slotmachine.getPayoutAmt();
|
65
|
67
|
Assert.assertEquals(0,payout);
|
66
|
68
|
}
|
|
69
|
+
|
|
70
|
+ @Test
|
|
71
|
+ public void testGenerateWords() {
|
|
72
|
+ //Given
|
|
73
|
+ SlotMachine game = new SlotMachine(100, player);
|
|
74
|
+ String before = game.getOutputword();
|
|
75
|
+
|
|
76
|
+ //When
|
|
77
|
+ game.generateWords();
|
|
78
|
+ String after = game.getOutputword();
|
|
79
|
+
|
|
80
|
+ //Then
|
|
81
|
+ Assert.assertNotEquals(before, after);
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ @Test
|
|
87
|
+ public void testBet() {
|
|
88
|
+ //Given
|
|
89
|
+ SlotMachine game = new SlotMachine(100, player);
|
|
90
|
+ int expected = 300;
|
|
91
|
+
|
|
92
|
+ //When
|
|
93
|
+ game.bet(100);
|
|
94
|
+ int actual = game.getPlayer().getCurrentBalance();
|
|
95
|
+
|
|
96
|
+ //Then
|
|
97
|
+ Assert.assertEquals(expected, actual);
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+ }
|
67
|
101
|
}
|