|
@@ -0,0 +1,204 @@
|
|
1
|
+package io.zipcoder.casino.CardGame.Solitaire;
|
|
2
|
+
|
|
3
|
+import io.zipcoder.casino.CardGame.Card;
|
|
4
|
+import io.zipcoder.casino.CardGame.Deck;
|
|
5
|
+import io.zipcoder.casino.CardGame.Face;
|
|
6
|
+import io.zipcoder.casino.CardGame.Suit;
|
|
7
|
+import org.junit.Assert;
|
|
8
|
+import org.junit.Test;
|
|
9
|
+
|
|
10
|
+public class FoundationTest {
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+ Foundation foundation = new Foundation();
|
|
15
|
+ Deck deck = new Deck();
|
|
16
|
+ Card card = new Card(Suit.CLUBS, Face.QUEEN);
|
|
17
|
+
|
|
18
|
+ @Test
|
|
19
|
+ public void addKingToQueenOnClubStackTest() {
|
|
20
|
+ //GIVEN
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+ Card chosen = deck.deckOfCards.pop();
|
|
24
|
+ foundation.tempStack.push(chosen);
|
|
25
|
+ foundation.clubStack.push(card);
|
|
26
|
+ foundation.whichSuit(foundation.tempStack);
|
|
27
|
+ //WHEN
|
|
28
|
+
|
|
29
|
+ Card expected = new Card(Suit.CLUBS, Face.KING);
|
|
30
|
+ Card actual = foundation.clubStack.peek();
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+ //THEN
|
|
34
|
+ Assert.assertEquals(expected, actual);
|
|
35
|
+
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+ @Test
|
|
39
|
+ public void addKingToQueenOfDiamondsStackTest() {
|
|
40
|
+ //GIVEN
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+ Card tempCard = new Card(Suit.DIAMONDS, Face.KING);
|
|
44
|
+ Card cardOnFoundation = new Card(Suit.DIAMONDS,
|
|
45
|
+ Face.QUEEN);
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+ foundation.tempStack.push(tempCard);
|
|
49
|
+ foundation.diamondStack.push(cardOnFoundation);
|
|
50
|
+ foundation.whichSuit(foundation.tempStack);
|
|
51
|
+ //WHEN
|
|
52
|
+
|
|
53
|
+ Card expected = new Card(Suit.DIAMONDS, Face.KING);
|
|
54
|
+ Card actual = foundation.diamondStack.peek();
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+ //THEN
|
|
58
|
+ Assert.assertEquals(expected, actual);
|
|
59
|
+
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+ @Test
|
|
63
|
+ public void addKingToQueenInHeartStackTest() {
|
|
64
|
+ Card tempCard = new Card(Suit.HEARTS, Face.KING);
|
|
65
|
+ Card cardOnFoundation = new Card(Suit.HEARTS,
|
|
66
|
+ Face.QUEEN);
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+ foundation.tempStack.push(tempCard);
|
|
70
|
+ foundation.heartStack.push(cardOnFoundation);
|
|
71
|
+ foundation.whichSuit(foundation.tempStack);
|
|
72
|
+ //WHEN
|
|
73
|
+
|
|
74
|
+ Card expected = new Card(Suit.HEARTS, Face.KING);
|
|
75
|
+ Card actual = foundation.heartStack.peek();
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+ //THEN
|
|
79
|
+ Assert.assertEquals(expected, actual);
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+ @Test
|
|
83
|
+ public void addKingToQueenInSpadeStackTest() {
|
|
84
|
+ Card tempCard = new Card(Suit.SPADES, Face.KING);
|
|
85
|
+ Card cardOnFoundation = new Card(Suit.SPADES,
|
|
86
|
+ Face.QUEEN);
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+ foundation.tempStack.push(tempCard);
|
|
90
|
+ foundation.spadeStack.push(cardOnFoundation);
|
|
91
|
+ foundation.whichSuit(foundation.tempStack);
|
|
92
|
+ //WHEN
|
|
93
|
+
|
|
94
|
+ Card expected = new Card(Suit.SPADES, Face.KING);
|
|
95
|
+ Card actual = foundation.spadeStack.peek();
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+ //THEN
|
|
99
|
+ Assert.assertEquals(expected, actual);
|
|
100
|
+ }
|
|
101
|
+
|
|
102
|
+ @Test
|
|
103
|
+ public void addTenToQueenInSpadeStackTest() {
|
|
104
|
+ Card tempCard = new Card(Suit.SPADES, Face.KING);
|
|
105
|
+ Card cardOnFoundation = new Card(Suit.SPADES,
|
|
106
|
+ Face.TEN);
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+ foundation.tempStack.push(tempCard);
|
|
110
|
+ foundation.spadeStack.push(cardOnFoundation);
|
|
111
|
+ foundation.whichSuit(foundation.tempStack);
|
|
112
|
+ //WHEN
|
|
113
|
+
|
|
114
|
+ Card expected = new Card(Suit.SPADES, Face.KING);
|
|
115
|
+ Card actual = foundation.spadeStack.peek();
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+ //THEN
|
|
119
|
+ Assert.assertNotEquals(expected, actual);
|
|
120
|
+ }
|
|
121
|
+
|
|
122
|
+ @Test
|
|
123
|
+ public void addAceToEmptyStackInClubStackTest() {
|
|
124
|
+ Card tempCard = new Card(Suit.CLUBS, Face.ACE);
|
|
125
|
+
|
|
126
|
+ Foundation foundation1 = new Foundation();
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+ foundation1.tempStack.push(tempCard);
|
|
130
|
+
|
|
131
|
+ foundation1.whichSuit(foundation1.tempStack);
|
|
132
|
+ //WHEN
|
|
133
|
+
|
|
134
|
+ Card expected = new Card(Suit.CLUBS, Face.ACE);
|
|
135
|
+ Card actual = foundation1.clubStack.peek();
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+ //THEN
|
|
139
|
+ Assert.assertEquals(expected, actual);
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ @Test
|
|
143
|
+ public void addAceToEmptyStackInDiamondStackTest() {
|
|
144
|
+ Card tempCard = new Card(Suit.DIAMONDS, Face.ACE);
|
|
145
|
+
|
|
146
|
+ Foundation foundation1 = new Foundation();
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+ foundation1.tempStack.push(tempCard);
|
|
150
|
+
|
|
151
|
+ foundation1.whichSuit(foundation1.tempStack);
|
|
152
|
+ //WHEN
|
|
153
|
+
|
|
154
|
+ Card expected = new Card(Suit.DIAMONDS, Face.ACE);
|
|
155
|
+ Card actual = foundation1.diamondStack.peek();
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+ //THEN
|
|
159
|
+ Assert.assertEquals(expected, actual);
|
|
160
|
+ }
|
|
161
|
+
|
|
162
|
+ @Test
|
|
163
|
+ public void addAceToEmptyStackInHeartStackTest() {
|
|
164
|
+ Card tempCard = new Card(Suit.HEARTS, Face.ACE);
|
|
165
|
+
|
|
166
|
+ Foundation foundation1 = new Foundation();
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+ foundation1.tempStack.push(tempCard);
|
|
170
|
+
|
|
171
|
+ foundation1.whichSuit(foundation1.tempStack);
|
|
172
|
+ //WHEN
|
|
173
|
+
|
|
174
|
+ Card expected = new Card(Suit.HEARTS, Face.ACE);
|
|
175
|
+ Card actual = foundation1.heartStack.peek();
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+ //THEN
|
|
179
|
+ Assert.assertEquals(expected, actual);
|
|
180
|
+ }
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+ @Test
|
|
185
|
+ public void addAceToEmptyStackInSpadeStackTest() {
|
|
186
|
+ Card tempCard = new Card(Suit.SPADES, Face.ACE);
|
|
187
|
+
|
|
188
|
+ Foundation foundation1 = new Foundation();
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+ foundation1.tempStack.push(tempCard);
|
|
192
|
+
|
|
193
|
+ foundation1.whichSuit(foundation1.tempStack);
|
|
194
|
+ //WHEN
|
|
195
|
+
|
|
196
|
+ Card expected = new Card(Suit.SPADES, Face.ACE);
|
|
197
|
+ Card actual = foundation1.spadeStack.peek();
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+ //THEN
|
|
201
|
+ Assert.assertEquals(expected, actual);
|
|
202
|
+ }
|
|
203
|
+
|
|
204
|
+}
|