|
@@ -1,8 +1,85 @@
|
1
|
1
|
package io.zipcoder.casino;
|
2
|
2
|
|
|
3
|
+import io.zipcoder.casino.cardgames.BlackJack;
|
|
4
|
+import io.zipcoder.casino.player.BlackJackPlayer;
|
|
5
|
+import io.zipcoder.casino.utilities.Card;
|
|
6
|
+import io.zipcoder.casino.utilities.containers.CardHand;
|
|
7
|
+import io.zipcoder.casino.utilities.containers.Deck;
|
|
8
|
+import io.zipcoder.casino.utilities.enums.CardValue;
|
|
9
|
+import org.junit.Assert;
|
3
|
10
|
import org.junit.Test;
|
4
|
11
|
|
|
12
|
+import java.util.ArrayList;
|
|
13
|
+
|
|
14
|
+import static io.zipcoder.casino.utilities.enums.CardSuit.HEARTS;
|
|
15
|
+
|
5
|
16
|
public class BlackJackTest {
|
|
17
|
+ Deck deck = new Deck();
|
|
18
|
+ BlackJack blackJack = new BlackJack();
|
|
19
|
+ ArrayList<BlackJackPlayer> blackJackPlayers = new ArrayList<>();
|
|
20
|
+ CardHand dealerHand = new CardHand();
|
|
21
|
+ CardHand playerHand = new CardHand();
|
|
22
|
+ BlackJackPlayer player = new BlackJackPlayer();
|
|
23
|
+ Card card10 = new Card(CardValue.TEN,HEARTS);
|
|
24
|
+ Card card7 = new Card(CardValue.SEVEN,HEARTS);
|
|
25
|
+ Card cardAce = new Card(CardValue.ACE,HEARTS);
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+ @Test
|
|
29
|
+ public void testPayoutAll(){
|
|
30
|
+ player.setBet(100);
|
|
31
|
+ blackJack.payoutAll();
|
|
32
|
+ long expected = 100;
|
|
33
|
+ long actual = player.getBet();
|
|
34
|
+ Assert.assertEquals(expected, actual);
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ @Test
|
|
38
|
+ public void testDealerDraw(){
|
|
39
|
+ blackJack.dealerDraw();
|
|
40
|
+ int expected = 2;
|
|
41
|
+ int actual = dealerHand.size();
|
|
42
|
+ Assert.assertEquals(expected,actual);
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ @Test
|
|
46
|
+ public void testDealCards(){
|
|
47
|
+ blackJack.dealCards(2);
|
|
48
|
+ int expected = 50;
|
|
49
|
+ int actual = blackJack.getDeck().size();
|
|
50
|
+ Assert.assertEquals(expected, actual);
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+ @Test
|
|
55
|
+ public void testDrawCard(){
|
|
56
|
+ blackJack.drawCard();
|
|
57
|
+
|
|
58
|
+ int expected = 51;
|
|
59
|
+ int actual = blackJack.getDeck().size();
|
|
60
|
+ Assert.assertEquals(expected, actual);
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ @Test
|
|
64
|
+ public void testRevealCard(){
|
|
65
|
+ dealerHand.add(card10);
|
|
66
|
+ blackJack.revealCard();
|
|
67
|
+ int expected = 1;
|
|
68
|
+ int actual = dealerHand.size();
|
|
69
|
+
|
|
70
|
+ Assert.assertEquals(expected, actual);
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ @Test
|
|
74
|
+ public void testGetSum(){
|
|
75
|
+
|
|
76
|
+ playerHand.add(card7);
|
|
77
|
+ playerHand.add(card10);
|
|
78
|
+
|
|
79
|
+ int expected = 17;
|
|
80
|
+ int actual = blackJack.getSum(playerHand);
|
6
|
81
|
|
|
82
|
+ Assert.assertEquals(expected, actual);
|
7
|
83
|
|
|
84
|
+ }
|
8
|
85
|
}
|