mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Cleaning up unit tests
This commit is contained in:
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -10847,8 +10847,8 @@ src/main/java/tree/properties/types/FileType.java svneol=native#text/plain
|
||||
src/main/java/tree/properties/types/package-info.java svneol=native#text/plain
|
||||
src/main/resources/proxy-template.ftl -text
|
||||
src/site/apt/index.apt -text
|
||||
src/test/java/forge/BoosterDraft1Test.java svneol=native#text/plain
|
||||
src/test/java/forge/BoosterDraftTest.java svneol=native#text/plain
|
||||
src/test/java/forge/BoosterDraft_1Test.java svneol=native#text/plain
|
||||
src/test/java/forge/CardColorTest.java svneol=native#text/plain
|
||||
src/test/java/forge/CardReaderTest.java svneol=native#text/plain
|
||||
src/test/java/forge/GameActionTest.java svneol=native#text/plain
|
||||
@@ -10865,7 +10865,7 @@ src/test/java/forge/RunTest.java svneol=native#text/plain
|
||||
src/test/java/forge/TinyTest.java svneol=native#text/plain
|
||||
src/test/java/forge/card/cardFactory/CardFactoryTest.java svneol=native#text/plain
|
||||
src/test/java/forge/card/cardFactory/CardFactoryUtilTest.java svneol=native#text/plain
|
||||
src/test/java/forge/card/mana/Mana_PartTest.java svneol=native#text/plain
|
||||
src/test/java/forge/card/mana/ManaPartTest.java svneol=native#text/plain
|
||||
src/test/java/forge/deck/generate/Generate2ColorDeckTest.java svneol=native#text/plain
|
||||
src/test/java/forge/deck/generate/Generate3ColorDeckTest.java svneol=native#text/plain
|
||||
src/test/java/forge/deck/generate/Generate5ColorDeckTest.java svneol=native#text/plain
|
||||
|
||||
@@ -11,15 +11,16 @@ import forge.item.ItemPoolView;
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000)
|
||||
public class BoosterDraft_1Test {
|
||||
public class BoosterDraft1Test {
|
||||
|
||||
/**
|
||||
* Booster draft_1 test1.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = 1000)
|
||||
public void BoosterDraft_1Test1() throws Exception {
|
||||
public void boosterDraft1Test1() throws Exception {
|
||||
final BoosterDraft draft = new BoosterDraft(CardPoolLimitation.Full);
|
||||
while (draft.hasNextChoice()) {
|
||||
final ItemPoolView<CardPrinted> list = draft.nextChoice();
|
||||
@@ -21,7 +21,7 @@ import forge.item.ItemPoolView;
|
||||
public class BoosterDraftTest implements IBoosterDraft {
|
||||
|
||||
/** The n. */
|
||||
int n = 3;
|
||||
private int n = 3;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -90,7 +90,9 @@ public class BoosterDraftTest implements IBoosterDraft {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.game.limited.IBoosterDraft#finishedDrafting()
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ public class CardColorTest {
|
||||
* Card color test1.
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = 1000)
|
||||
public void CardColorTest1() {
|
||||
public void cardColorTest1() {
|
||||
final ManaCost mc = new ManaCost("R W U");
|
||||
final EnumSet<Color> col = Color.convertManaCostToColor(mc);
|
||||
System.out.println(col.toString());
|
||||
|
||||
@@ -79,7 +79,8 @@ public class CardReaderTest {
|
||||
/**
|
||||
* Test_ read card_file not folder.
|
||||
*
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
* @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 {
|
||||
|
||||
@@ -15,10 +15,11 @@ public class GameActionTest {
|
||||
* main.
|
||||
* </p>
|
||||
*
|
||||
* @throws Exception the exception
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = 5000)
|
||||
public void GameActionTest1() throws Exception {
|
||||
public void gameActionTest1() throws Exception {
|
||||
System.out.println("GameActionTest");
|
||||
final GameAction gameAction = new GameAction();
|
||||
final GenerateConstructedDeck gen = new GenerateConstructedDeck();
|
||||
@@ -37,6 +38,6 @@ public class GameActionTest {
|
||||
System.out.println("error - " + check);
|
||||
break;
|
||||
}
|
||||
}// for
|
||||
} // for
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class GuiDownloadPicturesLQTest {
|
||||
* Gui download pictures test1.
|
||||
*/
|
||||
@Test(enabled = false, timeOut = 1000)
|
||||
public void GuiDownloadPicturesTest1() {
|
||||
public void guiDownloadPicturesTest1() {
|
||||
new GuiDownloadPicturesLQ(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class GuiDownloadSetPicturesLQTest {
|
||||
* Gui download set pictures lq test1.
|
||||
*/
|
||||
@Test(enabled = false, timeOut = 1000)
|
||||
public void GuiDownloadSetPicturesLQTest1() {
|
||||
public void g() {
|
||||
new GuiDownloadSetPicturesLQ(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class GuiMultipleBlockers4Test {
|
||||
* Gui multiple blockers4 test1.
|
||||
*/
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
public void GuiMultipleBlockers4Test1() {
|
||||
public void guiMultipleBlockers4Test1() {
|
||||
final CardList list = new CardList();
|
||||
list.add(AllZone.getCardFactory().getCard("Elvish Piper", null));
|
||||
list.add(AllZone.getCardFactory().getCard("Lantern Kami", null));
|
||||
|
||||
@@ -15,7 +15,7 @@ public class GuiProgressBarWindowTest {
|
||||
* Gui progress bar window test1.
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" })
|
||||
public void GuiProgressBarWindowTest1() {
|
||||
public void guiProgressBarWindowTest1() {
|
||||
try {
|
||||
final GuiProgressBarWindow dialog = new GuiProgressBarWindow();
|
||||
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class GuiQuestOptionsTest {
|
||||
* Gui quest options test1.
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" })
|
||||
public void GuiQuestOptionsTest1() {
|
||||
public void guiQuestOptionsTest1() {
|
||||
final QuestOptions dialog = new QuestOptions();
|
||||
dialog.setVisible(true);
|
||||
Assert.assertNotNull(dialog);
|
||||
|
||||
@@ -32,7 +32,7 @@ public class PanelTest extends JFrame {
|
||||
* Phase test1.
|
||||
*/
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
public void PhaseTest1() {
|
||||
public void phaseTest1() {
|
||||
final PanelTest p = new PanelTest();
|
||||
p.setSize(300, 300);
|
||||
p.setVisible(true);
|
||||
|
||||
@@ -12,7 +12,7 @@ public class PhaseTest {
|
||||
* Phase test1.
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = 5000, enabled = false)
|
||||
public void PhaseTest1() {
|
||||
public void phaseTest1() {
|
||||
final Phase phase = new Phase();
|
||||
for (int i = 0; i < phase.getPhaseOrder().length; i++) {
|
||||
System.out.println(phase.getPlayerTurn() + " " + phase.getPhase());
|
||||
|
||||
@@ -29,7 +29,6 @@ public class RunTest {
|
||||
*/
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
void test() {
|
||||
{
|
||||
Card c;
|
||||
final CardFactoryInterface cf = AllZone.getCardFactory();
|
||||
// ********* test Card
|
||||
@@ -220,9 +219,8 @@ public class RunTest {
|
||||
this.check("99", InputPayManaCostUtil.getLongColorString("1").equals(Constant.Color.COLORLESS));
|
||||
|
||||
/*
|
||||
* check("101",
|
||||
* Input_PayManaCostUtil.isManaNeeded(Constant.Color.Green, new
|
||||
* ManaCost("5")) == true); check("102",
|
||||
* 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
|
||||
@@ -276,60 +274,55 @@ public class RunTest {
|
||||
this.check("116", cardList.containsName(c2.getName()));
|
||||
|
||||
c = new Card();
|
||||
this.check("117", c.hasSickness() == true);
|
||||
this.check("117", c.hasSickness());
|
||||
c.addIntrinsicKeyword("Haste");
|
||||
this.check("118", c.hasSickness() == false);
|
||||
this.check("118", !c.hasSickness());
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
final CardFactoryInterface cf = AllZone.getCardFactory();
|
||||
final CardFactoryInterface cf1 = 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));
|
||||
c1.add(cf1.getCard("Shock", null));
|
||||
c1.add(cf1.getCard("Royal Assassin", null));
|
||||
c1.add(cf1.getCard("Hymn to Tourach", null));
|
||||
|
||||
CardList c2 = c1.filter(new CardListFilter() {
|
||||
CardList c3 = c1.filter(new CardListFilter() {
|
||||
@Override
|
||||
public boolean addCard(final Card c) {
|
||||
return c.isCreature();
|
||||
}
|
||||
});
|
||||
this.check("119", c2.containsName("Royal Assassin"));
|
||||
this.check("119", c2.size() == 1);
|
||||
this.check("119", c3.containsName("Royal Assassin"));
|
||||
this.check("119", c3.size() == 1);
|
||||
|
||||
c2 = c1.filter(new CardListFilter() {
|
||||
c3 = c1.filter(new CardListFilter() {
|
||||
@Override
|
||||
public boolean addCard(final Card c) {
|
||||
return c.isInstant();
|
||||
}
|
||||
});
|
||||
this.check("120", c2.containsName("Shock"));
|
||||
this.check("121", c2.size() == 1);
|
||||
this.check("120", c3.containsName("Shock"));
|
||||
this.check("121", c3.size() == 1);
|
||||
|
||||
c2 = c1.filter(new CardListFilter() {
|
||||
c3 = c1.filter(new CardListFilter() {
|
||||
@Override
|
||||
public boolean addCard(final Card c) {
|
||||
return c.getName().equals("Hymn to Tourach");
|
||||
}
|
||||
});
|
||||
this.check("120", c2.containsName("Hymn to Tourach"));
|
||||
this.check("121", c2.size() == 1);
|
||||
this.check("120", c3.containsName("Hymn to Tourach"));
|
||||
this.check("121", c3.size() == 1);
|
||||
|
||||
final Card card = cf.getCard("Sylvan Basilisk", null);
|
||||
final Card card2 = cf.getCard("Exalted Angel", null);
|
||||
final Card card = cf1.getCard("Sylvan Basilisk", null);
|
||||
final Card card2 = cf1.getCard("Exalted Angel", null);
|
||||
|
||||
this.check("121a", !CombatUtil.canDestroyAttacker(card, card2, null, false));
|
||||
}
|
||||
{
|
||||
|
||||
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>
|
||||
|
||||
@@ -27,7 +27,7 @@ public class CardFactoryUtilTest {
|
||||
* Card factory test1.
|
||||
*/
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
public void CardFactoryTest1() {
|
||||
public void cardFactoryTest1() {
|
||||
|
||||
Generator<Card> in = YieldUtils.toGenerator(AllZone.getCardFactory());
|
||||
|
||||
|
||||
473
src/test/java/forge/card/mana/ManaPartTest.java
Normal file
473
src/test/java/forge/card/mana/ManaPartTest.java
Normal file
@@ -0,0 +1,473 @@
|
||||
package forge.card.mana;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Constant;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mana_PartTest class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000)
|
||||
public class ManaPartTest {
|
||||
/**
|
||||
* <p>
|
||||
* testPayManaCost.
|
||||
* </p>
|
||||
*/
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = 5000)
|
||||
public void testPayManaCost() {
|
||||
// test constructor
|
||||
@SuppressWarnings("unused")
|
||||
ManaCost p = new ManaCost("G");
|
||||
p = new ManaCost("U");
|
||||
p = new ManaCost("W");
|
||||
p = new ManaCost("R");
|
||||
p = new ManaCost("B");
|
||||
p = new ManaCost("0");
|
||||
p = new ManaCost("1");
|
||||
p = new ManaCost("2");
|
||||
p = new ManaCost("3");
|
||||
p = new ManaCost("4");
|
||||
p = new ManaCost("5");
|
||||
p = new ManaCost("6");
|
||||
p = new ManaCost("7");
|
||||
p = new ManaCost("8");
|
||||
p = new ManaCost("9");
|
||||
p = new ManaCost("10");
|
||||
|
||||
p = new ManaCost("GW");
|
||||
p = new ManaCost("1 G");
|
||||
p = new ManaCost("1 GW");
|
||||
p = new ManaCost("GW GW");
|
||||
p = new ManaCost("GW GW GW");
|
||||
p = new ManaCost("GW GW GW GW");
|
||||
|
||||
p = new ManaCost("G G");
|
||||
p = new ManaCost("G G G");
|
||||
p = new ManaCost("G G G");
|
||||
p = new ManaCost("G G G G");
|
||||
|
||||
p = new ManaCost("2 GW GW GW");
|
||||
p = new ManaCost("3 G G G");
|
||||
p = new ManaCost("12 GW GW GW");
|
||||
p = new ManaCost("11 G G G");
|
||||
|
||||
p = new ManaCost("2/U");
|
||||
p = new ManaCost("2/B 2/B");
|
||||
p = new ManaCost("2/G 2/G 2/G");
|
||||
p = new ManaCost("2/R 2/R 2/R 2/R");
|
||||
p = new ManaCost("2/W 2/B 2/U 2/R 2/G");
|
||||
|
||||
final ManaCost p1 = new ManaCost("2/U");
|
||||
|
||||
this.check(0.3, p1.isNeeded("G"));
|
||||
this.check(0.4, p1.isNeeded("U"));
|
||||
this.check(0.5, p1.isNeeded("B"));
|
||||
this.check(0.6, p1.isNeeded("W"));
|
||||
this.check(0.7, p1.isNeeded("R"));
|
||||
this.check(0.8, p1.isNeeded("1"));
|
||||
|
||||
p1.addMana("U");
|
||||
this.check(0.9, p1.isPaid());
|
||||
|
||||
this.check(0.91, !p1.isNeeded("R"));
|
||||
|
||||
final ManaCost p2 = new ManaCost("G");
|
||||
this.check(1, p2.isNeeded("G"));
|
||||
|
||||
this.check(1.1, !p2.isNeeded("U"));
|
||||
this.check(1.2, !p2.isNeeded("B"));
|
||||
this.check(1.3, !p2.isNeeded("W"));
|
||||
this.check(1.4, !p2.isNeeded("R"));
|
||||
this.check(1.5, !p2.isNeeded("1"));
|
||||
|
||||
p2.addMana("G");
|
||||
this.check(2, p2.isPaid());
|
||||
|
||||
this.check(2.1, !p2.isNeeded("G"));
|
||||
|
||||
final ManaCost p4 = new ManaCost("1");
|
||||
|
||||
this.check(3, p4.isNeeded("G"));
|
||||
this.check(4, p4.isNeeded("U"));
|
||||
this.check(5, p4.isNeeded("B"));
|
||||
this.check(6, p4.isNeeded("W"));
|
||||
this.check(7, p4.isNeeded("R"));
|
||||
this.check(8, p4.isNeeded("1"));
|
||||
|
||||
p4.addMana("B");
|
||||
this.check(9, p4.isPaid());
|
||||
|
||||
this.check(9.1, !p4.isNeeded("R"));
|
||||
|
||||
final ManaCost p5 = new ManaCost("GW");
|
||||
|
||||
this.check(10, p5.isNeeded("G"));
|
||||
this.check(13, p5.isNeeded("W"));
|
||||
|
||||
this.check(11, !p5.isNeeded("U"));
|
||||
this.check(12, !p5.isNeeded("B"));
|
||||
this.check(14, !p5.isNeeded("R"));
|
||||
this.check(15, !p5.isNeeded("1"));
|
||||
|
||||
p5.addMana("W");
|
||||
this.check(16, p5.isPaid());
|
||||
|
||||
this.check(17, !p5.isNeeded("W"));
|
||||
|
||||
final ManaCost p6 = new ManaCost("BR");
|
||||
|
||||
this.check(17.1, p6.isNeeded("B"));
|
||||
this.check(17.2, p6.isNeeded("R"));
|
||||
|
||||
this.check(17.3, !p6.isNeeded("U"));
|
||||
this.check(17.4, !p6.isNeeded("W"));
|
||||
this.check(17.5, !p6.isNeeded("G"));
|
||||
this.check(17.6, !p6.isNeeded("1"));
|
||||
|
||||
p6.addMana("R");
|
||||
this.check(17.7, p6.isPaid());
|
||||
|
||||
this.check(17.8, !p6.isNeeded("R"));
|
||||
|
||||
final ManaCost p7 = new ManaCost("1 G G");
|
||||
|
||||
p7.addMana("G");
|
||||
|
||||
this.check(18.1, p7.isNeeded("G"));
|
||||
this.check(18.2, p7.isNeeded("W"));
|
||||
this.check(18.3, p7.isNeeded("U"));
|
||||
this.check(18.4, p7.isNeeded("B"));
|
||||
this.check(18.5, p7.isNeeded("R"));
|
||||
this.check(18.6, p7.isNeeded("1"));
|
||||
|
||||
p7.addMana("1");
|
||||
p7.addMana("G");
|
||||
|
||||
this.check(18.7, p7.isPaid());
|
||||
|
||||
this.check(18.8, !p7.isNeeded("W"));
|
||||
|
||||
final ManaCost p8 = new ManaCost("0");
|
||||
|
||||
this.check(19.1, !p8.isNeeded("1"));
|
||||
this.check(19.2, !p8.isNeeded("G"));
|
||||
this.check(19.3, !p8.isNeeded("U"));
|
||||
|
||||
this.check(19.4, p8.isPaid());
|
||||
|
||||
this.check(19.5, !p8.isNeeded("R"));
|
||||
|
||||
final ManaCost p9 = new ManaCost("G G");
|
||||
|
||||
this.check(20.1, !p9.isNeeded("1"));
|
||||
this.check(20.2, p9.isNeeded("G"));
|
||||
|
||||
this.check(20.3, !p9.isNeeded("U"));
|
||||
|
||||
p9.addMana("G");
|
||||
p9.addMana("G");
|
||||
|
||||
this.check(20.4, p9.isPaid());
|
||||
|
||||
this.check(20.5, !p9.isNeeded("B"));
|
||||
|
||||
final ManaCost p10 = new ManaCost("G G G");
|
||||
|
||||
this.check(21.1, !p10.isNeeded("W"));
|
||||
this.check(21.2, p10.isNeeded("G"));
|
||||
|
||||
this.check(21.3, !p10.isNeeded("R"));
|
||||
|
||||
p10.addMana("G");
|
||||
p10.addMana("G");
|
||||
p10.addMana("G");
|
||||
|
||||
this.check(21.4, p10.isPaid());
|
||||
|
||||
this.check(21.5, !p10.isNeeded("U"));
|
||||
|
||||
final ManaCost p11 = new ManaCost("G G G G");
|
||||
|
||||
this.check(22.1, !p11.isNeeded("W"));
|
||||
this.check(22.2, p11.isNeeded("G"));
|
||||
|
||||
this.check(22.3, !p11.isNeeded("R"));
|
||||
|
||||
p11.addMana("G");
|
||||
p11.addMana("G");
|
||||
p11.addMana("G");
|
||||
p11.addMana("G");
|
||||
|
||||
this.check(22.4, p11.isPaid());
|
||||
|
||||
this.check(22.5, !p11.isNeeded("G"));
|
||||
|
||||
final ManaCost p12 = new ManaCost("GW");
|
||||
|
||||
this.check(23.1, p12.isNeeded("W"));
|
||||
this.check(23.2, p12.isNeeded("G"));
|
||||
this.check(23.3, !p12.isNeeded("R"));
|
||||
|
||||
p12.addMana("G");
|
||||
|
||||
this.check(23.4, p12.isPaid());
|
||||
|
||||
this.check(23.5, !p12.isNeeded("G"));
|
||||
|
||||
final ManaCost p13 = new ManaCost("GW");
|
||||
|
||||
this.check(24.1, p13.isNeeded("W"));
|
||||
this.check(24.2, p13.isNeeded("G"));
|
||||
this.check(24.3, !p13.isNeeded("U"));
|
||||
|
||||
p13.addMana("W");
|
||||
|
||||
this.check(24.4, p13.isPaid());
|
||||
|
||||
this.check(24.5, !p13.isNeeded("W"));
|
||||
|
||||
final ManaCost p14 = new ManaCost("3 GW GW");
|
||||
|
||||
this.check(25.1, p14.isNeeded("W"));
|
||||
this.check(25.2, p14.isNeeded("G"));
|
||||
this.check(25.3, p14.isNeeded("U"));
|
||||
|
||||
p14.addMana("1");
|
||||
p14.addMana("1");
|
||||
p14.addMana("1");
|
||||
|
||||
this.check(25.4, p14.isNeeded("W"));
|
||||
this.check(25.5, p14.isNeeded("G"));
|
||||
this.check(25.6, !p14.isNeeded("U"));
|
||||
|
||||
p14.addMana("G");
|
||||
p14.addMana("W");
|
||||
|
||||
this.check(25.7, p14.isPaid());
|
||||
|
||||
this.check(25.8, !p14.isNeeded("W"));
|
||||
this.check(25.9, !p14.isNeeded("G"));
|
||||
this.check(25.10, !p14.isNeeded("1"));
|
||||
this.check(25.11, !p14.isNeeded("R"));
|
||||
|
||||
final ManaCost p15 = new ManaCost("4");
|
||||
|
||||
this.check(26.1, p15.isNeeded("W"));
|
||||
this.check(26.2, p15.isNeeded("G"));
|
||||
this.check(26.3, p15.isNeeded("U"));
|
||||
|
||||
p15.addMana("1");
|
||||
p15.addMana("1");
|
||||
p15.addMana("1");
|
||||
p15.addMana("1");
|
||||
|
||||
this.check(26.4, p15.isPaid());
|
||||
|
||||
final ManaCost p16 = new ManaCost("10");
|
||||
|
||||
p16.addMana("G");
|
||||
p16.addMana("W");
|
||||
p16.addMana("R");
|
||||
p16.addMana("U");
|
||||
p16.addMana("B");
|
||||
|
||||
p16.addMana("1");
|
||||
|
||||
p16.addMana("W");
|
||||
p16.addMana("R");
|
||||
p16.addMana("U");
|
||||
p16.addMana("B");
|
||||
|
||||
this.check(27, p16.isPaid());
|
||||
|
||||
final ManaCost p17 = new ManaCost("12 G GW");
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
p17.addMana("R");
|
||||
}
|
||||
|
||||
p17.addMana("G");
|
||||
p17.addMana("W");
|
||||
|
||||
this.check(28, p17.isPaid());
|
||||
|
||||
final ManaCost p18 = new ManaCost("2 W B U R G");
|
||||
|
||||
for (int i = 0; i < 1; i++) {
|
||||
p18.addMana("R");
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
p18.addMana("1");
|
||||
}
|
||||
|
||||
for (int i = 0; i < 1; i++) {
|
||||
p18.addMana("G");
|
||||
p18.addMana("W");
|
||||
p18.addMana("B");
|
||||
p18.addMana("U");
|
||||
|
||||
}
|
||||
this.check(29, p18.isPaid());
|
||||
|
||||
final ManaCost p19 = new ManaCost("W B U R G W");
|
||||
|
||||
p19.addMana("R");
|
||||
p19.addMana("G");
|
||||
p19.addMana("B");
|
||||
p19.addMana("U");
|
||||
|
||||
p19.addMana("W");
|
||||
p19.addMana("W");
|
||||
|
||||
this.check(30, p19.isPaid());
|
||||
|
||||
final ManaCost p20 = new ManaCost("W B U R G W B U R G");
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
p20.addMana("W");
|
||||
p20.addMana("R");
|
||||
p20.addMana("G");
|
||||
p20.addMana("B");
|
||||
p20.addMana("U");
|
||||
}
|
||||
|
||||
this.check(31, p20.isPaid());
|
||||
|
||||
final ManaCost p21 = new ManaCost("2 W B U R G W B U R G G");
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
p21.addMana("W");
|
||||
p21.addMana("R");
|
||||
p21.addMana("G");
|
||||
p21.addMana("B");
|
||||
p21.addMana("U");
|
||||
}
|
||||
|
||||
p21.addMana("1");
|
||||
p21.addMana("1");
|
||||
p21.addMana("G");
|
||||
|
||||
this.check(32, p21.isPaid());
|
||||
|
||||
final ManaCost p22 = new ManaCost("1 B R");
|
||||
|
||||
p22.addMana("B");
|
||||
p22.addMana("1");
|
||||
p22.addMana("R");
|
||||
|
||||
this.check(33, p22.isPaid());
|
||||
|
||||
final ManaCost p23 = new ManaCost("B R");
|
||||
|
||||
p23.addMana("B");
|
||||
p23.addMana("R");
|
||||
|
||||
this.check(34, p23.isPaid());
|
||||
|
||||
final ManaCost p24 = new ManaCost("2/B 2/B 2/B");
|
||||
|
||||
this.check(35, p24.isNeeded("G"));
|
||||
|
||||
p24.addMana("B");
|
||||
this.check(36, p24.toString().equals("2/B 2/B"));
|
||||
|
||||
p24.addMana("B");
|
||||
this.check(37, p24.toString().equals("2/B"));
|
||||
|
||||
p24.addMana("B");
|
||||
this.check(38, p24.isPaid());
|
||||
|
||||
final ManaCost p25 = new ManaCost("2/G");
|
||||
|
||||
p25.addMana("1");
|
||||
this.check(39, p25.toString().equals("1"));
|
||||
|
||||
p25.addMana("W");
|
||||
this.check(40, p25.isPaid());
|
||||
|
||||
final ManaCost p27 = new ManaCost("2/R 2/R");
|
||||
|
||||
p27.addMana("1");
|
||||
this.check(41, p27.toString().equals("2/R 1"));
|
||||
|
||||
p27.addMana("W");
|
||||
this.check(42, p27.toString().equals("2/R"));
|
||||
|
||||
final ManaCost p26 = new ManaCost("2/W 2/W");
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
this.check(43, !p26.isPaid());
|
||||
p26.addMana("1");
|
||||
}
|
||||
|
||||
this.check(44, p26.isPaid());
|
||||
|
||||
final ManaCost p28 = new ManaCost("2/W 2/B 2/U 2/R 2/G");
|
||||
this.check(45, !p28.isPaid());
|
||||
|
||||
p28.addMana("B");
|
||||
p28.addMana("R");
|
||||
p28.addMana("G");
|
||||
p28.addMana("W");
|
||||
p28.addMana("U");
|
||||
|
||||
this.check(45.1, p28.isPaid(), p28);
|
||||
|
||||
final ManaCost p29 = new ManaCost("2/W 2/B 2/U 2/R 2/G");
|
||||
this.check(46, !p29.isPaid());
|
||||
|
||||
final Card c = new Card();
|
||||
|
||||
p29.addMana(new Mana(Constant.Color.BLACK, 1, c));
|
||||
p29.addMana(new Mana(Constant.Color.RED, 1, c));
|
||||
p29.addMana(new Mana(Constant.Color.GREEN, 1, c));
|
||||
p29.addMana(new Mana(Constant.Color.WHITE, 1, c));
|
||||
p29.addMana(new Mana(Constant.Color.BLUE, 1, c));
|
||||
|
||||
this.check(46.1, p29.isPaid(), p29);
|
||||
|
||||
} // testPayManaCost()
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* check.
|
||||
* </p>
|
||||
*
|
||||
* @param n
|
||||
* a double.
|
||||
* @param b
|
||||
* a boolean.
|
||||
*/
|
||||
void check(final double n, final boolean b) {
|
||||
if (!b) {
|
||||
System.out.println("failed : " + n);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* check.
|
||||
* </p>
|
||||
*
|
||||
* @param n
|
||||
* a double.
|
||||
* @param b
|
||||
* a boolean.
|
||||
* @param p
|
||||
* a {@link forge.card.mana.ManaCost} object.
|
||||
*/
|
||||
void check(final double n, final boolean b, final ManaCost p) {
|
||||
if (!b) {
|
||||
System.out.println("failed : " + n);
|
||||
System.out.println(p.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,521 +0,0 @@
|
||||
package forge.card.mana;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Constant;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* <p>Mana_PartTest class.</p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000)
|
||||
public class Mana_PartTest {
|
||||
/**
|
||||
* <p>testPayManaCost.</p>
|
||||
*/
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = 5000)
|
||||
public void testPayManaCost() {
|
||||
{
|
||||
//test constructor
|
||||
@SuppressWarnings("unused")
|
||||
ManaCost p = new ManaCost("G");
|
||||
p = new ManaCost("U");
|
||||
p = new ManaCost("W");
|
||||
p = new ManaCost("R");
|
||||
p = new ManaCost("B");
|
||||
p = new ManaCost("0");
|
||||
p = new ManaCost("1");
|
||||
p = new ManaCost("2");
|
||||
p = new ManaCost("3");
|
||||
p = new ManaCost("4");
|
||||
p = new ManaCost("5");
|
||||
p = new ManaCost("6");
|
||||
p = new ManaCost("7");
|
||||
p = new ManaCost("8");
|
||||
p = new ManaCost("9");
|
||||
p = new ManaCost("10");
|
||||
|
||||
p = new ManaCost("GW");
|
||||
p = new ManaCost("1 G");
|
||||
p = new ManaCost("1 GW");
|
||||
p = new ManaCost("GW GW");
|
||||
p = new ManaCost("GW GW GW");
|
||||
p = new ManaCost("GW GW GW GW");
|
||||
|
||||
p = new ManaCost("G G");
|
||||
p = new ManaCost("G G G");
|
||||
p = new ManaCost("G G G");
|
||||
p = new ManaCost("G G G G");
|
||||
|
||||
p = new ManaCost("2 GW GW GW");
|
||||
p = new ManaCost("3 G G G");
|
||||
p = new ManaCost("12 GW GW GW");
|
||||
p = new ManaCost("11 G G G");
|
||||
|
||||
p = new ManaCost("2/U");
|
||||
p = new ManaCost("2/B 2/B");
|
||||
p = new ManaCost("2/G 2/G 2/G");
|
||||
p = new ManaCost("2/R 2/R 2/R 2/R");
|
||||
p = new ManaCost("2/W 2/B 2/U 2/R 2/G");
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("2/U");
|
||||
|
||||
check(0.3, p.isNeeded("G"));
|
||||
check(0.4, p.isNeeded("U"));
|
||||
check(0.5, p.isNeeded("B"));
|
||||
check(0.6, p.isNeeded("W"));
|
||||
check(0.7, p.isNeeded("R"));
|
||||
check(0.8, p.isNeeded("1"));
|
||||
|
||||
p.addMana("U");
|
||||
check(0.9, p.isPaid());
|
||||
|
||||
check(0.91, !p.isNeeded("R"));
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("G");
|
||||
check(1, p.isNeeded("G"));
|
||||
|
||||
check(1.1, !p.isNeeded("U"));
|
||||
check(1.2, !p.isNeeded("B"));
|
||||
check(1.3, !p.isNeeded("W"));
|
||||
check(1.4, !p.isNeeded("R"));
|
||||
check(1.5, !p.isNeeded("1"));
|
||||
|
||||
p.addMana("G");
|
||||
check(2, p.isPaid());
|
||||
|
||||
check(2.1, !p.isNeeded("G"));
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("1");
|
||||
|
||||
check(3, p.isNeeded("G"));
|
||||
check(4, p.isNeeded("U"));
|
||||
check(5, p.isNeeded("B"));
|
||||
check(6, p.isNeeded("W"));
|
||||
check(7, p.isNeeded("R"));
|
||||
check(8, p.isNeeded("1"));
|
||||
|
||||
p.addMana("B");
|
||||
check(9, p.isPaid());
|
||||
|
||||
check(9.1, !p.isNeeded("R"));
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("GW");
|
||||
|
||||
check(10, p.isNeeded("G"));
|
||||
check(13, p.isNeeded("W"));
|
||||
|
||||
check(11, !p.isNeeded("U"));
|
||||
check(12, !p.isNeeded("B"));
|
||||
check(14, !p.isNeeded("R"));
|
||||
check(15, !p.isNeeded("1"));
|
||||
|
||||
p.addMana("W");
|
||||
check(16, p.isPaid());
|
||||
|
||||
check(17, !p.isNeeded("W"));
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("BR");
|
||||
|
||||
check(17.1, p.isNeeded("B"));
|
||||
check(17.2, p.isNeeded("R"));
|
||||
|
||||
check(17.3, !p.isNeeded("U"));
|
||||
check(17.4, !p.isNeeded("W"));
|
||||
check(17.5, !p.isNeeded("G"));
|
||||
check(17.6, !p.isNeeded("1"));
|
||||
|
||||
p.addMana("R");
|
||||
check(17.7, p.isPaid());
|
||||
|
||||
check(17.8, !p.isNeeded("R"));
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("1 G G");
|
||||
|
||||
p.addMana("G");
|
||||
|
||||
check(18.1, p.isNeeded("G"));
|
||||
check(18.2, p.isNeeded("W"));
|
||||
check(18.3, p.isNeeded("U"));
|
||||
check(18.4, p.isNeeded("B"));
|
||||
check(18.5, p.isNeeded("R"));
|
||||
check(18.6, p.isNeeded("1"));
|
||||
|
||||
p.addMana("1");
|
||||
p.addMana("G");
|
||||
|
||||
check(18.7, p.isPaid());
|
||||
|
||||
check(18.8, !p.isNeeded("W"));
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("0");
|
||||
|
||||
check(19.1, !p.isNeeded("1"));
|
||||
check(19.2, !p.isNeeded("G"));
|
||||
check(19.3, !p.isNeeded("U"));
|
||||
|
||||
check(19.4, p.isPaid());
|
||||
|
||||
check(19.5, !p.isNeeded("R"));
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("G G");
|
||||
|
||||
check(20.1, !p.isNeeded("1"));
|
||||
check(20.2, p.isNeeded("G"));
|
||||
|
||||
check(20.3, !p.isNeeded("U"));
|
||||
|
||||
p.addMana("G");
|
||||
p.addMana("G");
|
||||
|
||||
check(20.4, p.isPaid());
|
||||
|
||||
check(20.5, !p.isNeeded("B"));
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("G G G");
|
||||
|
||||
check(21.1, !p.isNeeded("W"));
|
||||
check(21.2, p.isNeeded("G"));
|
||||
|
||||
check(21.3, !p.isNeeded("R"));
|
||||
|
||||
p.addMana("G");
|
||||
p.addMana("G");
|
||||
p.addMana("G");
|
||||
|
||||
check(21.4, p.isPaid());
|
||||
|
||||
check(21.5, !p.isNeeded("U"));
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("G G G G");
|
||||
|
||||
check(22.1, !p.isNeeded("W"));
|
||||
check(22.2, p.isNeeded("G"));
|
||||
|
||||
check(22.3, !p.isNeeded("R"));
|
||||
|
||||
p.addMana("G");
|
||||
p.addMana("G");
|
||||
p.addMana("G");
|
||||
p.addMana("G");
|
||||
|
||||
check(22.4, p.isPaid());
|
||||
|
||||
check(22.5, !p.isNeeded("G"));
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("GW");
|
||||
|
||||
check(23.1, p.isNeeded("W"));
|
||||
check(23.2, p.isNeeded("G"));
|
||||
check(23.3, !p.isNeeded("R"));
|
||||
|
||||
p.addMana("G");
|
||||
|
||||
check(23.4, p.isPaid());
|
||||
|
||||
check(23.5, !p.isNeeded("G"));
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("GW");
|
||||
|
||||
check(24.1, p.isNeeded("W"));
|
||||
check(24.2, p.isNeeded("G"));
|
||||
check(24.3, !p.isNeeded("U"));
|
||||
|
||||
p.addMana("W");
|
||||
|
||||
check(24.4, p.isPaid());
|
||||
|
||||
check(24.5, !p.isNeeded("W"));
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("3 GW GW");
|
||||
|
||||
check(25.1, p.isNeeded("W"));
|
||||
check(25.2, p.isNeeded("G"));
|
||||
check(25.3, p.isNeeded("U"));
|
||||
|
||||
p.addMana("1");
|
||||
p.addMana("1");
|
||||
p.addMana("1");
|
||||
|
||||
check(25.4, p.isNeeded("W"));
|
||||
check(25.5, p.isNeeded("G"));
|
||||
check(25.6, !p.isNeeded("U"));
|
||||
|
||||
p.addMana("G");
|
||||
p.addMana("W");
|
||||
|
||||
check(25.7, p.isPaid());
|
||||
|
||||
check(25.8, !p.isNeeded("W"));
|
||||
check(25.9, !p.isNeeded("G"));
|
||||
check(25.10, !p.isNeeded("1"));
|
||||
check(25.11, !p.isNeeded("R"));
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("4");
|
||||
|
||||
check(26.1, p.isNeeded("W"));
|
||||
check(26.2, p.isNeeded("G"));
|
||||
check(26.3, p.isNeeded("U"));
|
||||
|
||||
p.addMana("1");
|
||||
p.addMana("1");
|
||||
p.addMana("1");
|
||||
p.addMana("1");
|
||||
|
||||
check(26.4, p.isPaid());
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("10");
|
||||
|
||||
p.addMana("G");
|
||||
p.addMana("W");
|
||||
p.addMana("R");
|
||||
p.addMana("U");
|
||||
p.addMana("B");
|
||||
|
||||
p.addMana("1");
|
||||
|
||||
p.addMana("W");
|
||||
p.addMana("R");
|
||||
p.addMana("U");
|
||||
p.addMana("B");
|
||||
|
||||
check(27, p.isPaid());
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("12 G GW");
|
||||
|
||||
for (int i = 0; i < 12; i++)
|
||||
p.addMana("R");
|
||||
|
||||
p.addMana("G");
|
||||
p.addMana("W");
|
||||
|
||||
check(28, p.isPaid());
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("2 W B U R G");
|
||||
|
||||
for (int i = 0; i < 1; i++)
|
||||
p.addMana("R");
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
p.addMana("1");
|
||||
|
||||
for (int i = 0; i < 1; i++) {
|
||||
p.addMana("G");
|
||||
p.addMana("W");
|
||||
p.addMana("B");
|
||||
p.addMana("U");
|
||||
|
||||
}
|
||||
check(29, p.isPaid());
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("W B U R G W");
|
||||
|
||||
p.addMana("R");
|
||||
p.addMana("G");
|
||||
p.addMana("B");
|
||||
p.addMana("U");
|
||||
|
||||
p.addMana("W");
|
||||
p.addMana("W");
|
||||
|
||||
check(30, p.isPaid());
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("W B U R G W B U R G");
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
p.addMana("W");
|
||||
p.addMana("R");
|
||||
p.addMana("G");
|
||||
p.addMana("B");
|
||||
p.addMana("U");
|
||||
}
|
||||
|
||||
check(31, p.isPaid());
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("2 W B U R G W B U R G G");
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
p.addMana("W");
|
||||
p.addMana("R");
|
||||
p.addMana("G");
|
||||
p.addMana("B");
|
||||
p.addMana("U");
|
||||
}
|
||||
|
||||
p.addMana("1");
|
||||
p.addMana("1");
|
||||
p.addMana("G");
|
||||
|
||||
check(32, p.isPaid());
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("1 B R");
|
||||
|
||||
p.addMana("B");
|
||||
p.addMana("1");
|
||||
p.addMana("R");
|
||||
|
||||
check(33, p.isPaid());
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("B R");
|
||||
|
||||
p.addMana("B");
|
||||
p.addMana("R");
|
||||
|
||||
check(34, p.isPaid());
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("2/B 2/B 2/B");
|
||||
|
||||
check(35, p.isNeeded("G"));
|
||||
|
||||
p.addMana("B");
|
||||
check(36, p.toString().equals("2/B 2/B"));
|
||||
|
||||
p.addMana("B");
|
||||
check(37, p.toString().equals("2/B"));
|
||||
|
||||
p.addMana("B");
|
||||
check(38, p.isPaid());
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("2/G");
|
||||
|
||||
p.addMana("1");
|
||||
check(39, p.toString().equals("1"));
|
||||
|
||||
p.addMana("W");
|
||||
check(40, p.isPaid());
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("2/R 2/R");
|
||||
|
||||
p.addMana("1");
|
||||
check(41, p.toString().equals("2/R 1"));
|
||||
|
||||
p.addMana("W");
|
||||
check(42, p.toString().equals("2/R"));
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("2/W 2/W");
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
check(43, p.isPaid() == false);
|
||||
p.addMana("1");
|
||||
}
|
||||
|
||||
check(44, p.isPaid());
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("2/W 2/B 2/U 2/R 2/G");
|
||||
check(45, p.isPaid() == false);
|
||||
|
||||
p.addMana("B");
|
||||
p.addMana("R");
|
||||
p.addMana("G");
|
||||
p.addMana("W");
|
||||
p.addMana("U");
|
||||
|
||||
check(45.1, p.isPaid(), p);
|
||||
}
|
||||
|
||||
{
|
||||
ManaCost p = new ManaCost("2/W 2/B 2/U 2/R 2/G");
|
||||
check(46, p.isPaid() == false);
|
||||
|
||||
Card c = new Card();
|
||||
|
||||
p.addMana(new Mana(Constant.Color.BLACK, 1, c));
|
||||
p.addMana(new Mana(Constant.Color.RED, 1, c));
|
||||
p.addMana(new Mana(Constant.Color.GREEN, 1, c));
|
||||
p.addMana(new Mana(Constant.Color.WHITE, 1, c));
|
||||
p.addMana(new Mana(Constant.Color.BLUE, 1, c));
|
||||
|
||||
check(46.1, p.isPaid(), p);
|
||||
}
|
||||
|
||||
} //testPayManaCost()
|
||||
|
||||
|
||||
/**
|
||||
* <p>check.</p>
|
||||
*
|
||||
* @param n a double.
|
||||
* @param b a boolean.
|
||||
*/
|
||||
void check(double n, boolean b) {
|
||||
if (!b) {
|
||||
System.out.println("failed : " + n);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>check.</p>
|
||||
*
|
||||
* @param n a double.
|
||||
* @param b a boolean.
|
||||
* @param p a {@link forge.card.mana.ManaCost} object.
|
||||
*/
|
||||
void check(double n, boolean b, ManaCost p) {
|
||||
if (!b) {
|
||||
System.out.println("failed : " + n);
|
||||
System.out.println(p.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,23 @@
|
||||
package forge.deck.generate;
|
||||
|
||||
import forge.CardList;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.CardList;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: dhudson
|
||||
* Created by IntelliJ IDEA. User: dhudson
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, enabled = false)
|
||||
@Test(groups = { "UnitTest" }, enabled = false)
|
||||
public class Generate2ColorDeckTest {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Generate2 color deck test1.
|
||||
*/
|
||||
@Test(enabled = false)
|
||||
public void Generate2ColorDeckTest1() {
|
||||
Generate2ColorDeck gen = new Generate2ColorDeck("white", "blue");
|
||||
CardList cardList = gen.get2ColorDeck(60, null);
|
||||
public void generate2ColorDeckTest1() {
|
||||
final Generate2ColorDeck gen = new Generate2ColorDeck("white", "blue");
|
||||
final CardList cardList = gen.get2ColorDeck(60, null);
|
||||
Assert.assertNotNull(cardList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
package forge.deck.generate;
|
||||
|
||||
import forge.CardList;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.CardList;
|
||||
|
||||
/**
|
||||
* 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 Generate3ColorDeckTest {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Generate3 color deck test1.
|
||||
*/
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
public void Generate3ColorDeckTest1() {
|
||||
Generate3ColorDeck gen = new Generate3ColorDeck("white", "blue", "black");
|
||||
CardList cardList = gen.get3ColorDeck(60, null);
|
||||
public void generate3ColorDeckTest1() {
|
||||
final Generate3ColorDeck gen = new Generate3ColorDeck("white", "blue", "black");
|
||||
final CardList cardList = gen.get3ColorDeck(60, null);
|
||||
Assert.assertNotNull(cardList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
package forge.deck.generate;
|
||||
|
||||
import forge.CardList;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.CardList;
|
||||
|
||||
/**
|
||||
* 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 Generate5ColorDeckTest {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Generate5 color deck test1.
|
||||
*/
|
||||
@Test(timeOut = 1000, enabled = false)
|
||||
public void Generate5ColorDeckTest1() {
|
||||
Generate5ColorDeck gen = new Generate5ColorDeck();
|
||||
CardList cardList = gen.get5ColorDeck(60, null);
|
||||
public void generate5ColorDeckTest1() {
|
||||
final Generate5ColorDeck gen = new Generate5ColorDeck();
|
||||
final CardList cardList = gen.get5ColorDeck(60, null);
|
||||
Assert.assertNotNull(cardList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
package forge.deck.generate;
|
||||
|
||||
import forge.CardList;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.CardList;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: dhudson
|
||||
* Created by IntelliJ IDEA. User: dhudson
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000)
|
||||
@Test(groups = { "UnitTest" }, timeOut = 1000)
|
||||
public class GenerateConstructedDeckTest {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Generate constructed deck test1.
|
||||
*/
|
||||
@Test(enabled = false, timeOut = 1000)
|
||||
public void GenerateConstructedDeckTest1() {
|
||||
GenerateConstructedDeck g = new GenerateConstructedDeck();
|
||||
public void generateConstructedDeckTest1() {
|
||||
final GenerateConstructedDeck g = new GenerateConstructedDeck();
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
CardList c = g.generateDeck();
|
||||
final CardList c = g.generateDeck();
|
||||
System.out.println(c.getType("Creature").size() + " - " + c.size());
|
||||
}
|
||||
System.exit(1);
|
||||
|
||||
}//main
|
||||
} // main
|
||||
}
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
package forge.deck.generate;
|
||||
|
||||
import forge.CardList;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import forge.CardList;
|
||||
|
||||
/**
|
||||
* 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 GenerateConstructedMultiColorDeckTest {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Generate constructed multi color deck test1.
|
||||
*/
|
||||
@Test(enabled = false, timeOut = 1000)
|
||||
public void GenerateConstructedMultiColorDeckTest1() {
|
||||
GenerateConstructedMultiColorDeck g = new GenerateConstructedMultiColorDeck();
|
||||
public void generateConstructedMultiColorDeckTest1() {
|
||||
final GenerateConstructedMultiColorDeck g = new GenerateConstructedMultiColorDeck();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
System.out.println("***GENERATING DECK***");
|
||||
CardList c = g.generate3ColorDeck();
|
||||
final CardList c = g.generate3ColorDeck();
|
||||
System.out.println(c.getType("Creature").size() + " - " + c.size());
|
||||
for (int j = 0; j < c.size(); j++) {
|
||||
System.out.println(c.get(j).getName());
|
||||
@@ -29,6 +28,5 @@ public class GenerateConstructedMultiColorDeckTest {
|
||||
|
||||
}
|
||||
System.exit(1);
|
||||
}//main
|
||||
} // main
|
||||
}
|
||||
|
||||
|
||||
@@ -3,20 +3,19 @@ package forge.gui;
|
||||
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 ListChooserTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* List chooser test1.
|
||||
*/
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = 1000)
|
||||
public void ListChooserTest1() {
|
||||
ListChooser<String> c = new ListChooser<String>("test", "choose a or b", 0, 2, "a", "b");
|
||||
@Test(groups = { "UnitTest", "fast" }, timeOut = 1000)
|
||||
public void listChooserTest1() {
|
||||
final ListChooser<String> c = new ListChooser<String>("test", "choose a or b", 0, 2, "a", "b");
|
||||
System.out.println(c.show());
|
||||
for (String s : c.getSelectedValues()) {
|
||||
for (final String s : c.getSelectedValues()) {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,24 +4,23 @@ 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 CardDetailPanelTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Card detail panel test1.
|
||||
*/
|
||||
@Test(groups = {"UnitTest", "fast"})
|
||||
@Test(groups = { "UnitTest", "fast" })
|
||||
public void cardDetailPanelTest1() {
|
||||
try {
|
||||
CardDetailPanel dialog = new CardDetailPanel(null);
|
||||
//dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
// dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
Assert.assertNotNull(dialog);
|
||||
dialog = null;
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package forge.model;
|
||||
|
||||
import static net.slightlymagic.braids.util.testng.BraidsAssertFunctions.assertThrowsException;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -11,7 +7,9 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import net.slightlymagic.braids.util.ClumsyRunnable;
|
||||
import net.slightlymagic.braids.util.testng.BraidsAssertFunctions;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -22,119 +20,149 @@ public class BuildInfoTest {
|
||||
/** System property name for the class path. */
|
||||
private static final String JAVA_CLASS_PATH = "java.class.path";
|
||||
/** Manifest attribute name for the Build ID. */
|
||||
private static final String MF_ATTR_NAME_BUILD = "Implementation-Build"; // NOPMD by Braids on 8/12/11 10:29 AM
|
||||
private static final String MF_ATTR_NAME_BUILD = "Implementation-Build"; // NOPMD
|
||||
// by
|
||||
// Braids
|
||||
// on
|
||||
// 8/12/11
|
||||
// 10:29
|
||||
// AM
|
||||
/** Manifest attribute name for the version string. */
|
||||
private static final String MF_ATTR_NAME_VERSION = "Implementation-Version"; // NOPMD by Braids on 8/12/11 10:29 AM
|
||||
private static final String MF_ATTR_NAME_VERSION = "Implementation-Version"; // NOPMD
|
||||
// by
|
||||
// Braids
|
||||
// on
|
||||
// 8/12/11
|
||||
// 10:29
|
||||
// AM
|
||||
|
||||
/**
|
||||
* Test BuildInfo using a mock jar file.
|
||||
* @throws IOException rarely
|
||||
*
|
||||
* @throws IOException
|
||||
* rarely
|
||||
*/
|
||||
@Test
|
||||
public final void test_BuildInfo_mockJar() throws IOException { // NOPMD by Braids on 8/12/11 10:26 AM
|
||||
public final void test_BuildInfo_mockJar() throws IOException { // NOPMD by
|
||||
// Braids on
|
||||
// 8/12/11
|
||||
// 10:26 AM
|
||||
File jarAsFile = null;
|
||||
try {
|
||||
jarAsFile = makeTmpJarWithManifest("BuildInfoTest-", ".jar",
|
||||
new String[] {MF_ATTR_NAME_VERSION, "1.2.42", MF_ATTR_NAME_BUILD, "4200"});
|
||||
jarAsFile = this.makeTmpJarWithManifest("BuildInfoTest-", ".jar", new String[] {
|
||||
BuildInfoTest.MF_ATTR_NAME_VERSION, "1.2.42", BuildInfoTest.MF_ATTR_NAME_BUILD, "4200" });
|
||||
|
||||
final BuildInfo info = new BuildInfo(jarAsFile.getAbsolutePath());
|
||||
|
||||
final String actualVersion = info.getVersion();
|
||||
assertEquals(actualVersion, "1.2.42", "versions match");
|
||||
Assert.assertEquals(actualVersion, "1.2.42", "versions match");
|
||||
|
||||
final String actualBuildID = info.getBuildID();
|
||||
assertEquals(actualBuildID, "4200", "build IDs match");
|
||||
Assert.assertEquals(actualBuildID, "4200", "build IDs match");
|
||||
|
||||
} finally {
|
||||
assertTrue(jarAsFile.delete(), "attempting to delete temporary jar file");
|
||||
Assert.assertTrue(jarAsFile.delete(), "attempting to delete temporary jar file");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test BuildInfo with one mock forge jar placed in the class path.
|
||||
* @throws IOException indirectly
|
||||
*
|
||||
* @throws IOException
|
||||
* indirectly
|
||||
*/
|
||||
@Test
|
||||
public final void test_BuildInfo_oneJarInCP() throws IOException { // NOPMD by Braids on 8/12/11 10:26 AM
|
||||
final String origClassPath = System.getProperty(JAVA_CLASS_PATH);
|
||||
public final void test_BuildInfo_oneJarInCP() throws IOException { // NOPMD
|
||||
// by
|
||||
// Braids
|
||||
// on
|
||||
// 8/12/11
|
||||
// 10:26
|
||||
// AM
|
||||
final String origClassPath = System.getProperty(BuildInfoTest.JAVA_CLASS_PATH);
|
||||
File jarAsFile = null;
|
||||
|
||||
try {
|
||||
jarAsFile = makeTmpJarWithManifest("forge-BuildInfoTest-", "-with-dependencies.jar",
|
||||
new String[] {MF_ATTR_NAME_VERSION, "1.2.43", MF_ATTR_NAME_BUILD, "4201"});
|
||||
jarAsFile = this.makeTmpJarWithManifest("forge-BuildInfoTest-", "-with-dependencies.jar", new String[] {
|
||||
BuildInfoTest.MF_ATTR_NAME_VERSION, "1.2.43", BuildInfoTest.MF_ATTR_NAME_BUILD, "4201" });
|
||||
|
||||
System.setProperty(JAVA_CLASS_PATH,
|
||||
System.setProperty(BuildInfoTest.JAVA_CLASS_PATH,
|
||||
jarAsFile.getAbsolutePath() + System.getProperty("path.separator") + origClassPath);
|
||||
|
||||
|
||||
final BuildInfo info = new BuildInfo();
|
||||
|
||||
final String actualVersion = info.getVersion();
|
||||
assertEquals(actualVersion, "1.2.43", "versions match");
|
||||
Assert.assertEquals(actualVersion, "1.2.43", "versions match");
|
||||
|
||||
final String actualBuildID = info.getBuildID();
|
||||
assertEquals(actualBuildID, "4201", "build IDs match");
|
||||
Assert.assertEquals(actualBuildID, "4201", "build IDs match");
|
||||
|
||||
} finally {
|
||||
assertTrue(jarAsFile.delete(), "attempting to delete temporary jar file");
|
||||
System.setProperty(JAVA_CLASS_PATH, origClassPath);
|
||||
Assert.assertTrue(jarAsFile.delete(), "attempting to delete temporary jar file");
|
||||
System.setProperty(BuildInfoTest.JAVA_CLASS_PATH, origClassPath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test BuildInfo with two mock forge jars placed in the class path; this
|
||||
* is an error condition.
|
||||
* Test BuildInfo with two mock forge jars placed in the class path; this is
|
||||
* an error condition.
|
||||
*
|
||||
* @throws IOException indirectly
|
||||
* @throws IOException
|
||||
* indirectly
|
||||
*/
|
||||
@Test
|
||||
public final void test_BuildInfo_twoJarsInCP() throws IOException { // NOPMD by Braids on 8/12/11 10:26 AM
|
||||
final String origClassPath = System.getProperty(JAVA_CLASS_PATH);
|
||||
public final void test_BuildInfo_twoJarsInCP() throws IOException { // NOPMD
|
||||
// by
|
||||
// Braids
|
||||
// on
|
||||
// 8/12/11
|
||||
// 10:26
|
||||
// AM
|
||||
final String origClassPath = System.getProperty(BuildInfoTest.JAVA_CLASS_PATH);
|
||||
File jarAsFile1 = null;
|
||||
File jarAsFile2 = null;
|
||||
|
||||
try {
|
||||
jarAsFile1 = makeTmpJarWithManifest("forge-BuildInfoTest-1-", "-with-dependencies.jar",
|
||||
new String[] {MF_ATTR_NAME_VERSION, "1.1.1", MF_ATTR_NAME_BUILD, "1111"});
|
||||
jarAsFile1 = this.makeTmpJarWithManifest("forge-BuildInfoTest-1-", "-with-dependencies.jar", new String[] {
|
||||
BuildInfoTest.MF_ATTR_NAME_VERSION, "1.1.1", BuildInfoTest.MF_ATTR_NAME_BUILD, "1111" });
|
||||
|
||||
jarAsFile2 = makeTmpJarWithManifest("forge-BuildInfoTest-2-", "-with-dependencies.jar",
|
||||
new String[] {MF_ATTR_NAME_VERSION, "2.2.2", MF_ATTR_NAME_BUILD, "2222"});
|
||||
jarAsFile2 = this.makeTmpJarWithManifest("forge-BuildInfoTest-2-", "-with-dependencies.jar", new String[] {
|
||||
BuildInfoTest.MF_ATTR_NAME_VERSION, "2.2.2", BuildInfoTest.MF_ATTR_NAME_BUILD, "2222" });
|
||||
|
||||
final String pathSep = System.getProperty("path.separator");
|
||||
|
||||
System.setProperty(JAVA_CLASS_PATH,
|
||||
jarAsFile1.getAbsolutePath() + pathSep
|
||||
+ jarAsFile2.getAbsolutePath() + pathSep
|
||||
+ origClassPath);
|
||||
System.setProperty(BuildInfoTest.JAVA_CLASS_PATH,
|
||||
jarAsFile1.getAbsolutePath() + pathSep + jarAsFile2.getAbsolutePath() + pathSep + origClassPath);
|
||||
|
||||
final BuildInfo info = new BuildInfo();
|
||||
|
||||
assertThrowsException(MultipleForgeJarsFoundError.class,
|
||||
new ClumsyRunnable() {
|
||||
public void run() throws Exception { // NOPMD by Braids on 8/12/11 10:29 AM
|
||||
BraidsAssertFunctions.assertThrowsException(MultipleForgeJarsFoundError.class, new ClumsyRunnable() {
|
||||
@Override
|
||||
public void run() throws Exception { // NOPMD by Braids on
|
||||
// 8/12/11 10:29 AM
|
||||
info.getBuildID();
|
||||
}
|
||||
});
|
||||
|
||||
} finally {
|
||||
assertTrue(jarAsFile1.delete(), "attempting to delete 1st temporary jar");
|
||||
assertTrue(jarAsFile2.delete(), "attempting to delete 2nd temporary jar");
|
||||
System.setProperty(JAVA_CLASS_PATH, origClassPath);
|
||||
Assert.assertTrue(jarAsFile1.delete(), "attempting to delete 1st temporary jar");
|
||||
Assert.assertTrue(jarAsFile2.delete(), "attempting to delete 2nd temporary jar");
|
||||
System.setProperty(BuildInfoTest.JAVA_CLASS_PATH, origClassPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to create jar files at specific locations with specific
|
||||
* name-value pairs in their manifests.
|
||||
*
|
||||
* @param jarLocation where to create the jar file
|
||||
* @param nameValuePairs has the form {"name1", "value1", "name2", "value2", ...}
|
||||
* @param jarLocation
|
||||
* where to create the jar file
|
||||
* @param nameValuePairs
|
||||
* has the form {"name1", "value1", "name2", "value2", ...}
|
||||
*/
|
||||
private File makeTmpJarWithManifest(final String fileNamePrefix, final String fileNameSuffix,
|
||||
final String[] nameValuePairs)
|
||||
throws IOException {
|
||||
if (nameValuePairs.length % 2 != 0) {
|
||||
final String[] nameValuePairs) throws IOException {
|
||||
if ((nameValuePairs.length % 2) != 0) {
|
||||
throw new IllegalArgumentException("nameValuePairs must contain an even number of elements.");
|
||||
}
|
||||
|
||||
@@ -149,16 +177,16 @@ public class BuildInfoTest {
|
||||
final ZipEntry zipEntry = new ZipEntry("META-INF/MANIFEST.MF");
|
||||
zipOut.putNextEntry(zipEntry);
|
||||
|
||||
zipOut.write(toASCII("Manifest-Version: 1.3\n"));
|
||||
zipOut.write(this.toASCII("Manifest-Version: 1.3\n"));
|
||||
|
||||
for (int ix = 0; ix < nameValuePairs.length; ix += 2) {
|
||||
zipOut.write(toASCII(nameValuePairs[ix]));
|
||||
zipOut.write(toASCII(": "));
|
||||
zipOut.write(toASCII(nameValuePairs[ix + 1]));
|
||||
zipOut.write(toASCII("\n"));
|
||||
zipOut.write(this.toASCII(nameValuePairs[ix]));
|
||||
zipOut.write(this.toASCII(": "));
|
||||
zipOut.write(this.toASCII(nameValuePairs[ix + 1]));
|
||||
zipOut.write(this.toASCII("\n"));
|
||||
}
|
||||
|
||||
zipOut.write(toASCII("\n"));
|
||||
zipOut.write(this.toASCII("\n"));
|
||||
|
||||
zipOut.closeEntry();
|
||||
} finally {
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
package forge.model;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -19,17 +15,17 @@ import forge.properties.ForgePreferences;
|
||||
*/
|
||||
public class FModelTest {
|
||||
|
||||
|
||||
private FModel model;
|
||||
|
||||
/**
|
||||
* Set up before each test, creating a default model.
|
||||
*
|
||||
* @throws FileNotFoundException indirectly
|
||||
* @throws FileNotFoundException
|
||||
* indirectly
|
||||
*/
|
||||
@BeforeTest
|
||||
public final void setUp() throws FileNotFoundException {
|
||||
model = new FModel(null);
|
||||
this.model = new FModel(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,63 +33,81 @@ public class FModelTest {
|
||||
*/
|
||||
@AfterTest
|
||||
public final void tearDown() {
|
||||
if (model != null) {
|
||||
if (this.model != null) {
|
||||
try {
|
||||
model.close();
|
||||
}
|
||||
catch (Throwable ignored) {
|
||||
this.model.close();
|
||||
} catch (final Throwable ignored) {
|
||||
// ignore exceptions during close.
|
||||
}
|
||||
}
|
||||
|
||||
model = null;
|
||||
this.model = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test constructor (via setUp), close, and construct again.
|
||||
* @throws FileNotFoundException if something is really wrong
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
* if something is really wrong
|
||||
*/
|
||||
@Test
|
||||
public final void test_ctor_close_ctor() throws FileNotFoundException { // NOPMD by Braids on 8/12/11 10:36 AM
|
||||
assertNotNull(model, "model is not null");
|
||||
model.close();
|
||||
public final void test_ctor_close_ctor() throws FileNotFoundException { // NOPMD
|
||||
// by
|
||||
// Braids
|
||||
// on
|
||||
// 8/12/11
|
||||
// 10:36
|
||||
// AM
|
||||
Assert.assertNotNull(this.model, "model is not null");
|
||||
this.model.close();
|
||||
|
||||
System.err.println("log test"); // NOPMD by Braids on 8/12/11 10:36 AM
|
||||
|
||||
model = new FModel(null);
|
||||
assertNotNull(model, "model is not null");
|
||||
this.model = new FModel(null);
|
||||
Assert.assertNotNull(this.model, "model is not null");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getVersion.
|
||||
* @throws FileNotFoundException if something is really wrong
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
* if something is really wrong
|
||||
*/
|
||||
@Test
|
||||
public final void test_getVersion() throws FileNotFoundException {
|
||||
final String version = model.getBuildInfo().getVersion();
|
||||
final String version = this.model.getBuildInfo().getVersion();
|
||||
|
||||
assertEquals(version, "SVN", "version is default");
|
||||
Assert.assertEquals(version, "SVN", "version is default");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getBuildID.
|
||||
* @throws FileNotFoundException if something is really wrong
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
* if something is really wrong
|
||||
*/
|
||||
@Test
|
||||
public final void test_getBuildID() throws FileNotFoundException { // NOPMD by Braids on 8/12/11 10:36 AM
|
||||
public final void test_getBuildID() throws FileNotFoundException { // NOPMD
|
||||
// by
|
||||
// Braids
|
||||
// on
|
||||
// 8/12/11
|
||||
// 10:36
|
||||
// AM
|
||||
// Just test for an unexpected exception.
|
||||
model.getBuildInfo().getBuildID();
|
||||
this.model.getBuildInfo().getBuildID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getPreferences.
|
||||
* @throws FileNotFoundException indirectly
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
* indirectly
|
||||
*/
|
||||
@Test
|
||||
public final void test_getPreferences() throws FileNotFoundException {
|
||||
ForgePreferences prefs = model.getPreferences();
|
||||
assertNotNull(prefs, "prefs instance is not null");
|
||||
final ForgePreferences prefs = this.model.getPreferences();
|
||||
Assert.assertNotNull(prefs, "prefs instance is not null");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,17 +115,16 @@ public class FModelTest {
|
||||
*/
|
||||
@Test
|
||||
public final void test_resetGameState_getGameState() {
|
||||
Singletons.setModel(model);
|
||||
assertNull(model.getGameState(), "game state has not yet been initialized");
|
||||
Singletons.setModel(this.model);
|
||||
Assert.assertNull(this.model.getGameState(), "game state has not yet been initialized");
|
||||
|
||||
FGameState state1 = model.resetGameState();
|
||||
assertNotNull(state1, "first state is OK");
|
||||
final FGameState state1 = this.model.resetGameState();
|
||||
Assert.assertNotNull(state1, "first state is OK");
|
||||
|
||||
FGameState state2 = model.resetGameState();
|
||||
assertNotNull(state1, "first state is OK");
|
||||
assertNotEquals(state1, state2, "first and second states are different");
|
||||
final FGameState state2 = this.model.resetGameState();
|
||||
Assert.assertNotNull(state1, "first state is OK");
|
||||
Assert.assertNotEquals(state1, state2, "first and second states are different");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,31 +9,30 @@ import org.testng.Assert;
|
||||
*/
|
||||
public final class BraidsAssertFunctions {
|
||||
|
||||
/** Do not instantiate.*/
|
||||
/** Do not instantiate. */
|
||||
private BraidsAssertFunctions() {
|
||||
//empty
|
||||
// empty
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that a function (ClumsyRunnable) throws the given exception, or
|
||||
* a subclass of it.
|
||||
* Assert that a function (ClumsyRunnable) throws the given exception, or a
|
||||
* subclass of it.
|
||||
*
|
||||
* @param exnClass the exception we expect
|
||||
* @param withScissors the code to run
|
||||
* @param exnClass
|
||||
* the exception we expect
|
||||
* @param withScissors
|
||||
* the code to run
|
||||
*/
|
||||
public static void assertThrowsException(
|
||||
@SuppressWarnings("rawtypes") final Class exnClass,
|
||||
public static void assertThrowsException(@SuppressWarnings("rawtypes") final Class exnClass,
|
||||
final ClumsyRunnable withScissors) {
|
||||
try {
|
||||
withScissors.run();
|
||||
}
|
||||
catch (Exception exn) {
|
||||
} catch (final Exception exn) {
|
||||
if (!exnClass.isInstance(exn)) {
|
||||
Assert.fail("caught exception " + exn.getClass().getName()
|
||||
+ ", but expected " + exnClass.getName());
|
||||
Assert.fail("caught exception " + exn.getClass().getName() + ", but expected " + exnClass.getName());
|
||||
}
|
||||
|
||||
return; //success
|
||||
return; // success
|
||||
}
|
||||
|
||||
Assert.fail("expected exception " + exnClass.getName() + ", but none was thrown");
|
||||
|
||||
Reference in New Issue
Block a user