示例#1
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());
 }
  @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");
    }
  }
示例#3
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);
 }
示例#4
0
  @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());
  }
示例#5
0
文件: CardTest.java 项目: ebratt/mit
 @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()));
 }