diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2015-07-13 11:04:56 +0200 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2015-07-13 11:04:56 +0200 |
commit | 72fef1f9bcac0c980bfae6dde53358d9cba12901 (patch) | |
tree | 266a5fffb35666c7facfe0775a0053148dd98a5f /test | |
parent | 19183986d37c5ca1a31a5b308bace92b87430ffe (diff) |
Cleaned up a bit, finished sort tests, refactored cardbase adding and removing, need to write tests urgently
Diffstat (limited to 'test')
-rw-r--r-- | test/Testest.java | 2 | ||||
-rw-r--r-- | test/eu/equalparts/test/cardbase/CardbaseSortTest.java | 80 | ||||
-rw-r--r-- | test/eu/equalparts/test/cardbase/testbase.cb | 1 | ||||
-rw-r--r-- | test/eu/equalparts/test/cardbase/testcards.json | 2 |
4 files changed, 77 insertions, 8 deletions
diff --git a/test/Testest.java b/test/Testest.java index 855568d..e7ca872 100644 --- a/test/Testest.java +++ b/test/Testest.java @@ -1,12 +1,10 @@ import java.io.File; import java.io.IOException; import java.net.MalformedURLException; -import java.util.List; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; -import eu.equalparts.cardbase.Cardbase; import eu.equalparts.cardbase.cards.Card; import eu.equalparts.cardbase.decks.StandaloneDeck; import eu.equalparts.cardbase.utils.JSON; diff --git a/test/eu/equalparts/test/cardbase/CardbaseSortTest.java b/test/eu/equalparts/test/cardbase/CardbaseSortTest.java index 81cb6ef..eca41f0 100644 --- a/test/eu/equalparts/test/cardbase/CardbaseSortTest.java +++ b/test/eu/equalparts/test/cardbase/CardbaseSortTest.java @@ -40,7 +40,7 @@ public class CardbaseSortTest { public void setUp() throws Exception { cardbase = new Cardbase(); for (Card card : testCards) { - cardbase.addCard(card, 1); + cardbase.addCard(card); } } @@ -304,9 +304,29 @@ public class CardbaseSortTest { @Test public void test_sortByImageName() throws Exception { - Collection<Card> sortedCards = cardbase.sort("number"); + Collection<Card> sortedCards = cardbase.sort("imageName"); 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.imageName + " should have been " + names[i] + ", i = " + i, card.imageName.equals(names[i])); + i++; + } + } + + @Test + public void test_sortByWatermark() throws Exception { + Collection<Card> sortedCards = cardbase.sort("watermark"); + int i = 0; + String[] watermarks = { "", "", "", @@ -314,11 +334,63 @@ public class CardbaseSortTest { "", "", "", - "", + "Dimir", }; for (Card card : sortedCards) { - assertTrue(card.imageName + " should have been " + names[i] + ", i = " + i, card.imageName.equals(names[i])); + String watermark = card.watermark != null ? card.watermark : ""; + assertTrue(watermark + " should have been " + watermarks[i] + ", i = " + i, watermark.equals(watermarks[i])); i++; } } + + @Test + public void test_sortBySetCode() throws Exception { + Collection<Card> sortedCards = cardbase.sort("setCode"); + int i = 0; + String[] sets = { + "BOK", + "BOK", + "FRF", + "GTC", + "M12", + "M15", + "M15", + "ROE", + }; + for (Card card : sortedCards) { + assertTrue(card.setCode + " should have been " + sets[i] + ", i = " + i, card.setCode.equals(sets[i])); + i++; + } + } + + public void test_sortByImageCode() throws Exception { + Collection<Card> sortedCards = cardbase.sort("imageCode"); + int i = 0; + String[] codes = { + "bok", + "bok", + "frf", + "gtc", + "m12", + "m15", + "m15", + "roe", + }; + for (Card card : sortedCards) { + assertTrue(card.imageCode + " should have been " + codes[i] + ", i = " + i, card.imageCode.equals(codes[i])); + i++; + } + } + + @Test + public void test_sortByCount() throws Exception { + Collection<Card> sortedCards = cardbase.sort("count"); + int i = 0; + Integer[] counts = {1, 1, 1, 1, 2, 3, 8, 15 }; + for (Card card : sortedCards) { + assertTrue(card.count + " should have been " + counts[i] + ", i = " + i, card.count.equals(counts[i])); + i++; + } + } + } diff --git a/test/eu/equalparts/test/cardbase/testbase.cb b/test/eu/equalparts/test/cardbase/testbase.cb deleted file mode 100644 index 89b3bfb..0000000 --- a/test/eu/equalparts/test/cardbase/testbase.cb +++ /dev/null @@ -1 +0,0 @@ -{"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 index 71c8683..cccd8a4 100644 --- a/test/eu/equalparts/test/cardbase/testcards.json +++ b/test/eu/equalparts/test/cardbase/testcards.json @@ -1 +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 +[{"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},{"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":2},{"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":3},{"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":8},{"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},{"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":15},{"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},{"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}] |