mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Merge pull request #118 from allentiak/reorganize-tests
forge-gui-desktop: Reorganize tests (forge.card)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,19 @@
|
||||
package forge.card;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.StaticData;
|
||||
import forge.gamesimulationtests.util.CardDatabaseHelper;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
public class CardDbTestLazyCardLoading extends ForgeCardMockTestCase {
|
||||
public class CardDbLazyCardLoadingCardMockTestCase extends CardMockTestCase {
|
||||
|
||||
protected CardDb cardDb;
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package forge.card;
|
||||
|
||||
import forge.item.PaperCard;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class CardDbPerformanceTests extends CardDbTestCase {
|
||||
import forge.item.PaperCard;
|
||||
|
||||
public class CardDbPerformanceTests extends CardDbCardMockTestCase {
|
||||
|
||||
private Set<String> fullDbCardNames = new TreeSet<>();
|
||||
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
package forge.card;
|
||||
|
||||
import forge.ImageCache;
|
||||
import forge.ImageKeys;
|
||||
import forge.item.PaperCard;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import forge.ImageCache;
|
||||
import forge.ImageKeys;
|
||||
import forge.item.PaperCard;
|
||||
|
||||
/**
|
||||
* Test Case for CardDb forcing No Image for all the cards.
|
||||
* Check that everything still applies the same.
|
||||
* Test Case for CardDb forcing No Image for all the cards. Check that
|
||||
* everything still applies the same.
|
||||
*
|
||||
* Note: Run test for the class, being subclass will also run all
|
||||
* other tests as regression.
|
||||
* Note: Run test for the class, being subclass will also run all other tests as
|
||||
* regression.
|
||||
*/
|
||||
public class CardDbTestWithNoImage extends CardDbTestCase {
|
||||
public class CardDbWithNoImageCardDbMockTestCase extends CardDbCardMockTestCase {
|
||||
|
||||
@Override
|
||||
@BeforeMethod
|
||||
@@ -1,16 +1,17 @@
|
||||
package forge.card;
|
||||
|
||||
import forge.deck.CardPool;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class CardEditionCollectionTestCase extends ForgeCardMockTestCase {
|
||||
import forge.deck.CardPool;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
|
||||
public class CardEditionCollectionCardMockTestCase extends CardMockTestCase {
|
||||
|
||||
@Test
|
||||
public void testGetTheLatestOfAllTheOriginalEditionsOfCardsInPoolWithOriginalSets() {
|
||||
@@ -1,5 +1,25 @@
|
||||
package forge.card;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
|
||||
import org.powermock.modules.testng.PowerMockTestCase;
|
||||
import org.testng.IObjectFactory;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.ObjectFactory;
|
||||
|
||||
import forge.ImageCache;
|
||||
import forge.ImageKeys;
|
||||
import forge.Singletons;
|
||||
@@ -11,31 +31,13 @@ import forge.localinstance.properties.ForgePreferences;
|
||||
import forge.model.FModel;
|
||||
import forge.util.Localizer;
|
||||
import forge.util.TextUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
|
||||
import org.powermock.modules.testng.PowerMockTestCase;
|
||||
import org.testng.IObjectFactory;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.ObjectFactory;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@PrepareForTest(value = {FModel.class, Singletons.class, ResourceBundle.class,
|
||||
ImageCache.class, ImageIO.class, ImageKeys.class,
|
||||
ForgeConstants.class, Localizer.class})
|
||||
@PrepareForTest(value = { FModel.class, Singletons.class, ResourceBundle.class, ImageCache.class, ImageIO.class,
|
||||
ImageKeys.class, ForgeConstants.class, Localizer.class })
|
||||
@SuppressStaticInitializationFor({ "forge.ImageCache", "forge.localinstance.properties.ForgeConstants" })
|
||||
@PowerMockIgnore({"javax.xml.*", "org.xml.sax.*", "com.sun.org.apache.xerces.*", "org.w3c.dom.*", "org.springframework.context.*", "org.apache.log4j.*"})
|
||||
public class ForgeCardMockTestCase extends PowerMockTestCase {
|
||||
@PowerMockIgnore({ "javax.xml.*", "org.xml.sax.*", "com.sun.org.apache.xerces.*", "org.w3c.dom.*",
|
||||
"org.springframework.context.*", "org.apache.log4j.*" })
|
||||
public class CardMockTestCase extends PowerMockTestCase {
|
||||
|
||||
public static final String MOCKED_LOCALISED_STRING = "any localised string";
|
||||
|
||||
@@ -73,7 +75,7 @@ public class ForgeCardMockTestCase extends PowerMockTestCase {
|
||||
Field fAssetsDir = PowerMockito.field(ForgeConstants.class, "ASSETS_DIR");
|
||||
fAssetsDir.set(ForgeConstants.class, assetDir);
|
||||
// User Dir
|
||||
String homeDir = ForgeCardMockTestCase.getUserDir();
|
||||
String homeDir = CardMockTestCase.getUserDir();
|
||||
Field fUserDir = PowerMockito.field(ForgeConstants.class, "USER_DIR");
|
||||
fUserDir.set(ForgeConstants.class, homeDir);
|
||||
// User Pref Dir
|
||||
@@ -130,8 +132,11 @@ public class ForgeCardMockTestCase extends PowerMockTestCase {
|
||||
|
||||
@BeforeMethod
|
||||
protected void initMocks() throws Exception {
|
||||
//Loading a card also automatically loads the image, which we do not want (even if it wouldn't cause exceptions).
|
||||
//The static initializer block in ImageCache can't fully be mocked (https://code.google.com/p/powermock/issues/detail?id=256), so we also need to mess with ImageIO...
|
||||
// Loading a card also automatically loads the image, which we do not want (even
|
||||
// if it wouldn't cause exceptions).
|
||||
// The static initializer block in ImageCache can't fully be mocked
|
||||
// (https://code.google.com/p/powermock/issues/detail?id=256), so we also need
|
||||
// to mess with ImageIO...
|
||||
initCardImageMocks();
|
||||
initForgeConstants();
|
||||
// Mocking some more static stuff
|
||||
@@ -166,7 +171,8 @@ public class ForgeCardMockTestCase extends PowerMockTestCase {
|
||||
}
|
||||
|
||||
protected void initCardImageMocks() {
|
||||
//make sure that loading images only happens in a GUI environment, so we no longer need to mock this
|
||||
// make sure that loading images only happens in a GUI environment, so we no
|
||||
// longer need to mock this
|
||||
PowerMockito.mockStatic(ImageIO.class);
|
||||
PowerMockito.mockStatic(ImageCache.class);
|
||||
PowerMockito.mockStatic(ImageKeys.class);
|
||||
@@ -1,14 +1,19 @@
|
||||
package forge.card;
|
||||
|
||||
import forge.card.CardDb.CardRequest;
|
||||
import forge.item.IPaperCard;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
import forge.card.CardDb.CardRequest;
|
||||
import forge.item.IPaperCard;
|
||||
|
||||
@Test(timeOut = 1000, enabled = true)
|
||||
public class CardRequestTestCase {
|
||||
public class CardRequestTest {
|
||||
|
||||
private String cardName;
|
||||
private String edition;
|
||||
@@ -74,7 +79,8 @@ public class CardRequestTestCase {
|
||||
requestInfo = CardRequest.compose(cardName, edition, collNr + "]");
|
||||
assertEquals(requestInfo, expected);
|
||||
|
||||
// collNr with leading spaces, as possible result from a wrong parsing in a deck file
|
||||
// collNr with leading spaces, as possible result from a wrong parsing in a deck
|
||||
// file
|
||||
requestInfo = CardRequest.compose(cardName, edition, "\t\t 175 ");
|
||||
assertEquals(requestInfo, expected);
|
||||
|
||||
@@ -131,7 +137,6 @@ public class CardRequestTestCase {
|
||||
assertEquals(request.artIndex, 20);
|
||||
assertEquals(request.collectorNumber, IPaperCard.NO_COLLECTOR_NUMBER);
|
||||
|
||||
|
||||
// foil
|
||||
requestString = foilCardNameFoil + sep + foilEdition + sep + IPaperCard.DEFAULT_ART_INDEX;
|
||||
request = CardRequest.fromString(requestString);
|
||||
@@ -226,14 +231,16 @@ public class CardRequestTestCase {
|
||||
assertEquals(request.collectorNumber, IPaperCard.NO_COLLECTOR_NUMBER);
|
||||
}
|
||||
|
||||
@Test void isFoilCardNameMethod(){
|
||||
@Test
|
||||
void isFoilCardNameMethod() {
|
||||
assertTrue(CardRequest.isFoilCardName("Counterspell+"));
|
||||
assertFalse(CardRequest.isFoilCardName("Counterspell"));
|
||||
assertTrue(CardRequest.isFoilCardName(" Counterspell+ "));
|
||||
assertFalse(CardRequest.isFoilCardName(" Counterspell "));
|
||||
}
|
||||
|
||||
@Test void testComposeCardRequestWithCardNameAndFoil(){
|
||||
@Test
|
||||
void testComposeCardRequestWithCardNameAndFoil() {
|
||||
String cardName = "Counterspell";
|
||||
String foilCardName = "Counterspell+";
|
||||
|
||||
@@ -1,49 +1,54 @@
|
||||
package forge.card;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimaps;
|
||||
|
||||
import forge.item.PaperCard;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.CollectionSuppliers;
|
||||
import forge.util.MyRandom;
|
||||
import forge.util.TextUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Test Class (only for test purposes) to compare previous method implementations
|
||||
* with the new refactored ones. This class has been updated to the latest version
|
||||
* available of methods' implementation before the change is going to be submitted.
|
||||
* This is also a useful way to keep a backlog of changes whenever major
|
||||
* API changes like this MR are going to happen.
|
||||
* Test Class (only for test purposes) to compare previous method
|
||||
* implementations with the new refactored ones. This class has been updated to
|
||||
* the latest version available of methods' implementation before the change is
|
||||
* going to be submitted. This is also a useful way to keep a backlog of changes
|
||||
* whenever major API changes like this MR are going to happen.
|
||||
*/
|
||||
public class LegacyCardDb {
|
||||
public CardEdition.Collection editions;
|
||||
public ListMultimap<String, PaperCard> allCardsByName = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
|
||||
public ListMultimap<String, PaperCard> allCardsByName = Multimaps
|
||||
.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
|
||||
|
||||
public enum LegacySetPreference {
|
||||
Latest(false),
|
||||
LatestCoreExp(true),
|
||||
Earliest(false),
|
||||
EarliestCoreExp(true),
|
||||
Random(false);
|
||||
Latest(false), LatestCoreExp(true), Earliest(false), EarliestCoreExp(true), Random(false);
|
||||
|
||||
final boolean filterSets;
|
||||
|
||||
LegacySetPreference(boolean filterIrregularSets) {
|
||||
filterSets = filterIrregularSets;
|
||||
}
|
||||
|
||||
public boolean accept(CardEdition ed) {
|
||||
if (ed == null) return false;
|
||||
return !filterSets || ed.getType() == CardEdition.Type.CORE || ed.getType() == CardEdition.Type.EXPANSION || ed.getType() == CardEdition.Type.REPRINT;
|
||||
if (ed == null)
|
||||
return false;
|
||||
return !filterSets || ed.getType() == CardEdition.Type.CORE || ed.getType() == CardEdition.Type.EXPANSION
|
||||
|| ed.getType() == CardEdition.Type.REPRINT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public final static String foilSuffix = "+";
|
||||
public final static char NameSetSeparator = '|';
|
||||
|
||||
@@ -70,7 +75,8 @@ public class LegacyCardDb {
|
||||
String[] nameParts = TextUtil.split(name, NameSetSeparator);
|
||||
|
||||
int setPos = nameParts.length >= 2 && !StringUtils.isNumeric(nameParts[1]) ? 1 : -1;
|
||||
int artPos = nameParts.length >= 2 && StringUtils.isNumeric(nameParts[1]) ? 1 : nameParts.length >= 3 && StringUtils.isNumeric(nameParts[2]) ? 2 : -1;
|
||||
int artPos = nameParts.length >= 2 && StringUtils.isNumeric(nameParts[1]) ? 1
|
||||
: nameParts.length >= 3 && StringUtils.isNumeric(nameParts[2]) ? 2 : -1;
|
||||
|
||||
String cardName = nameParts[0];
|
||||
if (cardName.endsWith(foilSuffix)) {
|
||||
@@ -133,7 +139,9 @@ public class LegacyCardDb {
|
||||
|
||||
private PaperCard tryGetCard(LegacyCardDb.LegacyCardRequest request) {
|
||||
Collection<PaperCard> cards = getAllCards(request.cardName);
|
||||
if (cards == null) { return null; }
|
||||
if (cards == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PaperCard result = null;
|
||||
|
||||
@@ -149,8 +157,7 @@ public class LegacyCardDb {
|
||||
Collection<PaperCard> candidates;
|
||||
if (reqEdition == null) {
|
||||
candidates = new ArrayList<>(cards);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
candidates = new ArrayList<>();
|
||||
for (PaperCard pc : cards) {
|
||||
if (pc.getEdition().equalsIgnoreCase(reqEdition)) {
|
||||
@@ -168,8 +175,7 @@ public class LegacyCardDb {
|
||||
candidates.remove(result);
|
||||
result = Aggregates.random(candidates);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for (PaperCard pc : cards) {
|
||||
if (pc.getEdition().equalsIgnoreCase(reqEdition) && request.artIndex == pc.getArtIndex()) {
|
||||
result = pc;
|
||||
@@ -177,7 +183,9 @@ public class LegacyCardDb {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result == null) { return null; }
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return request.isFoil ? getFoiled(result) : result;
|
||||
}
|
||||
@@ -190,19 +198,23 @@ public class LegacyCardDb {
|
||||
return getCardFromEdition(cardName, null, fromSet);
|
||||
}
|
||||
|
||||
public PaperCard getCardFromEdition(final String cardName, final Date printedBefore, final LegacySetPreference fromSet) {
|
||||
public PaperCard getCardFromEdition(final String cardName, final Date printedBefore,
|
||||
final LegacySetPreference fromSet) {
|
||||
return getCardFromEdition(cardName, printedBefore, fromSet, -1);
|
||||
}
|
||||
|
||||
public PaperCard getCardFromEdition(final String cardName, final Date printedBefore, final LegacySetPreference fromSets, int artIndex) {
|
||||
public PaperCard getCardFromEdition(final String cardName, final Date printedBefore,
|
||||
final LegacySetPreference fromSets, int artIndex) {
|
||||
final CardDb.CardRequest cr = CardDb.CardRequest.fromString(cardName);
|
||||
LegacySetPreference fromSet = fromSets;
|
||||
List<PaperCard> cards = getAllCards(cr.cardName);
|
||||
if (printedBefore != null) {
|
||||
cards = Lists.newArrayList(Iterables.filter(cards, new Predicate<PaperCard>() {
|
||||
@Override public boolean apply(PaperCard c) {
|
||||
@Override
|
||||
public boolean apply(PaperCard c) {
|
||||
CardEdition ed = editions.get(c.getEdition());
|
||||
return ed.getDate().before(printedBefore); }
|
||||
return ed.getDate().before(printedBefore);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -217,7 +229,10 @@ public class LegacyCardDb {
|
||||
|
||||
if (StringUtils.isNotBlank(cr.edition)) {
|
||||
cards = Lists.newArrayList(Iterables.filter(cards, new Predicate<PaperCard>() {
|
||||
@Override public boolean apply(PaperCard input) { return input.getEdition().equalsIgnoreCase(cr.edition); }
|
||||
@Override
|
||||
public boolean apply(PaperCard input) {
|
||||
return input.getEdition().equalsIgnoreCase(cr.edition);
|
||||
}
|
||||
}));
|
||||
}
|
||||
if (artIndex == -1 && cr.artIndex > 0) {
|
||||
@@ -234,18 +249,18 @@ public class LegacyCardDb {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((artIndex <= 0 || pc.getArtIndex() == artIndex) && (printedBefore == null || ed.getDate().before(printedBefore))) {
|
||||
if ((artIndex <= 0 || pc.getArtIndex() == artIndex)
|
||||
&& (printedBefore == null || ed.getDate().before(printedBefore))) {
|
||||
if (pc.hasImage()) {
|
||||
return pc;
|
||||
}
|
||||
else if (firstWithoutImage == null) {
|
||||
} else if (firstWithoutImage == null) {
|
||||
firstWithoutImage = pc; // ensure first without image returns if none have image
|
||||
}
|
||||
}
|
||||
}
|
||||
return firstWithoutImage;
|
||||
}
|
||||
else if (fromSet == LegacySetPreference.LatestCoreExp || fromSet == LegacySetPreference.Latest || fromSet == null || fromSet == LegacySetPreference.Random) {
|
||||
} else if (fromSet == LegacySetPreference.LatestCoreExp || fromSet == LegacySetPreference.Latest
|
||||
|| fromSet == null || fromSet == LegacySetPreference.Random) {
|
||||
PaperCard firstWithoutImage = null;
|
||||
for (int i = 0; i < sz; i++) {
|
||||
PaperCard pc = cards.get(i);
|
||||
@@ -254,23 +269,21 @@ public class LegacyCardDb {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((artIndex < 0 || pc.getArtIndex() == artIndex) && (printedBefore == null || ed.getDate().before(printedBefore))) {
|
||||
if ((artIndex < 0 || pc.getArtIndex() == artIndex)
|
||||
&& (printedBefore == null || ed.getDate().before(printedBefore))) {
|
||||
if (fromSet == LegacySetPreference.LatestCoreExp || fromSet == LegacySetPreference.Latest) {
|
||||
if (pc.hasImage()) {
|
||||
return pc;
|
||||
}
|
||||
else if (firstWithoutImage == null) {
|
||||
} else if (firstWithoutImage == null) {
|
||||
firstWithoutImage = pc; // ensure first without image returns if none have image
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
while (sz > i) {
|
||||
int randomIndex = i + MyRandom.getRandom().nextInt(sz - i);
|
||||
pc = cards.get(randomIndex);
|
||||
if (pc.hasImage()) {
|
||||
return pc;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (firstWithoutImage == null) {
|
||||
firstWithoutImage = pc; // ensure first without image returns if none have image
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ package forge.gamesimulationtests;
|
||||
import forge.ImageCache;
|
||||
import forge.ImageKeys;
|
||||
import forge.Singletons;
|
||||
import forge.card.ForgeCardMockTestCase;
|
||||
import forge.card.CardMockTestCase;
|
||||
import forge.game.GameLogFormatter;
|
||||
import forge.gamesimulationtests.util.GameWrapper;
|
||||
import forge.gamesimulationtests.util.player.PlayerSpecification;
|
||||
@@ -24,12 +24,12 @@ import org.testng.annotations.BeforeMethod;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@PrepareForTest(value = {FModel.class, Singletons.class, ResourceBundle.class,
|
||||
ImageCache.class, ImageIO.class, ImageKeys.class,
|
||||
ForgeConstants.class, Localizer.class, Sentry.class, GameLogFormatter.class})
|
||||
@PrepareForTest(value = { FModel.class, Singletons.class, ResourceBundle.class, ImageCache.class, ImageIO.class,
|
||||
ImageKeys.class, ForgeConstants.class, Localizer.class, Sentry.class, GameLogFormatter.class })
|
||||
@SuppressStaticInitializationFor({ "forge.ImageCache", "forge.localinstance.properties.ForgeConstants" })
|
||||
@PowerMockIgnore({"javax.xml.*", "org.xml.sax.*", "com.sun.org.apache.xerces.*", "org.w3c.dom.*", "org.springframework.context.*", "org.apache.log4j.*"})
|
||||
public class BaseGameSimulationTest extends ForgeCardMockTestCase {
|
||||
@PowerMockIgnore({ "javax.xml.*", "org.xml.sax.*", "com.sun.org.apache.xerces.*", "org.w3c.dom.*",
|
||||
"org.springframework.context.*", "org.apache.log4j.*" })
|
||||
public class BaseGameSimulationTest extends CardMockTestCase {
|
||||
|
||||
@BeforeMethod
|
||||
@Override
|
||||
@@ -41,7 +41,8 @@ public class BaseGameSimulationTest extends ForgeCardMockTestCase {
|
||||
Lang.createInstance("en-US");
|
||||
}
|
||||
|
||||
protected void runGame(GameWrapper game, PlayerSpecification expectedWinner, int finalTurn, AssertAction... postGameAssertActions) {
|
||||
protected void runGame(GameWrapper game, PlayerSpecification expectedWinner, int finalTurn,
|
||||
AssertAction... postGameAssertActions) {
|
||||
try {
|
||||
initMocks();
|
||||
game.runGame();
|
||||
@@ -57,7 +58,8 @@ public class BaseGameSimulationTest extends ForgeCardMockTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected void verifyThatTheGameHasFinishedAndThatPlayerHasWonOnTurn(GameWrapper game, PlayerSpecification expectedWinner, int finalTurn) {
|
||||
protected void verifyThatTheGameHasFinishedAndThatPlayerHasWonOnTurn(GameWrapper game,
|
||||
PlayerSpecification expectedWinner, int finalTurn) {
|
||||
Assert.assertTrue(game.getGame().isGameOver());
|
||||
Assert.assertEquals(game.getGame().getOutcome().getLastTurnNumber(), finalTurn);
|
||||
Assert.assertEquals(game.getGame().getOutcome().getWinningPlayer().getPlayer().getName(),
|
||||
|
||||
Reference in New Issue
Block a user