73 lines
2.0 KiB
Java
73 lines
2.0 KiB
Java
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.Test;
|
|
import java.util.ArrayList;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
public class CardsTest {
|
|
private Cards cards, cards2, cards3;
|
|
private Card newCard, card, newerCard;
|
|
private ArrayList<Card> cardsArrayList, cardsArrayList2, cardsArrayList3;
|
|
|
|
@BeforeEach
|
|
void setUp() {
|
|
card = new Card("Name", 10, ElementTyp.WATER, CardType.MONSTER);
|
|
newCard = new Card("NameNew", 10, ElementTyp.WATER, CardType.SPELL);
|
|
newerCard = new Card("NameNewerer", 100, ElementTyp.FIRE, CardType.MONSTER);
|
|
cardsArrayList = new ArrayList<Card>();
|
|
cardsArrayList2 = new ArrayList<Card>();
|
|
cardsArrayList3 = new ArrayList<Card>();
|
|
cardsArrayList.add(card);
|
|
cardsArrayList2.add(newCard);
|
|
cardsArrayList2.add(card);
|
|
cardsArrayList3.add(newerCard);
|
|
cards = new Cards(cardsArrayList);
|
|
cards2 = new Cards(cardsArrayList2);
|
|
cards3 = new Cards(cardsArrayList3);
|
|
}
|
|
@Test
|
|
void test_addCard() {
|
|
System.out.println(cards.getCards().toString());
|
|
cards.addCard(newCard);
|
|
System.out.println(cards.getCards().toString());
|
|
System.out.println(cards2.getCards().toString());
|
|
assertTrue(cards.equals(cards2));
|
|
}
|
|
|
|
@Test
|
|
void test_addCard2() {
|
|
cards.addCard(newCard);
|
|
assertFalse(cards.equals(cards3));
|
|
}
|
|
|
|
@Test
|
|
void test_equals() {
|
|
assertFalse(cards.equals(cards2));
|
|
}
|
|
|
|
@Test
|
|
void test_contains() {
|
|
assertTrue(cards2.containsCard(card));
|
|
}
|
|
|
|
@Test
|
|
void test_contains2() {
|
|
assertFalse(cards.containsCard(newCard));
|
|
}
|
|
|
|
@Test
|
|
void test_delCard() {
|
|
cards.addCard(newCard);
|
|
|
|
cards.delCard(newCard);
|
|
|
|
assertTrue(cards.getCards().equals(cardsArrayList));
|
|
}
|
|
@Test
|
|
void test_getCards() {
|
|
assertTrue(cards.getCards().equals(cardsArrayList));
|
|
}
|
|
|
|
}
|