コード例 #1
0
  @Test
  public void testCardSetnGetSuit() {
    Card testCard = new Card();

    // test get and set methods for card suit
    // these functions must be tested together as
    // I need a way to check the private variables
    testCard.setSuit(1);
    assertEquals(1, testCard.getSuit());
  }
コード例 #2
0
  @Test
  public void testCardToString() {
    Card testCard = new Card();

    // Testing a cards toString() Functions
    // test ace of clubs
    testCard.setNumber(14);
    testCard.setSuit(1);
    assertEquals("AceClubs", testCard.toString());
    // test seven of hearts
    testCard.setNumber(7);
    testCard.setSuit(2);
    assertEquals("SevenHearts", testCard.toString());
    // test jack of spades
    testCard.setNumber(11);
    testCard.setSuit(3);
    assertEquals("JackSpades", testCard.toString());
  }
コード例 #3
0
  @Test
  public void testCardisEqual() {
    Card testCard = new Card();

    // isEqual(Card anotherCard) testign if 2 cards are equal
    testCard.setCard("QueenClubs");
    Card tempCard = new Card();
    tempCard.setCard("QueenClubs");
    assertEquals(true, testCard.isEqual(tempCard));
    tempCard.setCard("ThreeHearts");
    assertEquals(false, testCard.isEqual(tempCard));
  }
コード例 #4
0
  @Test
  public void testCardSetCard() {
    Card testCard = new Card();

    // Testing Set Card Functions
    // setCard(String) test1 *Valid Input*
    assertEquals(0, testCard.setCard("TwoSpades"));
    assertEquals("TwoSpades", testCard.toString());

    // setCard(String) test2 *Valid Input*
    assertEquals(0, testCard.setCard("QueenClubs"));
    assertEquals("QueenClubs", testCard.toString());

    // setCard(String) test3 *Invalid Input*
    assertEquals(-1, testCard.setCard("OneSpades"));

    // setCard(String) test4 *Invalid Input*
    assertEquals(-2, testCard.setCard("TwoHeads"));
  }