aboutsummaryrefslogtreecommitdiffstats
path: root/test/eu
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2015-06-24 18:58:15 +0200
committerEduardo Pedroni <e.pedroni91@gmail.com>2015-06-24 18:58:15 +0200
commitbf29c3d96160eeaa64f60a512a0a9f4d7c85167a (patch)
treed748a0fa4016c188b3d4be5bdd719261b40655b0 /test/eu
parent59174889aba82c64ae63e0a5622d6cbcab63dc39 (diff)
Mulling over the generic comparator issue
Diffstat (limited to 'test/eu')
-rw-r--r--test/eu/equalparts/test/cardbase/CardbaseSortTest.java169
-rw-r--r--test/eu/equalparts/test/cardbase/testbase.cb1
-rw-r--r--test/eu/equalparts/test/cardbase/testcards.json1
-rw-r--r--test/eu/equalparts/test/ui/CardbaseCLITest.java (renamed from test/eu/equalparts/test/ui/CLITest.java)2
4 files changed, 172 insertions, 1 deletions
diff --git a/test/eu/equalparts/test/cardbase/CardbaseSortTest.java b/test/eu/equalparts/test/cardbase/CardbaseSortTest.java
new file mode 100644
index 0000000..261451a
--- /dev/null
+++ b/test/eu/equalparts/test/cardbase/CardbaseSortTest.java
@@ -0,0 +1,169 @@
+package eu.equalparts.test.cardbase;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+
+import eu.equalparts.cardbase.Cardbase;
+import eu.equalparts.cardbase.data.Card;
+import eu.equalparts.cardbase.utils.JSON;
+
+/**
+ * Tests the sorting functionality.
+ *
+ * @author Eduardo Pedroni
+ *
+ */
+public class CardbaseSortTest {
+
+ private Cardbase cardbase;
+ private static List<Card> testCards;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ testCards = JSON.mapper.readValue(CardbaseSortTest.class.getResourceAsStream("testcards.json"), new TypeReference<List<Card>>() {});
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ cardbase = new Cardbase();
+ for (Card card : testCards) {
+ cardbase.addCard(card, 1);
+ }
+ }
+
+ @Test
+ public void test_sortByName() throws Exception {
+
+ Collection<Card> sortedCards = cardbase.sort("name");
+
+ int i = 0;
+ String[] names = {"Callow Jushi",
+ "Coerced Confession",
+ "Disrupting Shoal",
+ "Khalni Hydra",
+ "Nightmare",
+ "Shivan Dragon",
+ "Sorin Markov",
+ "Ugin's Construct" };
+
+ for (Card card : sortedCards) {
+ assertTrue(card.name + " should have been " + names[i] + ", i = " + i, card.name.equals(names[i]));
+ i++;
+ }
+ }
+
+ @Test
+ public void test_sortByLayout() throws Exception {
+
+ Collection<Card> sortedCards = cardbase.sort("layout");
+
+ int i = 0;
+ String[] layouts = {"flip",
+ "normal",
+ "normal",
+ "normal",
+ "normal",
+ "normal",
+ "normal",
+ "normal" };
+
+ for (Card card : sortedCards) {
+ assertTrue(card.layout + " should have been " + layouts[i] + ", i = " + i, card.layout.equals(layouts[i]));
+ i++;
+ }
+ }
+
+ @Test
+ public void test_sortByManaCost() throws Exception {
+
+
+
+// Collection<Card> sortedCards = cardbase.sort("name");
+//
+// int i = 0;
+// String[] layouts = {"flip",
+// "normal",
+// "normal",
+// "normal",
+// "normal",
+// "normal",
+// "normal",
+// "normal" };
+//
+// for (Card card : sortedCards) {
+// assertTrue(card.layout + " should have been " + layouts[i] + ", i = " + i, card.layout.equals(layouts[i]));
+// i++;
+// }
+ fail("todo");
+ }
+
+ @Test
+ public void test_sortByCMC() throws Exception {
+
+ Collection<Card> sortedCards = cardbase.sort("cmc");
+
+ int i = 0;
+ Integer[] cmcs = {2, 3, 4, 5, 6, 6, 6, 8};
+
+ for (Card card : sortedCards) {
+ assertTrue(card.cmc + " should have been " + cmcs[i] + ", i = " + i, card.cmc.equals(cmcs[i]));
+ i++;
+ }
+ }
+
+ @Test
+ public void test_sortByType() throws Exception {
+
+ Collection<Card> sortedCards = cardbase.sort("type");
+
+ int i = 0;
+ String[] types = {"Artifact Creature — Construct",
+ "Creature — Dragon",
+ "Creature — Human Wizard",
+ "Creature — Hydra",
+ "Creature — Nightmare Horse",
+ "Instant — Arcane",
+ "Planeswalker — Sorin",
+ "Sorcery"};
+
+ for (Card card : sortedCards) {
+ assertTrue(card.type + " should have been " + types[i] + ", i = " + i, card.type.equals(types[i]));
+ i++;
+ }
+ }
+
+ @Test
+ public void test_sortByRarity() throws Exception {
+
+ Collection<Card> sortedCards = cardbase.sort("rarity");
+
+ int i = 0;
+ String[] rarities = {"Uncommon",
+ "Uncommon",
+ "Uncommon",
+ "Rare",
+ "Rare",
+ "Rare",
+ "Mythic Rare",
+ "Mythic Rare"};
+
+ for (Card card : sortedCards) {
+ assertTrue(card.rarity + " should have been " + rarities[i] + ", i = " + i, card.rarity.equals(rarities[i]));
+ i++;
+ }
+ }
+}
diff --git a/test/eu/equalparts/test/cardbase/testbase.cb b/test/eu/equalparts/test/cardbase/testbase.cb
new file mode 100644
index 0000000..89b3bfb
--- /dev/null
+++ b/test/eu/equalparts/test/cardbase/testbase.cb
@@ -0,0 +1 @@
+{"M15276":{"name":"Nightmare","layout":"normal","manaCost":"{5}{B}","cmc":6,"type":"Creature — Nightmare Horse","rarity":"Rare","text":"Flying (This creature can't be blocked except by creatures with flying or reach.)\nNightmare's power and toughness are each equal to the number of Swamps you control.","flavor":"The thunder of its hooves beats dreams into despair.","artist":"Vance Kovacs","number":"276","power":"*","toughness":"*","loyalty":null,"multiverseid":383168,"imageName":"nightmare","border":null,"watermark":null,"setCode":"M15","imageCode":"m15","count":1},"FRF164":{"name":"Ugin's Construct","layout":"normal","manaCost":"{4}","cmc":4,"type":"Artifact Creature — Construct","rarity":"Uncommon","text":"When Ugin's Construct enters the battlefield, sacrifice a permanent that's one or more colors.","flavor":"While trapping the Eldrazi on Zendikar, Ugin learned little from Sorin, but he gleaned the rudiments of lithomancy from Nahiri.","artist":"Peter Mohrbacher","number":"164","power":"4","toughness":"5","loyalty":null,"multiverseid":391949,"imageName":"ugin's construct","border":null,"watermark":null,"setCode":"FRF","imageCode":"frf","count":1},"M12109":{"name":"Sorin Markov","layout":"normal","manaCost":"{3}{B}{B}{B}","cmc":6,"type":"Planeswalker — Sorin","rarity":"Mythic Rare","text":"+2: Sorin Markov deals 2 damage to target creature or player and you gain 2 life.\n−3: Target opponent's life total becomes 10.\n−7: You control target player during that player's next turn.","flavor":null,"artist":"Michael Komarck","number":"109","power":null,"toughness":null,"loyalty":4,"multiverseid":238330,"imageName":"sorin markov","border":null,"watermark":null,"setCode":"M12","imageCode":"m12","count":1},"ROE192":{"name":"Khalni Hydra","layout":"normal","manaCost":"{G}{G}{G}{G}{G}{G}{G}{G}","cmc":8,"type":"Creature — Hydra","rarity":"Mythic Rare","text":"Khalni Hydra costs {G} less to cast for each green creature you control.\nTrample","flavor":"\"In ages past, bargains were struck and promises were made. Now we must collect on our debt. Begin the hymns.\"\n—Moruul, Khalni druid","artist":"Todd Lockwood","number":"192","power":"8","toughness":"8","loyalty":null,"multiverseid":193551,"imageName":"khalni hydra","border":null,"watermark":null,"setCode":"ROE","imageCode":"roe","count":1},"BOK33":{"name":"Disrupting Shoal","layout":"normal","manaCost":"{X}{U}{U}","cmc":2,"type":"Instant — Arcane","rarity":"Rare","text":"You may exile a blue card with converted mana cost X from your hand rather than pay Disrupting Shoal's mana cost.\nCounter target spell if its converted mana cost is X.","flavor":null,"artist":"Scott M. Fischer","number":"33","power":null,"toughness":null,"loyalty":null,"multiverseid":74128,"imageName":"disrupting shoal","border":null,"watermark":null,"setCode":"BOK","imageCode":"bok","count":1},"M15281":{"name":"Shivan Dragon","layout":"normal","manaCost":"{4}{R}{R}","cmc":6,"type":"Creature — Dragon","rarity":"Rare","text":"Flying (This creature can't be blocked except by creatures with flying or reach.)\n{R}: Shivan Dragon gets +1/+0 until end of turn.","flavor":"The undisputed master of the mountains of Shiv.","artist":"Donato Giancola","number":"281","power":"5","toughness":"5","loyalty":null,"multiverseid":383172,"imageName":"shivan dragon","border":null,"watermark":null,"setCode":"M15","imageCode":"m15","count":1},"BOK31a":{"name":"Callow Jushi","layout":"flip","manaCost":"{1}{U}{U}","cmc":3,"type":"Creature — Human Wizard","rarity":"Uncommon","text":"Whenever you cast a Spirit or Arcane spell, you may put a ki counter on Callow Jushi.\nAt the beginning of the end step, if there are two or more ki counters on Callow Jushi, you may flip it.","flavor":null,"artist":"Tsutomu Kawade","number":"31a","power":"2","toughness":"2","loyalty":null,"multiverseid":74489,"imageName":"callow jushi","border":null,"watermark":null,"setCode":"BOK","imageCode":"bok","count":1},"GTC217":{"name":"Coerced Confession","layout":"normal","manaCost":"{4}{U/B}","cmc":5,"type":"Sorcery","rarity":"Uncommon","text":"Target player puts the top four cards of his or her library into his or her graveyard. You draw a card for each creature card put into that graveyard this way.","flavor":"\"Ask the right questions in the right way and truth is inevitable.\"\n—Lazav","artist":"Mathias Kollros","number":"217","power":null,"toughness":null,"loyalty":null,"multiverseid":366408,"imageName":"coerced confession","border":null,"watermark":"Dimir","setCode":"GTC","imageCode":"gtc","count":1}} \ No newline at end of file
diff --git a/test/eu/equalparts/test/cardbase/testcards.json b/test/eu/equalparts/test/cardbase/testcards.json
new file mode 100644
index 0000000..71c8683
--- /dev/null
+++ b/test/eu/equalparts/test/cardbase/testcards.json
@@ -0,0 +1 @@
+[{"name":"Callow Jushi","layout":"flip","manaCost":"{1}{U}{U}","cmc":3,"type":"Creature — Human Wizard","rarity":"Uncommon","text":"Whenever you cast a Spirit or Arcane spell, you may put a ki counter on Callow Jushi.\nAt the beginning of the end step, if there are two or more ki counters on Callow Jushi, you may flip it.","flavor":null,"artist":"Tsutomu Kawade","number":"31a","power":"2","toughness":"2","loyalty":null,"multiverseid":74489,"imageName":"callow jushi","border":null,"watermark":null,"setCode":"BOK","imageCode":"bok","count":null},{"name":"Coerced Confession","layout":"normal","manaCost":"{4}{U/B}","cmc":5,"type":"Sorcery","rarity":"Uncommon","text":"Target player puts the top four cards of his or her library into his or her graveyard. You draw a card for each creature card put into that graveyard this way.","flavor":"\"Ask the right questions in the right way and truth is inevitable.\"\n—Lazav","artist":"Mathias Kollros","number":"217","power":null,"toughness":null,"loyalty":null,"multiverseid":366408,"imageName":"coerced confession","border":null,"watermark":"Dimir","setCode":"GTC","imageCode":"gtc","count":null},{"name":"Khalni Hydra","layout":"normal","manaCost":"{G}{G}{G}{G}{G}{G}{G}{G}","cmc":8,"type":"Creature — Hydra","rarity":"Mythic Rare","text":"Khalni Hydra costs {G} less to cast for each green creature you control.\nTrample","flavor":"\"In ages past, bargains were struck and promises were made. Now we must collect on our debt. Begin the hymns.\"\n—Moruul, Khalni druid","artist":"Todd Lockwood","number":"192","power":"8","toughness":"8","loyalty":null,"multiverseid":193551,"imageName":"khalni hydra","border":null,"watermark":null,"setCode":"ROE","imageCode":"roe","count":null},{"name":"Nightmare","layout":"normal","manaCost":"{5}{B}","cmc":6,"type":"Creature — Nightmare Horse","rarity":"Rare","text":"Flying (This creature can't be blocked except by creatures with flying or reach.)\nNightmare's power and toughness are each equal to the number of Swamps you control.","flavor":"The thunder of its hooves beats dreams into despair.","artist":"Vance Kovacs","number":"276","power":"*","toughness":"*","loyalty":null,"multiverseid":383168,"imageName":"nightmare","border":null,"watermark":null,"setCode":"M15","imageCode":"m15","count":null},{"name":"Shivan Dragon","layout":"normal","manaCost":"{4}{R}{R}","cmc":6,"type":"Creature — Dragon","rarity":"Rare","text":"Flying (This creature can't be blocked except by creatures with flying or reach.)\n{R}: Shivan Dragon gets +1/+0 until end of turn.","flavor":"The undisputed master of the mountains of Shiv.","artist":"Donato Giancola","number":"281","power":"5","toughness":"5","loyalty":null,"multiverseid":383172,"imageName":"shivan dragon","border":null,"watermark":null,"setCode":"M15","imageCode":"m15","count":null},{"name":"Disrupting Shoal","layout":"normal","manaCost":"{X}{U}{U}","cmc":2,"type":"Instant — Arcane","rarity":"Rare","text":"You may exile a blue card with converted mana cost X from your hand rather than pay Disrupting Shoal's mana cost.\nCounter target spell if its converted mana cost is X.","flavor":null,"artist":"Scott M. Fischer","number":"33","power":null,"toughness":null,"loyalty":null,"multiverseid":74128,"imageName":"disrupting shoal","border":null,"watermark":null,"setCode":"BOK","imageCode":"bok","count":null},{"name":"Sorin Markov","layout":"normal","manaCost":"{3}{B}{B}{B}","cmc":6,"type":"Planeswalker — Sorin","rarity":"Mythic Rare","text":"+2: Sorin Markov deals 2 damage to target creature or player and you gain 2 life.\n−3: Target opponent's life total becomes 10.\n−7: You control target player during that player's next turn.","flavor":null,"artist":"Michael Komarck","number":"109","power":null,"toughness":null,"loyalty":4,"multiverseid":238330,"imageName":"sorin markov","border":null,"watermark":null,"setCode":"M12","imageCode":"m12","count":null},{"name":"Ugin's Construct","layout":"normal","manaCost":"{4}","cmc":4,"type":"Artifact Creature — Construct","rarity":"Uncommon","text":"When Ugin's Construct enters the battlefield, sacrifice a permanent that's one or more colors.","flavor":"While trapping the Eldrazi on Zendikar, Ugin learned little from Sorin, but he gleaned the rudiments of lithomancy from Nahiri.","artist":"Peter Mohrbacher","number":"164","power":"4","toughness":"5","loyalty":null,"multiverseid":391949,"imageName":"ugin's construct","border":null,"watermark":null,"setCode":"FRF","imageCode":"frf","count":null}] \ No newline at end of file
diff --git a/test/eu/equalparts/test/ui/CLITest.java b/test/eu/equalparts/test/ui/CardbaseCLITest.java
index 4a7ebac..ad81fb9 100644
--- a/test/eu/equalparts/test/ui/CLITest.java
+++ b/test/eu/equalparts/test/ui/CardbaseCLITest.java
@@ -8,7 +8,7 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-public class CLITest {
+public class CardbaseCLITest {
@BeforeClass
public static void setUpBeforeClass() throws Exception {