|
@@ -1,20 +1,23 @@
|
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;
|
6
|
7
|
|
|
8
|
+import java.util.Random;
|
|
9
|
+
|
7
|
10
|
|
8
|
11
|
public class SlotTest {
|
|
12
|
+ private int betAmount = 10;
|
|
13
|
+ private SlotMachine slotmachine = new SlotMachine(betAmount);
|
9
|
14
|
|
10
|
15
|
@Test
|
11
|
16
|
public void testSlotResult1(){
|
12
|
|
- int betAmount=10;
|
13
|
17
|
String word1="MOUSE";
|
14
|
18
|
String word2="MOUSE";
|
15
|
19
|
String word3="MOUSE";
|
16
|
20
|
//given
|
17
|
|
- SlotMachine slotmachine = new SlotMachine(betAmount);
|
18
|
21
|
slotmachine.setWord1(word1);
|
19
|
22
|
slotmachine.setWord2(word2);
|
20
|
23
|
slotmachine.setWord3(word3);
|
|
@@ -27,15 +30,12 @@ public class SlotTest {
|
27
|
30
|
|
28
|
31
|
@Test
|
29
|
32
|
public void testSlotResult2(){
|
30
|
|
- int betAmount=10;
|
31
|
33
|
String word1="MOUSE";
|
32
|
34
|
String word2="MOUSE";
|
33
|
35
|
String word3="CAT";
|
34
|
36
|
|
35
|
37
|
|
36
|
38
|
//given
|
37
|
|
- SlotMachine slotmachine = new SlotMachine(betAmount);
|
38
|
|
-
|
39
|
39
|
slotmachine.setWord1(word1);
|
40
|
40
|
slotmachine.setWord2(word2);
|
41
|
41
|
slotmachine.setWord3(word3);
|
|
@@ -65,4 +65,35 @@ public class SlotTest {
|
65
|
65
|
Assert.assertEquals(0,payout);
|
66
|
66
|
|
67
|
67
|
}
|
|
68
|
+
|
|
69
|
+ @Test
|
|
70
|
+ public void testSetBetAmount(){
|
|
71
|
+ int betAmount=10;
|
|
72
|
+ SlotMachine slotmachine = new SlotMachine(betAmount);
|
|
73
|
+
|
|
74
|
+ int newBet = 40;
|
|
75
|
+
|
|
76
|
+ slotmachine.bet(newBet);
|
|
77
|
+
|
|
78
|
+ int actual = slotmachine.betAmount;
|
|
79
|
+
|
|
80
|
+ Assert.assertEquals(newBet, actual);
|
|
81
|
+
|
|
82
|
+ }
|
|
83
|
+
|
|
84
|
+ @Test
|
|
85
|
+ public void testGenerateWords(){
|
|
86
|
+ Random random = new Random(1);
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+ String expectedWord1 = "SQUIRREL";
|
|
90
|
+ String expectedWord2 = "FISH";
|
|
91
|
+ String expectedWord3 = "CAT";
|
|
92
|
+
|
|
93
|
+ slotmachine.generateWords(random);
|
|
94
|
+
|
|
95
|
+ Assert.assertEquals(expectedWord1, slotmachine.word1);
|
|
96
|
+
|
|
97
|
+ }
|
|
98
|
+
|
68
|
99
|
}
|