mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
changed Constants and NewConstants from Interfaces to static classes.
This commit is contained in:
@@ -1,63 +1,78 @@
|
||||
package forge;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.card.BoosterGenerator;
|
||||
import forge.deck.Deck;
|
||||
|
||||
import forge.game.limited.IBoosterDraft;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPool;
|
||||
import forge.item.ItemPoolView;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* <p>BoosterDraftTest class.</p>
|
||||
*
|
||||
* <p>
|
||||
* BoosterDraftTest class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000, enabled = false)
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000, enabled = false)
|
||||
public class BoosterDraftTest implements IBoosterDraft {
|
||||
|
||||
/** The n. */
|
||||
int n = 3;
|
||||
|
||||
/**
|
||||
* <p>getDecks.</p>
|
||||
*
|
||||
* <p>
|
||||
* getDecks.
|
||||
* </p>
|
||||
*
|
||||
* @return an array of {@link forge.deck.Deck} objects.
|
||||
*/
|
||||
@Override
|
||||
@Test(timeOut = 1000)
|
||||
public Deck[] getDecks() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>nextChoice.</p>
|
||||
*
|
||||
* <p>
|
||||
* nextChoice.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
@Override
|
||||
public ItemPoolView<CardPrinted> nextChoice() {
|
||||
n--;
|
||||
BoosterGenerator pack = new BoosterGenerator(SetUtils.getSetByCode("M11"));
|
||||
this.n--;
|
||||
final BoosterGenerator pack = new BoosterGenerator(SetUtils.getSetByCode("M11"));
|
||||
return ItemPool.createFrom(pack.getBoosterPack(), CardPrinted.class);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void setChoice(CardPrinted c) {
|
||||
@Override
|
||||
public void setChoice(final CardPrinted c) {
|
||||
System.out.println(c.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>hasNextChoice.</p>
|
||||
*
|
||||
* <p>
|
||||
* hasNextChoice.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
public boolean hasNextChoice() {
|
||||
return n > 0;
|
||||
return this.n > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getChosenCards.</p>
|
||||
*
|
||||
* <p>
|
||||
* getChosenCards.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public CardList getChosenCards() {
|
||||
@@ -65,14 +80,19 @@ public class BoosterDraftTest implements IBoosterDraft {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getUnchosenCards.</p>
|
||||
*
|
||||
* <p>
|
||||
* getUnchosenCards.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public CardList getUnchosenCards() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.limited.IBoosterDraft#finishedDrafting()
|
||||
*/
|
||||
@Override
|
||||
public void finishedDrafting() {
|
||||
|
||||
|
||||
@@ -2,27 +2,27 @@ package forge;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
||||
import forge.game.limited.BoosterDraft;
|
||||
import forge.game.limited.CardPoolLimitation;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPoolView;
|
||||
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000)
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000)
|
||||
public class BoosterDraft_1Test {
|
||||
|
||||
/**
|
||||
* Booster draft_1 test1.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = 1000)
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = 1000)
|
||||
public void BoosterDraft_1Test1() throws Exception {
|
||||
BoosterDraft draft = new BoosterDraft(CardPoolLimitation.Full);
|
||||
final BoosterDraft draft = new BoosterDraft(CardPoolLimitation.Full);
|
||||
while (draft.hasNextChoice()) {
|
||||
ItemPoolView<CardPrinted> list = draft.nextChoice();
|
||||
final ItemPoolView<CardPrinted> list = draft.nextChoice();
|
||||
System.out.println(list.countAll());
|
||||
draft.setChoice(list.toFlatList().get(0));
|
||||
}
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
package forge;
|
||||
|
||||
import forge.card.mana.ManaCost;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.card.mana.ManaCost;
|
||||
|
||||
/**
|
||||
*
|
||||
* The Class CardColorTest.
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000)
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000)
|
||||
public class CardColorTest {
|
||||
|
||||
/**
|
||||
*
|
||||
* Card color test1.
|
||||
*/
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = 1000)
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = 1000)
|
||||
public void CardColorTest1() {
|
||||
ManaCost mc = new ManaCost("R W U");
|
||||
EnumSet<Color> col = Color.convertManaCostToColor(mc);
|
||||
final ManaCost mc = new ManaCost("R W U");
|
||||
final EnumSet<Color> col = Color.convertManaCostToColor(mc);
|
||||
System.out.println(col.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
package forge;
|
||||
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
import net.slightlymagic.braids.util.ClumsyRunnable;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.slightlymagic.braids.util.testng.BraidsAssertFunctions.assertThrowsException;
|
||||
import net.slightlymagic.braids.util.ClumsyRunnable;
|
||||
import net.slightlymagic.braids.util.testng.BraidsAssertFunctions;
|
||||
|
||||
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"})
|
||||
public class CardReaderTest implements NewConstants {
|
||||
@Test(groups = { "UnitTest" })
|
||||
public class CardReaderTest {
|
||||
|
||||
/** The default test-timeout. */
|
||||
public static final int TEST_TIMEOUT = 1000;
|
||||
@@ -25,64 +26,85 @@ public class CardReaderTest implements NewConstants {
|
||||
/** The estimated number of cards in the cardsfolder. */
|
||||
public static final int ESTIMATED_CARDS_IN_FOLDER = 9001;
|
||||
|
||||
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = TEST_TIMEOUT)
|
||||
/**
|
||||
* 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(CARDSFOLDER), null);
|
||||
new CardReader(ForgeProps.getFile(NewConstants.CARDSFOLDER), null);
|
||||
}
|
||||
};
|
||||
|
||||
assertThrowsException(NullPointerException.class, withScissors);
|
||||
BraidsAssertFunctions.assertThrowsException(NullPointerException.class, withScissors);
|
||||
}
|
||||
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = TEST_TIMEOUT)
|
||||
/**
|
||||
* 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 {
|
||||
Map<String, Card> map = new HashMap<String, Card>();
|
||||
final Map<String, Card> map = new HashMap<String, Card>();
|
||||
new CardReader(null, map);
|
||||
}
|
||||
};
|
||||
|
||||
assertThrowsException(NullPointerException.class, withScissors);
|
||||
BraidsAssertFunctions.assertThrowsException(NullPointerException.class, withScissors);
|
||||
}
|
||||
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = TEST_TIMEOUT)
|
||||
/**
|
||||
* 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 {
|
||||
Map<String, Card> map = new HashMap<String, Card>();
|
||||
new CardReader(new File(
|
||||
"this_does_not_exist_fjksdjfsdjfkdjslkfksdlajfikajfklsdhfksdalfhjklsdahfeakslfdsfdsfdsfdsfdssfc"
|
||||
), map);
|
||||
final Map<String, Card> map = new HashMap<String, Card>();
|
||||
new CardReader(
|
||||
new File(
|
||||
"this_does_not_exist_fjksdjfsdjfkdjslkfksdlajfikajfklsdhfksdalfhjklsdahfeakslfdsfdsfdsfdsfdssfc"),
|
||||
map);
|
||||
}
|
||||
};
|
||||
|
||||
assertThrowsException(RuntimeException.class, withScissors);
|
||||
BraidsAssertFunctions.assertThrowsException(RuntimeException.class, withScissors);
|
||||
}
|
||||
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = TEST_TIMEOUT)
|
||||
/**
|
||||
* 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
|
||||
tmpFile.deleteOnExit(); // request VM to delete later
|
||||
|
||||
final ClumsyRunnable withScissors = new ClumsyRunnable() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
Map<String, Card> map = new HashMap<String, Card>();
|
||||
final Map<String, Card> map = new HashMap<String, Card>();
|
||||
new CardReader(tmpFile, map);
|
||||
}
|
||||
};
|
||||
|
||||
assertThrowsException(RuntimeException.class, withScissors);
|
||||
BraidsAssertFunctions.assertThrowsException(RuntimeException.class, withScissors);
|
||||
}
|
||||
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = TEST_TIMEOUT)
|
||||
/**
|
||||
* Test_ read card_find card_zip.
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = CardReaderTest.TEST_TIMEOUT)
|
||||
public final void test_ReadCard_findCard_zip() {
|
||||
final Map<String, Card> map = new HashMap<String, Card>();
|
||||
final File cardsfolder = ForgeProps.getFile(CARDSFOLDER);
|
||||
final File cardsfolder = ForgeProps.getFile(NewConstants.CARDSFOLDER);
|
||||
final CardReader cardReader = new CardReader(cardsfolder, map);
|
||||
|
||||
final File zipFile = new File(cardsfolder, "cardsfolder.zip");
|
||||
@@ -95,10 +117,13 @@ public class CardReaderTest implements NewConstants {
|
||||
Assert.assertEquals(elvishWarrior.getName(), "Elvish Warrior", "name is correct");
|
||||
}
|
||||
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = TEST_TIMEOUT)
|
||||
/**
|
||||
* Test_ read card_find card_nonzip.
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = CardReaderTest.TEST_TIMEOUT)
|
||||
public final void test_ReadCard_findCard_nonzip() {
|
||||
final Map<String, Card> map = new HashMap<String, Card>();
|
||||
final File cardsfolder = ForgeProps.getFile(CARDSFOLDER);
|
||||
final File cardsfolder = ForgeProps.getFile(NewConstants.CARDSFOLDER);
|
||||
final CardReader cardReader = new CardReader(cardsfolder, map, null, false);
|
||||
|
||||
final Card savannahLions = cardReader.findCard("Savannah Lions");
|
||||
@@ -107,20 +132,26 @@ public class CardReaderTest implements NewConstants {
|
||||
Assert.assertEquals(savannahLions.getName(), "Savannah Lions", "name is correct");
|
||||
}
|
||||
|
||||
@Test(groups = {"slow"})
|
||||
/**
|
||||
* Test_ read card_run_nonzip.
|
||||
*/
|
||||
@Test(groups = { "slow" })
|
||||
public final void test_ReadCard_run_nonzip() {
|
||||
final Map<String, Card> map = new HashMap<String, Card>(2 * ESTIMATED_CARDS_IN_FOLDER);
|
||||
final File cardsfolder = ForgeProps.getFile(CARDSFOLDER);
|
||||
final CardReader cardReader = new CardReader(cardsfolder, map, null,false);
|
||||
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(groups = {"slow"})
|
||||
/**
|
||||
* Test_ read card_run_zip.
|
||||
*/
|
||||
@Test(groups = { "slow" })
|
||||
public final void test_ReadCard_run_zip() {
|
||||
final Map<String, Card> map = new HashMap<String, Card>(2 * ESTIMATED_CARDS_IN_FOLDER);
|
||||
final File cardsfolder = ForgeProps.getFile(CARDSFOLDER);
|
||||
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");
|
||||
|
||||
@@ -1,36 +1,42 @@
|
||||
package forge;
|
||||
|
||||
import forge.deck.generate.GenerateConstructedDeck;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.deck.generate.GenerateConstructedDeck;
|
||||
|
||||
/**
|
||||
*
|
||||
* The Class GameActionTest.
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000)
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000)
|
||||
public class GameActionTest {
|
||||
|
||||
/**
|
||||
* <p>main.</p>
|
||||
* <p>
|
||||
* main.
|
||||
* </p>
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = 5000)
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = 5000)
|
||||
public void GameActionTest1() throws Exception {
|
||||
System.out.println("GameActionTest");
|
||||
GameAction gameAction = new GameAction();
|
||||
GenerateConstructedDeck gen = new GenerateConstructedDeck();
|
||||
final GameAction gameAction = new GameAction();
|
||||
final GenerateConstructedDeck gen = new GenerateConstructedDeck();
|
||||
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
CardList list = gen.generateDeck();
|
||||
final CardList list = gen.generateDeck();
|
||||
|
||||
Card[] card = gameAction.smoothComputerManaCurve(list.toArray());
|
||||
final Card[] card = gameAction.smoothComputerManaCurve(list.toArray());
|
||||
|
||||
CardList check = new CardList();
|
||||
for (int a = 0; a < 30; a++)
|
||||
final CardList check = new CardList();
|
||||
for (int a = 0; a < 30; a++) {
|
||||
check.add(card[a]);
|
||||
}
|
||||
|
||||
if (check.getType("Land").size() != 7) {
|
||||
System.out.println("error - " + check);
|
||||
break;
|
||||
}
|
||||
}//for
|
||||
}// for
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
package forge;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.deck.Deck;
|
||||
import forge.game.GameType;
|
||||
import forge.game.limited.BoosterDraft;
|
||||
import forge.game.limited.CardPoolLimitation;
|
||||
import forge.gui.deckeditor.DeckEditorDraft;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: dhudson
|
||||
* Created by IntelliJ IDEA. User: dhudson
|
||||
*/
|
||||
@Test(groups = {"UnitTest"})
|
||||
@Test(groups = { "UnitTest" })
|
||||
public class GuiBoosterDraftTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Gui booster draft test1.
|
||||
*/
|
||||
@Test(groups = {"UnitTest", "fast"})
|
||||
public void GuiBoosterDraftTest1() {
|
||||
@Test(groups = { "UnitTest", "fast" })
|
||||
public void guiBoosterDraftTest1() {
|
||||
Constant.Runtime.setGameType(GameType.Draft);
|
||||
Constant.Runtime.HUMAN_DECK[0] = new Deck(GameType.Sealed);
|
||||
|
||||
DeckEditorDraft g = new DeckEditorDraft();
|
||||
final DeckEditorDraft g = new DeckEditorDraft();
|
||||
g.showGui(new BoosterDraft(CardPoolLimitation.Full));
|
||||
Assert.assertNotNull(g);
|
||||
g.dispose();
|
||||
|
||||
@@ -3,18 +3,16 @@ package forge;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: dhudson
|
||||
* Created by IntelliJ IDEA. User: dhudson
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000, enabled = false)
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000, enabled = false)
|
||||
public class GuiDownloadPicturesLQTest {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Gui download pictures test1.
|
||||
*/
|
||||
@Test(enabled = false, timeOut = 1000)
|
||||
public void GuiDownloadPicturesTest1() {
|
||||
public void GuiDownloadPicturesTest1() {
|
||||
new GuiDownloadPicturesLQ(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ package forge;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: dhudson
|
||||
* Created by IntelliJ IDEA. User: dhudson
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000, enabled = false)
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000, enabled = false)
|
||||
public class GuiDownloadSetPicturesLQTest {
|
||||
|
||||
/**
|
||||
*
|
||||
* Gui download set pictures lq test1.
|
||||
*/
|
||||
@Test(enabled = false, timeOut = 1000)
|
||||
public void GuiDownloadSetPicturesLQTest1() {
|
||||
|
||||
@@ -3,18 +3,16 @@ package forge;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: dhudson
|
||||
* Created by IntelliJ IDEA. User: dhudson
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000, enabled = false)
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000, enabled = false)
|
||||
public class GuiMigrateLocalMWSSetPicturesHQTest {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Gui migrate local mws set pictures h q1.
|
||||
*/
|
||||
@Test(enabled = false, timeOut = 1000)
|
||||
public void GuiMigrateLocalMWSSetPicturesHQ1() {
|
||||
public void GuiMigrateLocalMWSSetPicturesHQ1() {
|
||||
GuiMigrateLocalMWSSetPicturesHQ.startDownload(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,19 +3,17 @@ package forge;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: dhudson
|
||||
* Created by IntelliJ IDEA. User: dhudson
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000, enabled = false)
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000, enabled = false)
|
||||
public class GuiMultipleBlockers4Test {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Gui multiple blockers4 test1.
|
||||
*/
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
public void GuiMultipleBlockers4Test1() {
|
||||
CardList list = new CardList();
|
||||
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));
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
package forge;
|
||||
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: dhudson
|
||||
* Created by IntelliJ IDEA. User: dhudson
|
||||
*/
|
||||
@Test(groups = {"UnitTest"})
|
||||
@Test(groups = { "UnitTest" })
|
||||
public class GuiProgressBarWindowTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Gui progress bar window test1.
|
||||
*/
|
||||
@Test(groups = {"UnitTest", "fast"})
|
||||
@Test(groups = { "UnitTest", "fast" })
|
||||
public void GuiProgressBarWindowTest1() {
|
||||
try {
|
||||
GuiProgressBarWindow dialog = new GuiProgressBarWindow();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
final GuiProgressBarWindow dialog = new GuiProgressBarWindow();
|
||||
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
Assert.assertNotNull(dialog);
|
||||
dialog.dispose();
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,18 +6,17 @@ import org.testng.annotations.Test;
|
||||
import forge.quest.gui.QuestOptions;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: dhudson
|
||||
* Created by IntelliJ IDEA. User: dhudson
|
||||
*/
|
||||
@Test(groups = {"UnitTest"})
|
||||
@Test(groups = { "UnitTest" })
|
||||
public class GuiQuestOptionsTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Gui quest options test1.
|
||||
*/
|
||||
@Test(groups = {"UnitTest", "fast"})
|
||||
@Test(groups = { "UnitTest", "fast" })
|
||||
public void GuiQuestOptionsTest1() {
|
||||
QuestOptions dialog = new QuestOptions();
|
||||
final QuestOptions dialog = new QuestOptions();
|
||||
dialog.setVisible(true);
|
||||
Assert.assertNotNull(dialog);
|
||||
dialog.dispose();
|
||||
|
||||
@@ -1,63 +1,73 @@
|
||||
package forge;
|
||||
|
||||
import forge.error.ErrorViewer;
|
||||
import java.awt.Color;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.*;
|
||||
|
||||
import forge.error.ErrorViewer;
|
||||
|
||||
/**
|
||||
* <p>PanelTest class.</p>
|
||||
*
|
||||
* <p>
|
||||
* PanelTest class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000, enabled = false)
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000, enabled = false)
|
||||
public class PanelTest extends JFrame {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JPanel jPanel1 = new JPanel();
|
||||
private JLabel jLabel1 = new JLabel();
|
||||
private final JPanel jPanel1 = new JPanel();
|
||||
private final JLabel jLabel1 = new JLabel();
|
||||
|
||||
/**
|
||||
*
|
||||
* Phase test1.
|
||||
*/
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
public void PhaseTest1() {
|
||||
PanelTest p = new PanelTest();
|
||||
final PanelTest p = new PanelTest();
|
||||
p.setSize(300, 300);
|
||||
p.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Constructor for PanelTest.</p>
|
||||
* <p>
|
||||
* Constructor for PanelTest.
|
||||
* </p>
|
||||
*/
|
||||
public PanelTest() {
|
||||
try {
|
||||
jbInit();
|
||||
} catch (Exception ex) {
|
||||
this.jbInit();
|
||||
} catch (final Exception ex) {
|
||||
ErrorViewer.showError(ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>jbInit.</p>
|
||||
*
|
||||
* @throws java.lang.Exception if any.
|
||||
* <p>
|
||||
* jbInit.
|
||||
* </p>
|
||||
*
|
||||
* @throws java.lang.Exception
|
||||
* if any.
|
||||
*/
|
||||
private void jbInit() throws Exception {
|
||||
this.getContentPane().setLayout(null);
|
||||
jPanel1.setForeground(Color.orange);
|
||||
jPanel1.setBounds(new Rectangle(15, 36, 252, 156));
|
||||
jLabel1.setFont(new java.awt.Font("Dialog", 1, 12));
|
||||
jLabel1.setForeground(new Color(70, 90, 163));
|
||||
jLabel1.setText("jLabel1");
|
||||
this.getContentPane().add(jPanel1, null);
|
||||
jPanel1.add(jLabel1, null);
|
||||
this.jPanel1.setForeground(Color.orange);
|
||||
this.jPanel1.setBounds(new Rectangle(15, 36, 252, 156));
|
||||
this.jLabel1.setFont(new java.awt.Font("Dialog", 1, 12));
|
||||
this.jLabel1.setForeground(new Color(70, 90, 163));
|
||||
this.jLabel1.setText("jLabel1");
|
||||
this.getContentPane().add(this.jPanel1, null);
|
||||
this.jPanel1.add(this.jLabel1, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,17 @@ package forge;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: dhudson
|
||||
* Created by IntelliJ IDEA. User: dhudson
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 5000, enabled = false)
|
||||
@Test(groups = { "UnitTest" }, timeOut = 5000, enabled = false)
|
||||
public class PhaseTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Phase test1.
|
||||
*/
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = 5000, enabled = false)
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = 5000, enabled = false)
|
||||
public void PhaseTest1() {
|
||||
Phase phase = new Phase();
|
||||
final Phase phase = new Phase();
|
||||
for (int i = 0; i < phase.getPhaseOrder().length; i++) {
|
||||
System.out.println(phase.getPlayerTurn() + " " + phase.getPhase());
|
||||
phase.nextPhase();
|
||||
|
||||
@@ -1,251 +1,263 @@
|
||||
package forge;
|
||||
|
||||
import forge.card.cardfactory.CardFactoryInterface;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.gui.input.InputPayManaCostUtil;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.card.cardfactory.CardFactoryInterface;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.gui.input.InputPayManaCostUtil;
|
||||
|
||||
/**
|
||||
* <p>RunTest class.</p>
|
||||
*
|
||||
* <p>
|
||||
* RunTest class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000, enabled = false)
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000, enabled = false)
|
||||
public class RunTest {
|
||||
//@SuppressWarnings("unchecked") // HashSet needs <type>
|
||||
// @SuppressWarnings("unchecked") // HashSet needs <type>
|
||||
|
||||
/**
|
||||
* <p>test.</p>
|
||||
* <p>
|
||||
* test.
|
||||
* </p>
|
||||
*/
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
void test() {
|
||||
{
|
||||
Card c;
|
||||
CardFactoryInterface cf = AllZone.getCardFactory();
|
||||
//********* test Card
|
||||
final CardFactoryInterface cf = AllZone.getCardFactory();
|
||||
// ********* test Card
|
||||
c = cf.getCard("Elvish Warrior", AllZone.getComputerPlayer());
|
||||
check("1", c.getOwner().isComputer());
|
||||
check("1.1", c.getName().equals("Elvish Warrior"));
|
||||
check("2", c.getManaCost().equals("G G"));
|
||||
check("2.1", c.isCreature());
|
||||
check("2.2", c.isType("Elf"));
|
||||
check("2.3", c.isType("Warrior"));
|
||||
check("3", c.getText().equals(""));
|
||||
check("4", c.getNetAttack() == 2);
|
||||
check("5", c.getNetDefense() == 3);
|
||||
check("6", c.getKeyword().isEmpty());
|
||||
this.check("1", c.getOwner().isComputer());
|
||||
this.check("1.1", c.getName().equals("Elvish Warrior"));
|
||||
this.check("2", c.getManaCost().equals("G G"));
|
||||
this.check("2.1", c.isCreature());
|
||||
this.check("2.2", c.isType("Elf"));
|
||||
this.check("2.3", c.isType("Warrior"));
|
||||
this.check("3", c.getText().equals(""));
|
||||
this.check("4", c.getNetAttack() == 2);
|
||||
this.check("5", c.getNetDefense() == 3);
|
||||
this.check("6", c.getKeyword().isEmpty());
|
||||
|
||||
c = cf.getCard("Shock", null);
|
||||
check("14", c.isInstant());
|
||||
//check("15", c.getText().equals("Shock deals 2 damge to target creature or player."));
|
||||
this.check("14", c.isInstant());
|
||||
// check("15",
|
||||
// c.getText().equals("Shock deals 2 damge to target creature or player."));
|
||||
|
||||
c = cf.getCard("Bayou", null);
|
||||
check("17", c.getManaCost().equals(""));
|
||||
check("18", c.isLand());
|
||||
check("19", c.isType("Swamp"));
|
||||
check("20", c.isType("Forest"));
|
||||
this.check("17", c.getManaCost().equals(""));
|
||||
this.check("18", c.isLand());
|
||||
this.check("19", c.isType("Swamp"));
|
||||
this.check("20", c.isType("Forest"));
|
||||
|
||||
//********* test ManaCost
|
||||
// ********* test ManaCost
|
||||
ManaCost manaCost = new ManaCost("G");
|
||||
check("21", !manaCost.isPaid());
|
||||
this.check("21", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.GREEN);
|
||||
check("22", manaCost.isPaid());
|
||||
this.check("22", manaCost.isPaid());
|
||||
|
||||
manaCost = new ManaCost("7");
|
||||
check("23", !manaCost.isPaid());
|
||||
this.check("23", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.BLACK);
|
||||
check("24", !manaCost.isPaid());
|
||||
this.check("24", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.BLUE);
|
||||
check("25", !manaCost.isPaid());
|
||||
this.check("25", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.COLORLESS);
|
||||
check("26", !manaCost.isPaid());
|
||||
this.check("26", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.GREEN);
|
||||
check("27", !manaCost.isPaid());
|
||||
this.check("27", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.RED);
|
||||
check("28", !manaCost.isPaid());
|
||||
this.check("28", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.WHITE);
|
||||
check("29", !manaCost.isPaid());
|
||||
this.check("29", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.WHITE);
|
||||
check("30", manaCost.isPaid());
|
||||
this.check("30", manaCost.isPaid());
|
||||
|
||||
manaCost = new ManaCost("2 W W G G B B U U R R");
|
||||
check("31", !manaCost.isPaid());
|
||||
this.check("31", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.WHITE);
|
||||
check("32", !manaCost.isPaid());
|
||||
this.check("32", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.WHITE);
|
||||
check("32.1", !manaCost.isPaid());
|
||||
this.check("32.1", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.BLACK);
|
||||
check("33", !manaCost.isPaid());
|
||||
this.check("33", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.BLACK);
|
||||
check("34", !manaCost.isPaid());
|
||||
this.check("34", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.BLUE);
|
||||
check("35", !manaCost.isPaid());
|
||||
this.check("35", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.BLUE);
|
||||
check("36", !manaCost.isPaid());
|
||||
this.check("36", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.GREEN);
|
||||
check("37", !manaCost.isPaid());
|
||||
this.check("37", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.GREEN);
|
||||
check("38", !manaCost.isPaid());
|
||||
this.check("38", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.RED);
|
||||
check("39", !manaCost.isPaid());
|
||||
this.check("39", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.RED);
|
||||
check("40", !manaCost.isPaid());
|
||||
this.check("40", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.RED);
|
||||
check("41", !manaCost.isPaid());
|
||||
this.check("41", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.BLUE);
|
||||
check("42", manaCost.isPaid());
|
||||
this.check("42", manaCost.isPaid());
|
||||
|
||||
manaCost = new ManaCost("G G");
|
||||
check("43", !manaCost.isPaid());
|
||||
this.check("43", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.GREEN);
|
||||
check("44", !manaCost.isPaid());
|
||||
this.check("44", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.GREEN);
|
||||
check("45", manaCost.isPaid());
|
||||
this.check("45", manaCost.isPaid());
|
||||
|
||||
manaCost = new ManaCost("1 U B");
|
||||
check("45", !manaCost.isPaid());
|
||||
this.check("45", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.BLACK);
|
||||
check("46", !manaCost.isPaid());
|
||||
this.check("46", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.BLUE);
|
||||
check("47", !manaCost.isPaid());
|
||||
this.check("47", !manaCost.isPaid());
|
||||
manaCost.payMana(Constant.Color.BLUE);
|
||||
check("48", manaCost.isPaid());
|
||||
this.check("48", manaCost.isPaid());
|
||||
|
||||
//********* test CardUtil.getColors()
|
||||
// ********* test CardUtil.getColors()
|
||||
c = new Card();
|
||||
c.setManaCost("G");
|
||||
ArrayList<String> color = CardUtil.getColors(c);
|
||||
check("49", color.contains(Constant.Color.GREEN));
|
||||
check("50", color.size() == 1);
|
||||
this.check("49", color.contains(Constant.Color.GREEN));
|
||||
this.check("50", color.size() == 1);
|
||||
|
||||
c = new Card();
|
||||
c.setManaCost("W B G R U");
|
||||
color = CardUtil.getColors(c);
|
||||
Set<String> set = new HashSet<String>(color);
|
||||
final Set<String> set = new HashSet<String>(color);
|
||||
System.out.println("color: " + color);
|
||||
check("51", set.size() == 5);
|
||||
check("52", color.contains(Constant.Color.BLACK));
|
||||
check("53", color.contains(Constant.Color.BLUE));
|
||||
check("54", color.contains(Constant.Color.GREEN));
|
||||
check("55", color.contains(Constant.Color.RED));
|
||||
check("56", color.contains(Constant.Color.WHITE));
|
||||
this.check("51", set.size() == 5);
|
||||
this.check("52", color.contains(Constant.Color.BLACK));
|
||||
this.check("53", color.contains(Constant.Color.BLUE));
|
||||
this.check("54", color.contains(Constant.Color.GREEN));
|
||||
this.check("55", color.contains(Constant.Color.RED));
|
||||
this.check("56", color.contains(Constant.Color.WHITE));
|
||||
|
||||
c = new Card();
|
||||
c.setManaCost("2");
|
||||
color = CardUtil.getColors(c);
|
||||
check("57", color.size() == 1);
|
||||
check("58", color.contains(Constant.Color.COLORLESS));
|
||||
this.check("57", color.size() == 1);
|
||||
this.check("58", color.contains(Constant.Color.COLORLESS));
|
||||
|
||||
c = new Card();
|
||||
color = CardUtil.getColors(c);
|
||||
check("59", color.size() == 1);
|
||||
check("60", color.contains(Constant.Color.COLORLESS));
|
||||
this.check("59", color.size() == 1);
|
||||
this.check("60", color.contains(Constant.Color.COLORLESS));
|
||||
|
||||
c = new Card();
|
||||
c.setManaCost("");
|
||||
color = CardUtil.getColors(c);
|
||||
check("61", color.size() == 1);
|
||||
check("62", color.contains(Constant.Color.COLORLESS));
|
||||
this.check("61", color.size() == 1);
|
||||
this.check("62", color.contains(Constant.Color.COLORLESS));
|
||||
|
||||
c = cf.getCard("Bayou", null);
|
||||
color = CardUtil.getColors(c);
|
||||
check("63", color.size() == 1);
|
||||
check("64", color.contains(Constant.Color.COLORLESS));
|
||||
this.check("63", color.size() == 1);
|
||||
this.check("64", color.contains(Constant.Color.COLORLESS));
|
||||
|
||||
c = cf.getCard("Elvish Warrior", null);
|
||||
color = CardUtil.getColors(c);
|
||||
check("65", color.size() == 1);
|
||||
check("66", color.contains(Constant.Color.GREEN));
|
||||
this.check("65", color.size() == 1);
|
||||
this.check("66", color.contains(Constant.Color.GREEN));
|
||||
|
||||
c = new Card();
|
||||
c.setManaCost("11 W W B B U U R R G G");
|
||||
color = CardUtil.getColors(c);
|
||||
check("67", color.size() == 5);
|
||||
this.check("67", color.size() == 5);
|
||||
|
||||
c = new Card();
|
||||
c = cf.getCard("Elvish Warrior", null);
|
||||
c.setManaCost("11");
|
||||
color = CardUtil.getColors(c);
|
||||
check("68", color.size() == 1);
|
||||
check("69", color.contains(Constant.Color.COLORLESS));
|
||||
this.check("68", color.size() == 1);
|
||||
this.check("69", color.contains(Constant.Color.COLORLESS));
|
||||
|
||||
check("70", c.isCreature());
|
||||
check("71", !c.isArtifact());
|
||||
check("72", !c.isBasicLand());
|
||||
check("73", !c.isEnchantment());
|
||||
check("74", !c.isGlobalEnchantment());
|
||||
check("75", !c.isInstant());
|
||||
check("76", !c.isLand());
|
||||
check("77", !c.isAura());
|
||||
check("78", c.isPermanent());
|
||||
check("79", !c.isSorcery());
|
||||
check("80", !c.isTapped());
|
||||
check("81", c.isUntapped());
|
||||
this.check("70", c.isCreature());
|
||||
this.check("71", !c.isArtifact());
|
||||
this.check("72", !c.isBasicLand());
|
||||
this.check("73", !c.isEnchantment());
|
||||
this.check("74", !c.isGlobalEnchantment());
|
||||
this.check("75", !c.isInstant());
|
||||
this.check("76", !c.isLand());
|
||||
this.check("77", !c.isAura());
|
||||
this.check("78", c.isPermanent());
|
||||
this.check("79", !c.isSorcery());
|
||||
this.check("80", !c.isTapped());
|
||||
this.check("81", c.isUntapped());
|
||||
|
||||
c = cf.getCard("Swamp", null);
|
||||
check("82", c.isBasicLand());
|
||||
check("83", c.isLand());
|
||||
this.check("82", c.isBasicLand());
|
||||
this.check("83", c.isLand());
|
||||
|
||||
c = cf.getCard("Bayou", null);
|
||||
check("84", !c.isBasicLand());
|
||||
check("85", c.isLand());
|
||||
this.check("84", !c.isBasicLand());
|
||||
this.check("85", c.isLand());
|
||||
|
||||
c = cf.getCard("Shock", null);
|
||||
check("86", !c.isCreature());
|
||||
check("87", !c.isArtifact());
|
||||
check("88", !c.isBasicLand());
|
||||
check("89", !c.isEnchantment());
|
||||
check("90", !c.isGlobalEnchantment());
|
||||
check("91", c.isInstant());
|
||||
check("92", !c.isLand());
|
||||
check("93", !c.isAura());
|
||||
check("94", !c.isPermanent());
|
||||
check("95", !c.isSorcery());
|
||||
check("96", !c.isTapped());
|
||||
check("97", c.isUntapped());
|
||||
this.check("86", !c.isCreature());
|
||||
this.check("87", !c.isArtifact());
|
||||
this.check("88", !c.isBasicLand());
|
||||
this.check("89", !c.isEnchantment());
|
||||
this.check("90", !c.isGlobalEnchantment());
|
||||
this.check("91", c.isInstant());
|
||||
this.check("92", !c.isLand());
|
||||
this.check("93", !c.isAura());
|
||||
this.check("94", !c.isPermanent());
|
||||
this.check("95", !c.isSorcery());
|
||||
this.check("96", !c.isTapped());
|
||||
this.check("97", c.isUntapped());
|
||||
|
||||
//test Input_PayManaCostUtil
|
||||
check("98", InputPayManaCostUtil.getLongColorString("G").equals(Constant.Color.GREEN));
|
||||
check("99", InputPayManaCostUtil.getLongColorString("1").equals(Constant.Color.COLORLESS));
|
||||
// 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", Input_PayManaCostUtil.isManaNeeded(Constant.Color.Blue, new ManaCost("4")) == true);
|
||||
check("103", Input_PayManaCostUtil.isManaNeeded(Constant.Color.White, new ManaCost("3")) == true);
|
||||
check("104", Input_PayManaCostUtil.isManaNeeded(Constant.Color.Black, new ManaCost("2")) == true);
|
||||
check("105", Input_PayManaCostUtil.isManaNeeded(Constant.Color.Red, new ManaCost("1")) == true);
|
||||
*/
|
||||
* check("101",
|
||||
* Input_PayManaCostUtil.isManaNeeded(Constant.Color.Green, new
|
||||
* ManaCost("5")) == true); check("102",
|
||||
* Input_PayManaCostUtil.isManaNeeded(Constant.Color.Blue, new
|
||||
* ManaCost("4")) == true); check("103",
|
||||
* Input_PayManaCostUtil.isManaNeeded(Constant.Color.White, new
|
||||
* ManaCost("3")) == true); check("104",
|
||||
* Input_PayManaCostUtil.isManaNeeded(Constant.Color.Black, new
|
||||
* ManaCost("2")) == true); check("105",
|
||||
* Input_PayManaCostUtil.isManaNeeded(Constant.Color.Red, new
|
||||
* ManaCost("1")) == true);
|
||||
*/
|
||||
/*
|
||||
ManaCost cost = new ManaCost("1 B B");
|
||||
Input_PayManaCostUtil.isManaNeeded(Constant.Color.Black, cost);
|
||||
cost.subtractMana(Constant.Color.Black);
|
||||
cost.subtractMana(Constant.Color.Green);
|
||||
check("106", Input_PayManaCostUtil.isManaNeeded(Constant.Color.Green, cost) == false);
|
||||
*/
|
||||
* ManaCost cost = new ManaCost("1 B B");
|
||||
* Input_PayManaCostUtil.isManaNeeded(Constant.Color.Black, cost);
|
||||
* cost.subtractMana(Constant.Color.Black);
|
||||
* cost.subtractMana(Constant.Color.Green); check("106",
|
||||
* Input_PayManaCostUtil.isManaNeeded(Constant.Color.Green, cost) ==
|
||||
* false);
|
||||
*/
|
||||
|
||||
c = new Card();
|
||||
Card c2 = new Card();
|
||||
c.addIntrinsicKeyword("Flying");
|
||||
c2.addIntrinsicKeyword("Flying");
|
||||
//check("107", CombatUtil.canBlock(c, c2));
|
||||
//check("108", CombatUtil.canBlock(c2, c));
|
||||
// check("107", CombatUtil.canBlock(c, c2));
|
||||
// check("108", CombatUtil.canBlock(c2, c));
|
||||
|
||||
c = new Card();
|
||||
c2 = new Card();
|
||||
c2.addIntrinsicKeyword("Flying");
|
||||
check("109", CombatUtil.canBlock(c, c2));
|
||||
check("110", !CombatUtil.canBlock(c2, c));
|
||||
|
||||
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);
|
||||
check("110a", !CombatUtil.canBlock(c2, c));
|
||||
check("110b", CombatUtil.canBlock(c, c2));
|
||||
this.check("110a", !CombatUtil.canBlock(c2, c));
|
||||
this.check("110b", CombatUtil.canBlock(c, c2));
|
||||
|
||||
c = new Card();
|
||||
c.setName("1");
|
||||
@@ -254,79 +266,84 @@ public class RunTest {
|
||||
c2.setName("2");
|
||||
c2.setUniqueNumber(2);
|
||||
|
||||
//test CardList
|
||||
CardList cardList = new CardList(new Card[]
|
||||
{c, c2});
|
||||
check("111", cardList.contains(c));
|
||||
check("112", cardList.contains(c2));
|
||||
check("113", cardList.containsName(c));
|
||||
check("114", cardList.containsName(c.getName()));
|
||||
check("115", cardList.containsName(c2));
|
||||
check("116", cardList.containsName(c2.getName()));
|
||||
// test CardList
|
||||
final CardList cardList = new CardList(new Card[] { c, c2 });
|
||||
this.check("111", cardList.contains(c));
|
||||
this.check("112", cardList.contains(c2));
|
||||
this.check("113", cardList.containsName(c));
|
||||
this.check("114", cardList.containsName(c.getName()));
|
||||
this.check("115", cardList.containsName(c2));
|
||||
this.check("116", cardList.containsName(c2.getName()));
|
||||
|
||||
c = new Card();
|
||||
check("117", c.hasSickness() == true);
|
||||
this.check("117", c.hasSickness() == true);
|
||||
c.addIntrinsicKeyword("Haste");
|
||||
check("118", c.hasSickness() == false);
|
||||
|
||||
this.check("118", c.hasSickness() == false);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
CardFactoryInterface cf = AllZone.getCardFactory();
|
||||
CardList c1 = new CardList();
|
||||
final CardFactoryInterface cf = AllZone.getCardFactory();
|
||||
final CardList c1 = new CardList();
|
||||
c1.add(cf.getCard("Shock", null));
|
||||
c1.add(cf.getCard("Royal Assassin", null));
|
||||
c1.add(cf.getCard("Hymn to Tourach", null));
|
||||
|
||||
CardList c2 = c1.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
@Override
|
||||
public boolean addCard(final Card c) {
|
||||
return c.isCreature();
|
||||
}
|
||||
});
|
||||
check("119", c2.containsName("Royal Assassin"));
|
||||
check("119", c2.size() == 1);
|
||||
this.check("119", c2.containsName("Royal Assassin"));
|
||||
this.check("119", c2.size() == 1);
|
||||
|
||||
c2 = c1.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
@Override
|
||||
public boolean addCard(final Card c) {
|
||||
return c.isInstant();
|
||||
}
|
||||
});
|
||||
check("120", c2.containsName("Shock"));
|
||||
check("121", c2.size() == 1);
|
||||
this.check("120", c2.containsName("Shock"));
|
||||
this.check("121", c2.size() == 1);
|
||||
|
||||
c2 = c1.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
@Override
|
||||
public boolean addCard(final Card c) {
|
||||
return c.getName().equals("Hymn to Tourach");
|
||||
}
|
||||
});
|
||||
check("120", c2.containsName("Hymn to Tourach"));
|
||||
check("121", c2.size() == 1);
|
||||
this.check("120", c2.containsName("Hymn to Tourach"));
|
||||
this.check("121", c2.size() == 1);
|
||||
|
||||
Card card = cf.getCard("Sylvan Basilisk", null);
|
||||
Card card2 = cf.getCard("Exalted Angel", null);
|
||||
final Card card = cf.getCard("Sylvan Basilisk", null);
|
||||
final Card card2 = cf.getCard("Exalted Angel", null);
|
||||
|
||||
check("121a", !CombatUtil.canDestroyAttacker(card, card2, null, false));
|
||||
this.check("121a", !CombatUtil.canDestroyAttacker(card, card2, null, false));
|
||||
}
|
||||
{
|
||||
check("122", CardUtil.getConvertedManaCost("0") == 0);
|
||||
check("123", CardUtil.getConvertedManaCost("R") == 1);
|
||||
check("124", CardUtil.getConvertedManaCost("R R") == 2);
|
||||
check("125", CardUtil.getConvertedManaCost("R R R") == 3);
|
||||
check("126", CardUtil.getConvertedManaCost("1") == 1);
|
||||
check("127", CardUtil.getConvertedManaCost("2/R 2/G 2/W 2/B 2/U") == 10);
|
||||
this.check("122", CardUtil.getConvertedManaCost("0") == 0);
|
||||
this.check("123", CardUtil.getConvertedManaCost("R") == 1);
|
||||
this.check("124", CardUtil.getConvertedManaCost("R R") == 2);
|
||||
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()
|
||||
}// test()
|
||||
|
||||
/**
|
||||
* <p>check.</p>
|
||||
*
|
||||
* @param message a {@link java.lang.String} object.
|
||||
* @param ok a boolean.
|
||||
* <p>
|
||||
* check.
|
||||
* </p>
|
||||
*
|
||||
* @param message
|
||||
* a {@link java.lang.String} object.
|
||||
* @param ok
|
||||
* a boolean.
|
||||
*/
|
||||
void check(String message, boolean ok) {
|
||||
void check(final String message, final boolean ok) {
|
||||
if (!ok) {
|
||||
//throw new RuntimeException("RunTest test error : " +message);
|
||||
// throw new RuntimeException("RunTest test error : " +message);
|
||||
System.out.println("RunTest test error : " + message);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ import org.testng.annotations.Test;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
@Test(groups = {"UnitTest"})
|
||||
@Test(groups = { "UnitTest" })
|
||||
public class TinyTest {
|
||||
/**
|
||||
* Just a quick test to see if TestNG and Assert are working.
|
||||
*/
|
||||
@Test(groups = {"UnitTest", "fast"})
|
||||
@Test(groups = { "UnitTest", "fast" })
|
||||
public void test_true() {
|
||||
Assert.assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
package forge.card.cardFactory;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.slightlymagic.braids.util.ClumsyRunnable;
|
||||
import net.slightlymagic.braids.util.testng.BraidsAssertFunctions;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.card.cardfactory.CardFactoryInterface;
|
||||
@@ -8,28 +18,24 @@ import forge.card.cardfactory.PreloadingCardFactory;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.view.swing.OldGuiNewGame;
|
||||
import net.slightlymagic.braids.util.ClumsyRunnable;
|
||||
import net.slightlymagic.braids.util.testng.BraidsAssertFunctions;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
//import net.slightlymagic.braids.testng.BraidsAssertFunctions;
|
||||
|
||||
/**
|
||||
* <p>Mana_PartTest class.</p>
|
||||
*
|
||||
* <p>
|
||||
* Mana_PartTest class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
@Test(groups = {"UnitTest" }, timeOut = CardFactoryTest.DEFAULT_TEST_TIMEOUT_MS)
|
||||
public class CardFactoryTest implements NewConstants {
|
||||
@Test(groups = { "UnitTest" }, timeOut = CardFactoryTest.DEFAULT_TEST_TIMEOUT_MS)
|
||||
public class CardFactoryTest {
|
||||
|
||||
/** The default time to allow a test to run before TestNG ignores it. */
|
||||
public static final int DEFAULT_TEST_TIMEOUT_MS = 5000; // NOPMD by Braids on 8/18/11 11:43 PM
|
||||
public static final int DEFAULT_TEST_TIMEOUT_MS = 5000; // NOPMD by Braids
|
||||
// on 8/18/11 11:43
|
||||
// PM
|
||||
|
||||
private transient CardFactoryInterface factory;
|
||||
|
||||
@@ -39,16 +45,16 @@ public class CardFactoryTest implements NewConstants {
|
||||
@BeforeMethod
|
||||
public final void setUp() {
|
||||
OldGuiNewGame.loadDynamicGamedata();
|
||||
factory = new LazyCardFactory(ForgeProps.getFile(CARDSFOLDER));
|
||||
this.factory = new LazyCardFactory(ForgeProps.getFile(NewConstants.CARDSFOLDER));
|
||||
}
|
||||
|
||||
/**
|
||||
* Just a quick test to see if Arc-Slogger is in the database, and if it
|
||||
* has the correct owner.
|
||||
* Just a quick test to see if Arc-Slogger is in the database, and if it has
|
||||
* the correct owner.
|
||||
*/
|
||||
@Test(enabled = true, timeOut = DEFAULT_TEST_TIMEOUT_MS)
|
||||
@Test(enabled = true, timeOut = CardFactoryTest.DEFAULT_TEST_TIMEOUT_MS)
|
||||
public final void test_getCard_1() { // NOPMD by Braids on 8/18/11 11:39 PM
|
||||
final Card card = factory.getCard("Arc-Slogger", null);
|
||||
final Card card = this.factory.getCard("Arc-Slogger", null);
|
||||
Assert.assertNotNull(card, "card is not null");
|
||||
Assert.assertNull(card.getOwner(), "card has correct owner");
|
||||
}
|
||||
@@ -56,38 +62,55 @@ public class CardFactoryTest implements NewConstants {
|
||||
/**
|
||||
* Make sure the method throws an exception when it's supposed to.
|
||||
*/
|
||||
@Test(enabled = true, timeOut = DEFAULT_TEST_TIMEOUT_MS)
|
||||
public final void test_getRandomCombinationWithoutRepetition_tooLarge() { // NOPMD by Braids on 8/18/11 11:39 PM
|
||||
BraidsAssertFunctions.assertThrowsException(IllegalArgumentException.class,
|
||||
new ClumsyRunnable() {
|
||||
public void run() throws Exception { // NOPMD by Braids on 8/18/11 11:40 PM
|
||||
factory.getRandomCombinationWithoutRepetition(factory.size());
|
||||
@Test(enabled = true, timeOut = CardFactoryTest.DEFAULT_TEST_TIMEOUT_MS)
|
||||
public final void test_getRandomCombinationWithoutRepetition_tooLarge() { // NOPMD
|
||||
// by
|
||||
// Braids
|
||||
// on
|
||||
// 8/18/11
|
||||
// 11:39
|
||||
// PM
|
||||
BraidsAssertFunctions.assertThrowsException(IllegalArgumentException.class, new ClumsyRunnable() {
|
||||
@Override
|
||||
public void run() throws Exception { // NOPMD by Braids on 8/18/11
|
||||
// 11:40 PM
|
||||
CardFactoryTest.this.factory.getRandomCombinationWithoutRepetition(CardFactoryTest.this.factory.size());
|
||||
}
|
||||
});
|
||||
|
||||
BraidsAssertFunctions.assertThrowsException(IllegalArgumentException.class,
|
||||
new ClumsyRunnable() {
|
||||
public void run() throws Exception { // NOPMD by Braids on 8/18/11 11:40 PM
|
||||
final int largeDivisorForRandomCombo = 4; // NOPMD by Braids on 8/18/11 11:41 PM
|
||||
factory.getRandomCombinationWithoutRepetition(factory.size() / largeDivisorForRandomCombo);
|
||||
BraidsAssertFunctions.assertThrowsException(IllegalArgumentException.class, new ClumsyRunnable() {
|
||||
@Override
|
||||
public void run() throws Exception { // NOPMD by Braids on 8/18/11
|
||||
// 11:40 PM
|
||||
final int largeDivisorForRandomCombo = 4; // NOPMD by Braids on
|
||||
// 8/18/11 11:41 PM
|
||||
CardFactoryTest.this.factory.getRandomCombinationWithoutRepetition(CardFactoryTest.this.factory.size()
|
||||
/ largeDivisorForRandomCombo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure the method works.
|
||||
*
|
||||
* This doesn't work with LazyCardFactory, so it is too slow to enable by default.
|
||||
*
|
||||
* This doesn't work with LazyCardFactory, so it is too slow to enable by
|
||||
* default.
|
||||
*/
|
||||
@Test(enabled = false, timeOut = DEFAULT_TEST_TIMEOUT_MS)
|
||||
public final void test_getRandomCombinationWithoutRepetition_oneTenth() { // NOPMD by Braids on 8/18/11 11:39 PM
|
||||
factory = new PreloadingCardFactory(ForgeProps.getFile(CARDSFOLDER));
|
||||
@Test(enabled = false, timeOut = CardFactoryTest.DEFAULT_TEST_TIMEOUT_MS)
|
||||
public final void test_getRandomCombinationWithoutRepetition_oneTenth() { // NOPMD
|
||||
// by
|
||||
// Braids
|
||||
// on
|
||||
// 8/18/11
|
||||
// 11:39
|
||||
// PM
|
||||
this.factory = new PreloadingCardFactory(ForgeProps.getFile(NewConstants.CARDSFOLDER));
|
||||
final int divisor = 10; // NOPMD by Braids on 8/18/11 11:41 PM
|
||||
final CardList actual = factory.getRandomCombinationWithoutRepetition(factory.size() / divisor);
|
||||
final CardList actual = this.factory.getRandomCombinationWithoutRepetition(this.factory.size() / divisor);
|
||||
|
||||
final Set<String> cardNames = new TreeSet<String>();
|
||||
|
||||
for (Card card : actual) {
|
||||
for (final Card card : actual) {
|
||||
Assert.assertNotNull(card);
|
||||
cardNames.add(card.getName());
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package forge.card.cardFactory;
|
||||
|
||||
import static forge.card.cardfactory.CardFactoryUtil.getMostProminentCreatureType;
|
||||
import static forge.card.cardfactory.CardFactoryUtil.isNegativeCounter;
|
||||
import static forge.card.cardfactory.CardFactoryUtil.multiplyManaCost;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.code.jyield.Generator;
|
||||
@@ -14,19 +10,21 @@ import forge.Card;
|
||||
import forge.CardFilter;
|
||||
import forge.CardList;
|
||||
import forge.Counters;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
|
||||
/**
|
||||
* <p>Mana_PartTest class.</p>
|
||||
*
|
||||
* <p>
|
||||
* Mana_PartTest class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000, enabled = false)
|
||||
public class CardFactoryUtilTest implements NewConstants {
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000, enabled = false)
|
||||
public class CardFactoryUtilTest {
|
||||
|
||||
/**
|
||||
*
|
||||
* Card factory test1.
|
||||
*/
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
public void CardFactoryTest1() {
|
||||
@@ -34,23 +32,23 @@ public class CardFactoryUtilTest implements NewConstants {
|
||||
Generator<Card> in = YieldUtils.toGenerator(AllZone.getCardFactory());
|
||||
|
||||
in = CardFilter.getColor(in, "black");
|
||||
|
||||
|
||||
CardList list = new CardList(in);
|
||||
list = list.getType("Creature");
|
||||
|
||||
System.out.println("Most prominent creature type: " + getMostProminentCreatureType(list));
|
||||
System.out.println("Most prominent creature type: " + CardFactoryUtil.getMostProminentCreatureType(list));
|
||||
|
||||
|
||||
String manacost = "3 GW W W R B S";
|
||||
String multipliedTwice = multiplyManaCost(manacost, 2);
|
||||
String multipliedThrice = multiplyManaCost(manacost, 3);
|
||||
final String manacost = "3 GW W W R B S";
|
||||
final String multipliedTwice = CardFactoryUtil.multiplyManaCost(manacost, 2);
|
||||
final String multipliedThrice = CardFactoryUtil.multiplyManaCost(manacost, 3);
|
||||
|
||||
System.out.println(manacost + " times 2 = " + multipliedTwice);
|
||||
System.out.println(manacost + " times 3 = " + multipliedThrice);
|
||||
|
||||
if (isNegativeCounter(Counters.M1M1)) {
|
||||
if (CardFactoryUtil.isNegativeCounter(Counters.M1M1)) {
|
||||
System.out.println("M1M1 is a bad counter!");
|
||||
} else
|
||||
} else {
|
||||
System.out.println("M1M1 is a good counter!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user