New version
Made in thge sessions
This commit is contained in:
@@ -1,81 +1,42 @@
|
||||
/**
|
||||
* PokerGame.java
|
||||
*
|
||||
* Course in Software Craftsmenship @ Högskolan Väst
|
||||
* Poker game kata for testing TDD, Test Driven Development
|
||||
*
|
||||
* 2015-04-27
|
||||
*/
|
||||
|
||||
package session3;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PokerGameTest {
|
||||
PokerGame myGame = new PokerGame();
|
||||
|
||||
@Test
|
||||
public void nothing_gives_0() throws Exception {
|
||||
String hand = "S2K3R5H6S7";
|
||||
public void green_wins_with_highest_card() {
|
||||
Player green = new Player("Green", "2S 3C 4D 7H AH");
|
||||
Player white = new Player("White", "3S 4C 5D 6H KH");
|
||||
PokerGame game = new PokerGame();
|
||||
|
||||
int result = myGame.getScore(hand);
|
||||
Player winningPlayer = game.calculateWinningPlayer(green, white);
|
||||
|
||||
assertEquals(0, result);
|
||||
assertEquals("Green", winningPlayer.getPlayerName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void single_pair_gives_2() throws Exception {
|
||||
String hand = "S2K2R5H6S7";
|
||||
public void one_pair_beats_highest_card() throws Exception {
|
||||
Player green = new Player("Green", "2S 3C 4D 7H AH");
|
||||
Player white = new Player("White", "3S 3C 5D 6H KH");
|
||||
PokerGame game = new PokerGame();
|
||||
|
||||
int result = myGame.getScore(hand);
|
||||
|
||||
assertEquals(2, result);
|
||||
Player winningPlayer = game.calculateWinningPlayer(green, white);
|
||||
|
||||
assertEquals("White", winningPlayer.getPlayerName());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void three_of_a_kind_gives_3() throws Exception {
|
||||
String hand = "S2K2R2H6S7";
|
||||
public void two_pair_beats_one_pair() throws Exception {
|
||||
Player green = new Player("Green", "6S 6C 4D 7H AH");
|
||||
Player white = new Player("White", "3S 3C 5D 5H KH");
|
||||
PokerGame game = new PokerGame();
|
||||
|
||||
int result = myGame.getScore(hand);
|
||||
|
||||
assertEquals(3, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void two_pairs_gives_6() throws Exception {
|
||||
String hand = "S2K2R5H7S7";
|
||||
|
||||
int result = myGame.getScore(hand);
|
||||
|
||||
assertEquals(6, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void four_of_a_kind_gives_7() throws Exception {
|
||||
String hand = "S2K2R2H2S7";
|
||||
|
||||
int result = myGame.getScore(hand);
|
||||
|
||||
assertEquals(7, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void full_house_gives_9() throws Exception {
|
||||
String hand = "S2K2R2H7S7";
|
||||
|
||||
int result = myGame.getScore(hand);
|
||||
|
||||
assertEquals(9, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flush_gives_10() throws Exception {
|
||||
String hand = "S2S6S7S8S9";
|
||||
|
||||
int result = myGame.getScore(hand);
|
||||
|
||||
assertEquals(10, result);
|
||||
Player winningPlayer = game.calculateWinningPlayer(green, white);
|
||||
|
||||
assertEquals("White", winningPlayer.getPlayerName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user