|
@@ -0,0 +1,110 @@
|
|
1
|
+import org.junit.Assert;
|
|
2
|
+import org.junit.Test;
|
|
3
|
+
|
|
4
|
+import java.util.Arrays;
|
|
5
|
+
|
|
6
|
+public class DiceTest {
|
|
7
|
+
|
|
8
|
+ @Test
|
|
9
|
+ public void tossAndSumTest0()
|
|
10
|
+ {
|
|
11
|
+ //Given
|
|
12
|
+ Dice dice = new Dice(2);
|
|
13
|
+ long actualNumber = dice.tossAndSum();
|
|
14
|
+ //When
|
|
15
|
+ boolean test2To12 = 1 < actualNumber && actualNumber < 13;
|
|
16
|
+ //Then
|
|
17
|
+ Assert.assertTrue(test2To12);
|
|
18
|
+ System.out.println(actualNumber);
|
|
19
|
+
|
|
20
|
+ }
|
|
21
|
+
|
|
22
|
+ @Test
|
|
23
|
+ public void tossAndSumTest1()
|
|
24
|
+ {
|
|
25
|
+ //Given
|
|
26
|
+ Dice dice = new Dice(10);
|
|
27
|
+ long actualNumber = dice.tossAndSum();
|
|
28
|
+ //When
|
|
29
|
+ boolean test10To60 = 9 < actualNumber && actualNumber < 61;
|
|
30
|
+ //Then
|
|
31
|
+ Assert.assertTrue(test10To60);
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ @Test
|
|
35
|
+ public void binArrayTest1()
|
|
36
|
+ {
|
|
37
|
+ //Given
|
|
38
|
+ Bins bins = new Bins(3,18);
|
|
39
|
+ //When
|
|
40
|
+ int expectedValue = (3);
|
|
41
|
+ //Then
|
|
42
|
+ Assert.assertEquals(expectedValue, bins.binArray[0][0]);
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ @Test
|
|
46
|
+ public void binArrayTest2()
|
|
47
|
+ {
|
|
48
|
+ //Given
|
|
49
|
+ int maxRoll = 12;
|
|
50
|
+ int minRoll = 2;
|
|
51
|
+ Bins bins = new Bins(minRoll,maxRoll);
|
|
52
|
+ //When
|
|
53
|
+ int expectedValue = maxRoll;
|
|
54
|
+ int result = maxRoll-minRoll;
|
|
55
|
+ //Then
|
|
56
|
+ Assert.assertEquals(expectedValue, bins.binArray[result][0]);
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ @Test
|
|
60
|
+ public void binArrayTest3()
|
|
61
|
+ {
|
|
62
|
+ //Given
|
|
63
|
+ int maxRoll = 6;
|
|
64
|
+ int minRoll = 1;
|
|
65
|
+ Bins bins = new Bins(minRoll,maxRoll);
|
|
66
|
+ //When
|
|
67
|
+ int expectedValue = maxRoll;
|
|
68
|
+ int result = bins.binArray.length-1;
|
|
69
|
+ //Then
|
|
70
|
+ Assert.assertEquals(expectedValue, bins.binArray[result][0]);
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ @Test
|
|
74
|
+ public void getBinTest1()
|
|
75
|
+ {
|
|
76
|
+ //Given
|
|
77
|
+ Bins bins = new Bins(3,18);
|
|
78
|
+ int expectedValue = (0);
|
|
79
|
+ //When
|
|
80
|
+ int actualValue = bins.getBin(3);
|
|
81
|
+ //Then
|
|
82
|
+ Assert.assertEquals(expectedValue, actualValue);
|
|
83
|
+ }
|
|
84
|
+
|
|
85
|
+ @Test
|
|
86
|
+ public void getBinTest2()
|
|
87
|
+ {
|
|
88
|
+ //Given
|
|
89
|
+ Bins bins = new Bins(2,12);
|
|
90
|
+ int expectedValue = (0);
|
|
91
|
+ //When
|
|
92
|
+ int actualValue = bins.getBin(12);
|
|
93
|
+ //Then
|
|
94
|
+ Assert.assertEquals(expectedValue, actualValue);
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ @Test
|
|
98
|
+ public void incrementBinTest1()
|
|
99
|
+ {
|
|
100
|
+ //Given
|
|
101
|
+ Bins bins = new Bins(3,18);
|
|
102
|
+ int expectedValue = (1);
|
|
103
|
+ //When
|
|
104
|
+ bins.incrementBin(3);
|
|
105
|
+ int actualValue = bins.getBin(3);
|
|
106
|
+ //Then
|
|
107
|
+ Assert.assertEquals(expectedValue, actualValue);
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+}
|