blob: a35bc32b0b3054b69de1fc8ddf69bc46ac73ea8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package eu.equalparts.cardbase.decks;
import static org.junit.Assert.*;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.equalparts.cardbase.cards.Card;
import eu.equalparts.cardbase.decks.ReferenceDeck;
import eu.equalparts.cardbase.decks.StandaloneDeck;
public class DeckTest {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@Test
public void test_createReferenceDeckFromStandaloneDeck() throws Exception {
ObjectMapper mapper = new ObjectMapper();
StandaloneDeck standaloneDeck = mapper.readValue(getClass().getResourceAsStream("deck.cbd"), StandaloneDeck.class);
ReferenceDeck uut = new ReferenceDeck(standaloneDeck);
boolean condition = uut.name == standaloneDeck.name &&
uut.plains == standaloneDeck.plains &&
uut.islands == standaloneDeck.islands &&
uut.swamps == standaloneDeck.swamps &&
uut.mountains == standaloneDeck.mountains &&
uut.forests == standaloneDeck.forests;
assertTrue("Metadata was not correctly set.", condition);
assertEquals("Wrong number of cards.", uut.cardReferences.size(), standaloneDeck.cards.size());
for (Card card : standaloneDeck.cards) {
Integer count = uut.cardReferences.get(card.hashCode());
assertNotNull("Reference missing in deck.", count);
assertEquals("Card count is wrong.", card.count, count);
}
}
}
|