|
@@ -1,21 +1,21 @@
|
1
|
1
|
package io.zipcoder.casino;
|
2
|
2
|
|
3
|
3
|
|
|
4
|
+import org.junit.Before;
|
4
|
5
|
import org.junit.Test;
|
5
|
6
|
import org.junit.Assert;
|
|
7
|
+import java.util.Random;
|
6
|
8
|
|
7
|
|
-import java.io.ByteArrayInputStream;
|
8
|
|
-import java.util.NoSuchElementException;
|
9
|
|
-import java.util.Scanner;
|
10
|
9
|
|
11
|
10
|
|
12
|
11
|
public class SlotTest {
|
|
12
|
+ private int betAmount = 10;
|
|
13
|
+ private SlotMachine slotmachine = new SlotMachine(betAmount);
|
13
|
14
|
|
14
|
15
|
Player player = new Player("Bob", 400);
|
15
|
16
|
|
16
|
17
|
@Test
|
17
|
18
|
public void testSlotResult1(){
|
18
|
|
- int betAmount=10;
|
19
|
19
|
String word1="MOUSE";
|
20
|
20
|
String word2="MOUSE";
|
21
|
21
|
String word3="MOUSE";
|
|
@@ -33,7 +33,6 @@ public class SlotTest {
|
33
|
33
|
|
34
|
34
|
@Test
|
35
|
35
|
public void testSlotResult2(){
|
36
|
|
- int betAmount=10;
|
37
|
36
|
String word1="MOUSE";
|
38
|
37
|
String word2="MOUSE";
|
39
|
38
|
String word3="CAT";
|
|
@@ -41,7 +40,6 @@ public class SlotTest {
|
41
|
40
|
|
42
|
41
|
//given
|
43
|
42
|
SlotMachine slotmachine = new SlotMachine(betAmount, player);
|
44
|
|
-
|
45
|
43
|
slotmachine.setWord1(word1);
|
46
|
44
|
slotmachine.setWord2(word2);
|
47
|
45
|
slotmachine.setWord3(word3);
|
|
@@ -120,4 +118,35 @@ public class SlotTest {
|
120
|
118
|
|
121
|
119
|
|
122
|
120
|
}
|
|
121
|
+
|
|
122
|
+ @Test
|
|
123
|
+ public void testSetBetAmount(){
|
|
124
|
+ int betAmount=10;
|
|
125
|
+ SlotMachine slotmachine = new SlotMachine(betAmount);
|
|
126
|
+
|
|
127
|
+ int newBet = 40;
|
|
128
|
+
|
|
129
|
+ slotmachine.bet(newBet);
|
|
130
|
+
|
|
131
|
+ int actual = slotmachine.betAmount;
|
|
132
|
+
|
|
133
|
+ Assert.assertEquals(newBet, actual);
|
|
134
|
+
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ @Test
|
|
138
|
+ public void testGenerateWords2(){
|
|
139
|
+ Random random = new Random(1);
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+ String expectedWord1 = "SQUIRREL";
|
|
143
|
+ String expectedWord2 = "FISH";
|
|
144
|
+ String expectedWord3 = "CAT";
|
|
145
|
+
|
|
146
|
+ slotmachine.generateWords(random);
|
|
147
|
+
|
|
148
|
+ Assert.assertEquals(expectedWord1, slotmachine.word1);
|
|
149
|
+
|
|
150
|
+ }
|
|
151
|
+
|
123
|
152
|
}
|