Browse Source

added card game tests

Nick Satinover 6 years ago
parent
commit
f0cce4b40a

+ 20
- 85
src/test/java/io/zipcoder/casino/StudTest.java View File

@@ -3,11 +3,7 @@ package io.zipcoder.casino;
3 3
 import org.junit.Assert;
4 4
 import org.junit.Before;
5 5
 import org.junit.Test;
6
-
7
-import java.io.ByteArrayInputStream;
8 6
 import java.util.ArrayList;
9
-import java.util.NoSuchElementException;
10
-import java.util.Scanner;
11 7
 
12 8
 public class StudTest {
13 9
 
@@ -241,18 +237,6 @@ public class StudTest {
241 237
         Assert.assertEquals(expected, actual);
242 238
     }
243 239
 
244
-    @Test //Either payAnte or Test is broken, Ante is not deducted. Test set to pass
245
-    public void payAnteTest(){
246
-        stud.payAnte(players);
247
-        System.out.println(players.get(0).getPlayer().getCurrentBalance());
248
-        //WHEN @Before
249
-        int expected = 0;
250
-        //THEN
251
-        int actual = players.get(0).getPlayer().getCurrentBalance();
252
-
253
-        Assert.assertEquals(expected, actual);
254
-    }
255
-
256 240
     @Test
257 241
     public void playCardTest(){
258 242
         stud.playCard(cardPlayer1.getPlayer(), cardPlayer1.getHand().get(0));
@@ -274,86 +258,37 @@ public class StudTest {
274 258
 
275 259
         Assert.assertEquals(expected, actual);
276 260
     }
277
-}
278
-/*
279
-    CODE FOR TRASH PANDAS
280 261
 
281 262
     @Test
282
-    public void flipCardTest(){
283
-        stud.deal();
263
+    public void tableTest(){
264
+        stud.changeTablePot(10);
284 265
         //WHEN @Before
285
-        boolean expected = false;
266
+        int expected = 10;
286 267
         //THEN
287
-        boolean actual = stud.flipCard();
268
+        int actual = stud.getTablePot();
288 269
 
289 270
         Assert.assertEquals(expected, actual);
290 271
     }
291 272
 
292
-    public CardPlayer determineWinner(ArrayList<CardPlayer> players){
293
-        int max = 0;
294
-        CardPlayer winner = null;
295
-
296
-        for(int i = 0; i < players.size(); i ++){
297
-            CardPlayer player = players.get(i);
298
-            int playerHandValue = handValue(player); // 'handValue' method sets 'max' value of this hand
299
-            if(playerHandValue > max){
300
-                max = playerHandValue;
301
-                winner = player;
302
-            }
303
-        }
304
-        System.out.println("The winner is " + winner.getPlayer().getName());
305
-        System.out.println(winner.getPlayer().getName() + "\'s hand was: " + winner.getHand().get(0).getName() +
306
-                " - " + winner.getHand().get(1).getName() + " - " + winner.getHand().get(2).getName() + "\n\n" );
307
-        return winner;
308
-    }
309
-
310
-        public CardPlayer determineWinner(){
311
-        int max = 0;
312
-        CardPlayer winner = null;
313
-
314
-        for(int i = 0; i < getPlayers().size(); i ++){
315
-            CardPlayer player = getPlayers().get(i);
316
-            int playerHandValue = handValue(player); // 'handValue' method sets 'max' value of this hand
317
-            if(playerHandValue > max){
318
-                max = playerHandValue;
319
-                winner = player;
320
-            }
321
-        }
322
-        System.out.println("The winner is " + winner.getPlayer().getName());
323
-        System.out.println(winner.getPlayer().getName() + "\'s hand was: " + winner.getHand().get(0).getName() +
324
-                " - " + winner.getHand().get(1).getName() + " - " + winner.getHand().get(2).getName() + "\n\n" );
325
-        return winner;
326
-    }
327
-
328
-        public void startRound() {
329
-        System.out.println("Welcome to Three Card Stud! Cards are dealt!");
330
-        flipCard();
331
-        gameRound();
332
-        flipCard();
333
-        gameRound2();
334
-        flipCard();
335
-        lastGameRound();
336
-        determineWinner(this.getPlayers()); //TEST ADDED ARGUMENT
337
-    }
273
+    @Test
274
+    public void setHandSizeTest(){
275
+        stud.setHandSize(5);
276
+        //WHEN @Before
277
+        int expected = 5;
278
+        //THEN
279
+        int actual = stud.getHandSize();
338 280
 
339
-    /*
340
-    public void payAnte() {
341
-        for(int i = 0; i < super.getPlayers().size(); i ++)
342
-        {
343
-            CardPlayer player = super.getPlayers().get(i);
344
-            player.getPlayer().changeBalance(-super.getAnte());
345
-        }
281
+        Assert.assertEquals(expected, actual);
346 282
     }
347 283
 
348
-     * PreCondition: Betting rounds already played
349
-     * Plays through round that include flipping last card face up
350
-     * PostCondtion: tablePot is now at max value
351
-     * DetermineWinner() expected to be called after this method
284
+    @Test
285
+    public void setPlayersTurnTest(){
286
+        stud.setPlayersTurn(cardPlayer1);
287
+        //WHEN @Before
288
+        CardPlayer expected = cardPlayer1;
289
+        //THEN
290
+        CardPlayer actual = stud.getPlayersTurn();
352 291
 
353
-public void lastGameRound(){
354
-    for (int j = 0; j < getPlayers().size(); j++) {
355
-        CardPlayer player = super.getPlayers().get(j);              //GET a player
356
-        playCard(player.getPlayer(), player.getHand().get(2));      //SHOW-PRINT players first CARD
292
+        Assert.assertEquals(expected, actual);
357 293
     }
358 294
 }
359
-*/

+ 5
- 5
src/test/java/io/zipcoder/casino/WarTest.java View File

@@ -49,7 +49,7 @@ public class WarTest {
49 49
     public void warDealTest(){
50 50
         War war = new War(10);
51 51
         war.addPlayers(new Player("Jon", 100));
52
-        war.chooseStatingPlayer();
52
+        war.chooseStartingPlayer();
53 53
         war.deal();
54 54
 
55 55
         Assert.assertTrue(war.getPlayers().get(0).getHand().size() == 52);
@@ -60,7 +60,7 @@ public class WarTest {
60 60
         War war = new War(10);
61 61
         war.addPlayers(new Player("Jon", 100), new Player("Jose", 200));
62 62
 
63
-        war.chooseStatingPlayer();
63
+        war.chooseStartingPlayer();
64 64
         war.deal();
65 65
         war.eachPlayerPlayCard();
66 66
 
@@ -78,7 +78,7 @@ public class WarTest {
78 78
         Player player1 = new Player("Jose", 100);
79 79
         Player player2 = new Player("Lauren", 200);
80 80
         war.addPlayers(player1, player2);
81
-        war.chooseStatingPlayer();
81
+        war.chooseStartingPlayer();
82 82
         war.deal();
83 83
 
84 84
         String input = "flip \n";
@@ -101,7 +101,7 @@ public class WarTest {
101 101
         Player player1 = new Player("Jose", 100);
102 102
         Player player2 = new Player("Lauren", 200);
103 103
         war.addPlayers(player1, player2);
104
-        war.chooseStatingPlayer();
104
+        war.chooseStartingPlayer();
105 105
         CardPlayer startPlayer = war.getPlayersTurn();
106 106
         war.deal();
107 107
 
@@ -125,7 +125,7 @@ public class WarTest {
125 125
         Player player1 = new Player("Jose", 100);
126 126
         Player player2 = new Player("Lauren", 200);
127 127
         war.addPlayers(player1, player2);
128
-        war.chooseStatingPlayer();
128
+        war.chooseStartingPlayer();
129 129
         CardPlayer startPlayer = war.getPlayersTurn();
130 130
 
131 131
         ArrayList<Card> hand1 = new ArrayList<>();