mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Lazy loading of forge.Card instances
This commit is contained in:
@@ -1,128 +0,0 @@
|
||||
package forge;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.slightlymagic.braids.util.testng.BraidsAssertFunctions;
|
||||
import net.slightlymagic.braids.util.testng.ClumsyRunnable;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
|
||||
/**
|
||||
* Created by hand to test the CardReader class.
|
||||
*/
|
||||
@Test(groups = { "UnitTest" }, enabled = false)
|
||||
public class CardReaderTest {
|
||||
|
||||
/** The default test-timeout. */
|
||||
public static final int TEST_TIMEOUT = 1000;
|
||||
|
||||
/** The estimated number of cards in the cardsfolder. */
|
||||
public static final int ESTIMATED_CARDS_IN_FOLDER = 9001;
|
||||
|
||||
/**
|
||||
* Test_ read card_null map.
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = CardReaderTest.TEST_TIMEOUT)
|
||||
public final void test_ReadCard_nullMap() {
|
||||
final ClumsyRunnable withScissors = new ClumsyRunnable() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
new CardReader(ForgeProps.getFile(NewConstants.CARDSFOLDER), null);
|
||||
}
|
||||
};
|
||||
|
||||
BraidsAssertFunctions.assertThrowsException(NullPointerException.class, withScissors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test_ read card_null cards folder.
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = CardReaderTest.TEST_TIMEOUT)
|
||||
public final void test_ReadCard_nullCardsFolder() {
|
||||
final ClumsyRunnable withScissors = new ClumsyRunnable() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
final Map<String, Card> map = new HashMap<String, Card>();
|
||||
new CardReader(null, map);
|
||||
}
|
||||
};
|
||||
|
||||
BraidsAssertFunctions.assertThrowsException(NullPointerException.class, withScissors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test_ read card_nonexistent cards folder.
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = CardReaderTest.TEST_TIMEOUT)
|
||||
public final void test_ReadCard_nonexistentCardsFolder() {
|
||||
final ClumsyRunnable withScissors = new ClumsyRunnable() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
final Map<String, Card> map = new HashMap<String, Card>();
|
||||
new CardReader(
|
||||
new File(
|
||||
"this_does_not_exist_fjksdjfsdjfkdjslkfksdlajfikajfklsdhfksdalfhjklsdahfeakslfdsfdsfdsfdsfdssfc"),
|
||||
map);
|
||||
}
|
||||
};
|
||||
|
||||
BraidsAssertFunctions.assertThrowsException(RuntimeException.class, withScissors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test_ read card_file not folder.
|
||||
*
|
||||
* @throws IOException
|
||||
* Signals that an I/O exception has occurred.
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = CardReaderTest.TEST_TIMEOUT)
|
||||
public final void test_ReadCard_fileNotFolder() throws IOException {
|
||||
|
||||
final File tmpFile = File.createTempFile("just-a-file", ".testng.tmp");
|
||||
tmpFile.deleteOnExit(); // request VM to delete later
|
||||
|
||||
final ClumsyRunnable withScissors = new ClumsyRunnable() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
final Map<String, Card> map = new HashMap<String, Card>();
|
||||
new CardReader(tmpFile, map);
|
||||
}
|
||||
};
|
||||
|
||||
BraidsAssertFunctions.assertThrowsException(RuntimeException.class, withScissors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test_ read card_run_nonzip.
|
||||
*/
|
||||
@Test(groups = { "slow" }, enabled = false)
|
||||
public final void test_ReadCard_run_nonzip() {
|
||||
final Map<String, Card> map = new HashMap<String, Card>(2 * CardReaderTest.ESTIMATED_CARDS_IN_FOLDER);
|
||||
final File cardsfolder = ForgeProps.getFile(NewConstants.CARDSFOLDER);
|
||||
final CardReader cardReader = new CardReader(cardsfolder, map, null, false);
|
||||
cardReader.run();
|
||||
Assert.assertNotNull(map.get("Elvish Warrior"), "Elvish Warrior was loaded");
|
||||
Assert.assertNotNull(map.get("Savannah Lions"), "Savannah Lions were loaded");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test_ read card_run_zip.
|
||||
*/
|
||||
@Test(groups = { "slow" }, enabled = false)
|
||||
public final void test_ReadCard_run_zip() {
|
||||
final Map<String, Card> map = new HashMap<String, Card>(2 * CardReaderTest.ESTIMATED_CARDS_IN_FOLDER);
|
||||
final File cardsfolder = ForgeProps.getFile(NewConstants.CARDSFOLDER);
|
||||
final CardReader cardReader = new CardReader(cardsfolder, map);
|
||||
cardReader.run();
|
||||
Assert.assertNotNull(map.get("Elvish Warrior"), "Elvish Warrior was loaded");
|
||||
Assert.assertNotNull(map.get("Savannah Lions"), "Savannah Lions were loaded");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package forge;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.gui.GuiMultipleBlockers;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA. User: dhudson
|
||||
*/
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000, enabled = false)
|
||||
public class GuiMultipleBlockers4Test {
|
||||
|
||||
/**
|
||||
* Gui multiple blockers4 test1.
|
||||
*/
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
public void guiMultipleBlockers4Test1() {
|
||||
final CardList list = new CardList();
|
||||
list.add(AllZone.getCardFactory().getCard("Elvish Piper", null));
|
||||
list.add(AllZone.getCardFactory().getCard("Lantern Kami", null));
|
||||
list.add(AllZone.getCardFactory().getCard("Frostling", null));
|
||||
list.add(AllZone.getCardFactory().getCard("Frostling", null));
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
new GuiMultipleBlockers(null, list, i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,8 @@
|
||||
package forge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.card.CardManaCost;
|
||||
import forge.card.cardfactory.CardFactoryInterface;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaCostParser;
|
||||
import forge.control.input.InputPayManaCostUtil;
|
||||
import forge.game.phase.CombatUtil;
|
||||
|
||||
/**
|
||||
@@ -36,6 +27,7 @@ public class RunTest {
|
||||
Card c;
|
||||
final CardFactoryInterface cf = AllZone.getCardFactory();
|
||||
// ********* test Card
|
||||
/*
|
||||
c = cf.getCard("Elvish Warrior", AllZone.getComputerPlayer());
|
||||
this.check("1", c.getOwner().isComputer());
|
||||
this.check("1.1", c.getName().equals("Elvish Warrior"));
|
||||
@@ -221,7 +213,7 @@ public class RunTest {
|
||||
// test Input_PayManaCostUtil
|
||||
this.check("98", InputPayManaCostUtil.getLongColorString("G").equals(Constant.Color.GREEN));
|
||||
this.check("99", InputPayManaCostUtil.getLongColorString("1").equals(Constant.Color.COLORLESS));
|
||||
|
||||
*/
|
||||
/*
|
||||
* check("101", Input_PayManaCostUtil.isManaNeeded(Constant.Color.Green,
|
||||
* new ManaCost("5")) == true); check("102",
|
||||
@@ -255,7 +247,7 @@ public class RunTest {
|
||||
c2.addIntrinsicKeyword("Flying");
|
||||
this.check("109", CombatUtil.canBlock(c, c2));
|
||||
this.check("110", !CombatUtil.canBlock(c2, c));
|
||||
|
||||
/*
|
||||
c = cf.getCard("Fyndhorn Elves", null);
|
||||
c2 = cf.getCard("Talas Warrior", null);
|
||||
this.check("110a", !CombatUtil.canBlock(c2, c));
|
||||
@@ -326,6 +318,7 @@ public class RunTest {
|
||||
this.check("125", CardUtil.getConvertedManaCost("R R R") == 3);
|
||||
this.check("126", CardUtil.getConvertedManaCost("1") == 1);
|
||||
this.check("127", CardUtil.getConvertedManaCost("2/R 2/G 2/W 2/B 2/U") == 10);
|
||||
*/
|
||||
} // test()
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user