Exemple #1
0
  @Test
  public void ThreeOfAKind_3() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.DIAMONDS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.SPADES, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.HEARTS, eRank.TWO, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.THREE, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.ThreeOfAKind.getHandStrength());
    assertTrue(h.getHighPairStrength() == eRank.TEN.getRank());
    assertTrue(h.getLowPairStrength() == 0);
    assertTrue(h.getKicker().size() == 2);

    Card c1 = h.getKicker().get(eCardNo.FirstCard.getCardNo());
    Card c2 = h.getKicker().get(eCardNo.SecondCard.getCardNo());

    //	Check to see if the first kicker is a THREE
    assertTrue(c1.getRank().getRank() == eRank.THREE.getRank());

    //	Check to see if the second kicker is a TWO
    assertTrue(c2.getRank().getRank() == eRank.TWO.getRank());
  }
Exemple #2
0
 @Test
 public void testGetCash()
     throws NotEnoughMoneyInAccountException, NotEnoughMoneyInATMException,
         NoCardInsertedException {
   System.out.println("getCashNotZeroBalance");
   double atmMoney = 1000.0;
   ATM atmTest = new ATM(atmMoney);
   Card mockCard = mock(Card.class);
   Account mockAccount = mock(Account.class);
   atmTest.insertCard(mockCard); // ver.2
   double balance = 600.0;
   double amount = 100.0;
   int pinCode = 7777;
   when(mockCard.getAccount()).thenReturn(mockAccount);
   when(mockCard.checkPin(pinCode)).thenReturn(true);
   when(mockCard.isBlocked()).thenReturn(false);
   when(mockAccount.getBalance()).thenReturn(balance);
   when(mockAccount.withdrow(amount)).thenReturn(amount);
   atmTest.validateCard(mockCard, pinCode);
   atmTest.getCash(amount);
   when(mockAccount.getBalance()).thenReturn(balance - amount);
   assertEquals(atmTest.getMoneyInATM(), atmMoney - amount, 0.0);
   assertEquals(atmTest.checkBalance(), balance - amount, 0.0);
   InOrder inOrder = inOrder(mockCard, mockAccount);
   inOrder.verify(mockCard).isBlocked();
   inOrder.verify(mockCard).checkPin(pinCode);
   inOrder.verify(mockCard, atLeastOnce()).getAccount();
   verify(mockAccount).withdrow(amount);
   inOrder.verify(mockAccount).getBalance();
 }
  @Test
  public void testNumCards() {

    List<Card> deck = makeDeck();
    Card tmpCard;

    Hand aHand =
        new Hand(
            1
                + " "
                + deck.remove(0)
                + " "
                + deck.remove(0)
                + " "
                + deck.remove(0)
                + " "
                + deck.remove(0)
                + " "
                + deck.remove(0));

    assertTrue(aHand.isComplete());

    try {
      tmpCard = deck.remove(0);
      aHand.addCard(tmpCard.getRank(), tmpCard.getSuit());
    } catch (Exception e) {
      fail("hand exception");
    }
  }
Exemple #4
0
 @Test
 public void testContructorGetSuit() {
   System.out.println("card() and getSuit()");
   Card.Suit expSuit = Card.Suit.CLUB;
   Card instance = new Card(expSuit, Card.Rank.TWO);
   Card.Suit suitResult = instance.getSuit();
   assertEquals(expSuit, suitResult);
 }
Exemple #5
0
 @Test
 public void testContructorGetRank() {
   System.out.println("card() and getRank");
   Card.Rank expRank = Card.Rank.TWO;
   Card instance = new Card(Card.Suit.CLUB, expRank);
   Card.Rank rankResult = instance.getRank();
   assertEquals(expRank, rankResult);
 }
 @Test
 public void testSetPlayer() {
   Card dodo = CardList.getCard("Dodo");
   DeployedCard actual = new DeployedCard(dodo, 0, 1).setPlayer(Player.BLUE);
   Card expected = dodo.setHoldingPlayer(Player.BLUE);
   assertEquals(expected, actual.card);
   assertEquals(0, actual.row);
   assertEquals(1, actual.col);
 }
Exemple #7
0
 @Test
 public final void testEqualsObject() {
   Assert.assertTrue(AC.equals(AC));
   Assert.assertTrue(AC.equals(AC2));
   Assert.assertTrue(AC.equals(new Card(CardValue.ACE, CardSuit.CLUBS)));
   Assert.assertFalse(AC.equals(KH));
   Assert.assertFalse(AC.equals(KS));
   Assert.assertFalse(KS.equals(KH));
 }
 @Test
 public void testCards() throws HTTPError {
   Customer customer = createPersonCustomer();
   Card card = createCard();
   assertNotNull(card);
   assertNotNull(card.href);
   card.associateToCustomer(customer);
   assertEquals(card.href, customer.cards.iterator().next().href);
 }
Exemple #9
0
 @Test
 public void testHashCode() {
   System.out.println("hashCode");
   List<Card> allCards = getAllCards();
   Set<Integer> hashCodes = new HashSet<>(allCards.size());
   for (Card card : allCards) {
     assertThat(hashCodes, not(hasItem(card.hashCode())));
   }
 }
Exemple #10
0
 @Test
 public void testValidateCardWithInvalidPin() throws NoCardInsertedException {
   System.out.println("validateCardWithInvalidPin");
   ATM atmTest = new ATM(1000.0);
   Card mockCard = mock(Card.class);
   int pinCode = 7777;
   when(mockCard.isBlocked()).thenReturn(false);
   when(mockCard.checkPin(pinCode)).thenReturn(false);
   assertFalse(atmTest.validateCard(mockCard, pinCode));
 }
Exemple #11
0
 @Test
 public void testCheckBalanceVerify() throws NoCardInsertedException {
   System.out.println("checkBalanceVerify");
   ATM atmTest = new ATM(1000);
   Card mockCard = mock(Card.class);
   Account mockAccount = mock(Account.class);
   when(mockCard.getAccount()).thenReturn(mockAccount);
   atmTest.insertCard(mockCard);
   atmTest.checkBalance();
   verify(mockCard, times(1)).isBlocked();
 }
  @Test
  public void testInstantion() {
    Card card1 = new Card(Suit.HEART, "5");
    Card card2 = new Card(Suit.SPADE, "K");

    assertNotNull(card1);
    assertNotNull(card2);

    assertEquals(10, card2.getValue());
    assertEquals("HEART", card1.getSuit().toString());
    assertEquals("5", card1.getDescription());
  }
Exemple #13
0
 @Test(expected = IllegalArgumentException.class)
 public void testGetCashLessThanZero()
     throws NotEnoughMoneyInATMException, NotEnoughMoneyInAccountException,
         NoCardInsertedException {
   System.out.println("getCashLessThanZero");
   double amount = -100.0;
   ATM atmTest = new ATM(1000.0);
   Card mockCard = mock(Card.class);
   atmTest.insertCard(mockCard);
   Account mockAccount = mock(Account.class);
   when(mockCard.getAccount()).thenReturn(mockAccount);
   atmTest.getCash(amount);
 }
Exemple #14
0
  @Test
  public void HighCard() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.DIAMONDS, eRank.KING, 0));
    h.AddCardToHand(new Card(eSuit.SPADES, eRank.THREE, 0));
    h.AddCardToHand(new Card(eSuit.HEARTS, eRank.TWO, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.ACE, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.HighCard.getHandStrength());
    assertTrue(h.getHighPairStrength() == eRank.ACE.getRank());
    assertTrue(h.getLowPairStrength() == 0);
    assertTrue(h.getKicker().size() == 4);

    Card c1 = h.getKicker().get(eCardNo.FirstCard.getCardNo());
    Card c2 = h.getKicker().get(eCardNo.SecondCard.getCardNo());
    Card c3 = h.getKicker().get(eCardNo.ThirdCard.getCardNo());
    Card c4 = h.getKicker().get(eCardNo.FourthCard.getCardNo());

    //	Check value of kicker
    assertTrue(c1.getRank().getRank() == eRank.KING.getRank());

    //	Check value of kicker
    assertTrue(c2.getRank().getRank() == eRank.TEN.getRank());

    //	Check value of kicker
    assertTrue(c3.getRank().getRank() == eRank.THREE.getRank());

    //	Check value of kicker
    assertTrue(c4.getRank().getRank() == eRank.TWO.getRank());
  }
Exemple #15
0
 @Test
 public void testCard() {
   // if card was created (is not null)
   assertNotNull(card);
   // if card was created with proper rank
   assertEquals(rank3, card.getRank());
   // if cards suit is different than another suit
   assertNotEquals(suitD, card.getSuit());
   // if after change suits match
   card.setSuit(suitD);
   assertEquals(suitD, card.getSuit());
   // if card's String representation is as expected
   assertEquals("3♦", card.toString());
 }
Exemple #16
0
 @Test
 public void testValidateValidCard() throws NoCardInsertedException {
   System.out.println("validateValidCard");
   ATM atmTest = new ATM(1000.0);
   Card mockCard = mock(Card.class);
   int pinCode = 7777;
   when(mockCard.isBlocked()).thenReturn(false);
   when(mockCard.checkPin(pinCode)).thenReturn(true);
   boolean expResult = true;
   boolean result = atmTest.validateCard(mockCard, pinCode);
   assertEquals(expResult, result);
   InOrder inOrder = inOrder(mockCard);
   inOrder.verify(mockCard).isBlocked();
   inOrder.verify(mockCard).checkPin(pinCode);
 }
Exemple #17
0
 @Test
 public void testCheckBalance() throws NoCardInsertedException {
   System.out.println("checkBalance");
   ATM atmTest = new ATM(1000.0);
   Card mockCard = mock(Card.class);
   Account mockAccount = mock(Account.class);
   atmTest.insertCard(mockCard);
   when(mockCard.getAccount()).thenReturn(mockAccount);
   when(mockAccount.getBalance()).thenReturn(0.0);
   double expResult = 0.0;
   double result = atmTest.checkBalance();
   assertEquals(expResult, result, 0.0);
   InOrder inOrder = inOrder(mockCard, mockAccount);
   inOrder.verify(mockCard).getAccount();
   inOrder.verify(mockAccount).getBalance();
 }
Exemple #18
0
 @Test
 public void CardDB() throws ClassNotFoundException {
   name = "Grapeshot Catapult";
   set = "Old";
   rarity = "Common";
   foil = "false";
   Card card = new Card(name, set, rarity, foil, conditions);
   Database db = new Database("TestDB");
   try {
     card.sendToDatabase(db);
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   assertNotNull(db);
 }
Exemple #19
0
 @Test
 public final void testCompareTo() {
   Assert.assertEquals(AC.compareTo(AC), 0);
   Assert.assertEquals(AC.compareTo(AC2), 0);
   Assert.assertEquals(AC.compareTo(new Card(CardValue.ACE, CardSuit.CLUBS)), 0);
   Assert.assertFalse(AC.compareTo(KH) == 0);
   Assert.assertTrue(AC.compareTo(KH) > 0);
   Assert.assertTrue(KH.compareTo(AC) < 0);
   Assert.assertTrue(KS.compareTo(KH) > 0);
   Assert.assertTrue(KH.compareTo(KS) < 0);
 }
Exemple #20
0
 @Test(expected = NotEnoughMoneyInATMException.class)
 public void testGetCashNotEnoughMoneyInATM()
     throws NoCardInsertedException, NotEnoughMoneyInAccountException,
         NotEnoughMoneyInATMException {
   System.out.println("getCashNotEnoughMoneyInATM");
   ATM atmTest = new ATM(1000.0);
   Card mockCard = mock(Card.class);
   Account mockAccount = mock(Account.class);
   double amount = 1100.0;
   int pinCode = 7777;
   atmTest.insertCard(mockCard); // ver.2
   when(mockCard.getAccount()).thenReturn(mockAccount);
   when(mockCard.checkPin(pinCode)).thenReturn(true);
   atmTest.validateCard(mockCard, pinCode);
   atmTest.getCash(amount);
   InOrder inOrder = inOrder(mockCard, mockAccount);
   inOrder.verify(mockCard).getAccount();
   inOrder.verify(mockAccount).getBalance();
 }
Exemple #21
0
  @Test
  public void FourOfAKind_1() {
    Deck d = new Deck();
    Hand h = new Hand();
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.DIAMONDS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.SPADES, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.HEARTS, eRank.TEN, 0));
    h.AddCardToHand(new Card(eSuit.CLUBS, eRank.NINE, 0));
    h.EvalHand();

    assertTrue(h.getHandStrength() == eHandStrength.FourOfAKind.getHandStrength());
    assertTrue(h.getHighPairStrength() == eRank.TEN.getRank());
    assertTrue(h.getLowPairStrength() == 0);
    assertTrue(h.getKicker().size() == 1);

    Card c1 = h.getKicker().get(eCardNo.FirstCard.getCardNo());

    //	Check to see if the kicker is a NINE
    assertTrue(c1.getRank().getRank() == eRank.NINE.getRank());
  }
Exemple #22
0
 @Test
 public final void testGetValue() {
   Assert.assertEquals(CardValue.ACE, AC.getValue());
   Assert.assertEquals(CardValue.KING, KH.getValue());
   Assert.assertEquals(AC.getValue(), AC2.getValue());
   Assert.assertFalse(AC.getValue().equals(KH.getValue()));
 }
Exemple #23
0
 @Test
 public final void testGetSuit() {
   Assert.assertEquals(CardSuit.CLUBS, AC.getSuit());
   Assert.assertEquals(CardSuit.HEARTS, KH.getSuit());
   Assert.assertEquals(AC.getSuit(), AC2.getSuit());
   Assert.assertFalse(AC.getSuit().equals(KH.getSuit()));
 }
Exemple #24
0
 @Test
 public final void testToString() {
   String expected = "Ace of CLUBS";
   Assert.assertEquals(expected, AC.toString());
 }
Exemple #25
0
 @Test
 public final void testHashCode() {
   Assert.assertEquals(AC.hashCode(), AC2.hashCode());
   Assert.assertFalse(AC.hashCode() == KH.hashCode());
 }
 @Test
 public void number() {
   assertTrue(card.getNumber() == number);
 }
Exemple #27
0
 @Test
 public void createCards() {
   name = "Grapeshot Catapult";
   set = "Old";
   rarity = "Common";
   foil = "false";
   Card card = new Card(name, set, rarity, foil, conditions);
   assertEquals(card.getName(), "Grapeshot Catapult");
   assertEquals(card.getConditions(), conditions);
   assertEquals(card.getFoil(), "false");
   assertEquals(card.getSet(), "Old");
   assertEquals(card.getRarity(), "Common");
   assertEquals(card.getTotal(), "9");
   Card newCard = new Card("Cool", "New", rarity, foil, conditions);
   assertEquals(newCard.getName(), "Cool");
   assertNotEquals(card.getSet(), "New");
   assertEquals(newCard.getSet(), "New");
 }