aboutsummaryrefslogtreecommitdiffstats
path: root/test/eu/equalparts/cardbase
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2015-11-04 18:26:04 +0100
committerEduardo Pedroni <e.pedroni91@gmail.com>2015-11-04 18:26:04 +0100
commit5f5b12862f467be85b51b08bd8744e8288e41b9f (patch)
tree3da1f9e7bc7dec5948c440644afdffb73ee5d42f /test/eu/equalparts/cardbase
parentad02b9ff8050ba026d446963e3862a4baaf671be (diff)
Finished perusal tests, wrote happy path remove tests but still not passing
Diffstat (limited to 'test/eu/equalparts/cardbase')
-rw-r--r--test/eu/equalparts/cardbase/cli/CardbaseCLITest.java143
-rw-r--r--test/eu/equalparts/cardbase/cli/specificCardPerusal7
2 files changed, 147 insertions, 3 deletions
diff --git a/test/eu/equalparts/cardbase/cli/CardbaseCLITest.java b/test/eu/equalparts/cardbase/cli/CardbaseCLITest.java
index 528362e..7332c3b 100644
--- a/test/eu/equalparts/cardbase/cli/CardbaseCLITest.java
+++ b/test/eu/equalparts/cardbase/cli/CardbaseCLITest.java
@@ -19,6 +19,7 @@ import org.junit.rules.TemporaryFolder;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.equalparts.cardbase.cards.Card;
+import eu.equalparts.cardbase.cards.FullCardSet;
import eu.equalparts.cardbase.utils.MTGUniverse;
public class CardbaseCLITest {
@@ -535,17 +536,153 @@ public class CardbaseCLITest {
}
}
- /***********************************************************************************
- * undo() tests, happy path
- ***********************************************************************************/
+ @Test
+ public void specificPerusalWithValidArgumentIsPrinted() throws Exception {
+ uut = new CardbaseCLI(getClass().getResource("/testbase.cb").getFile());
+ // dummy set just so the uut knows the set to peruse from
+ FullCardSet fcs = new FullCardSet();
+ fcs.code = "FRF";
+ uut.selectedSet = fcs;
+
+ try {
+ System.setOut(new PrintStream(testOutput));
+ uut.peruse("129");
+ } finally {
+ System.setOut(console);
+ }
+
+ try (Scanner scanner = new Scanner(getClass().getResourceAsStream("specificCardPerusal"))) {
+ assertEquals(scanner.useDelimiter("\\Z").next() + EOL, testOutput.toString());
+ }
+ }
+
+ /*
+ * Edge cases
+ */
+ @Test
+ public void specificPerusalWithInvalidArgument() throws Exception {
+ uut = new CardbaseCLI(getClass().getResource("/testbase.cb").getFile());
+ // dummy set just so the uut knows the set to peruse from
+ FullCardSet fcs = new FullCardSet();
+ fcs.code = "FRF";
+ uut.selectedSet = fcs;
+
+ try {
+ System.setOut(new PrintStream(testOutput));
+ uut.peruse("100");
+ } finally {
+ System.setOut(console);
+ }
+
+ assertEquals("Card not in cardbase." + EOL, testOutput.toString());
+ }
+
+ @Test
+ public void specificPerusalWithNoSelectedSet() throws Exception {
+ uut = new CardbaseCLI(getClass().getResource("/testbase.cb").getFile());
+ uut.selectedSet = null;
+
+ try {
+ System.setOut(new PrintStream(testOutput));
+ uut.peruse("100");
+ } finally {
+ System.setOut(console);
+ }
+
+ assertEquals("Please select a set before perusing a specific card." + EOL, testOutput.toString());
+ }
/***********************************************************************************
* remove() tests, happy path
***********************************************************************************/
+ @Test
+ public void removeValidAmountOfExistingCard() throws Exception {
+ uut = new CardbaseCLI(getClass().getResource("/testbase.cb").getFile());
+ // dummy set just so the uut knows the set to peruse from
+ FullCardSet fcs = new FullCardSet();
+ fcs.code = "FRF";
+ uut.selectedSet = fcs;
+
+ uut.remove("129", "3");
+
+ assertEquals("Wrong number of cards was removed.", uut.cardbase.getCard("FRF", "129").count, new Integer(6));
+ }
+
+ @Test
+ public void removeExceedingAmountOfExistingCard() throws Exception {
+ uut = new CardbaseCLI(getClass().getResource("/testbase.cb").getFile());
+ // dummy set just so the uut knows the set to peruse from
+ FullCardSet fcs = new FullCardSet();
+ fcs.code = "FRF";
+ uut.selectedSet = fcs;
+
+ uut.remove("128", "3");
+
+ assertNull("Card was not removed successfully.", uut.cardbase.getCard("FRF", "128"));
+ }
+
+ @Test
+ public void removeExactAmountOfExistingCard() throws Exception {
+ uut = new CardbaseCLI(getClass().getResource("/testbase.cb").getFile());
+ // dummy set just so the uut knows the set to peruse from
+ FullCardSet fcs = new FullCardSet();
+ fcs.code = "FRF";
+ uut.selectedSet = fcs;
+
+ uut.remove("128", "1");
+
+ assertNull("Card was not removed successfully.", uut.cardbase.getCard("FRF", "128"));
+ }
+
+ @Test
+ public void removeSingleExistingCardWithoutAmount() throws Exception {
+ uut = new CardbaseCLI(getClass().getResource("/testbase.cb").getFile());
+ // dummy set just so the uut knows the set to peruse from
+ FullCardSet fcs = new FullCardSet();
+ fcs.code = "FRF";
+ uut.selectedSet = fcs;
+
+ uut.remove("128");
+
+ assertNull("Card was not removed successfully.", uut.cardbase.getCard("FRF", "128"));
+ }
+
+ @Test
+ public void removeMultipleExistingCardWithoutAmount() throws Exception {
+ uut = new CardbaseCLI(getClass().getResource("/testbase.cb").getFile());
+ // dummy set just so the uut knows the set to peruse from
+ FullCardSet fcs = new FullCardSet();
+ fcs.code = "FRF";
+ uut.selectedSet = fcs;
+
+ uut.remove("129");
+
+ assertNull("Card was not removed successfully.", uut.cardbase.getCard("FRF", "129"));
+ }
+
+ /*
+ * Edge cases
+ */
+ // attempt to remove nonexistent card without amount
+
+ // attempt to remove nonexistent card with amount
+
+ // remove 0 of existing card
+
+ // remove negative number of existing card
+
+ // remove card without selected set
+
/***********************************************************************************
* add() tests, happy path
***********************************************************************************/
+
+
+ /***********************************************************************************
+ * undo() tests, happy path
+ ***********************************************************************************/
+
}
diff --git a/test/eu/equalparts/cardbase/cli/specificCardPerusal b/test/eu/equalparts/cardbase/cli/specificCardPerusal
new file mode 100644
index 0000000..a1f6548
--- /dev/null
+++ b/test/eu/equalparts/cardbase/cli/specificCardPerusal
@@ -0,0 +1,7 @@
+8 Formless Nurturing (FRF, 129)
+ Sorcery
+ Cost: {3}{G}
+ Manifest the top card of your library, then put a +1/+1 counter on it. (To manifest a card, put it onto the battlefield face down as a 2/2 creature. Turn it face up any time for its mana cost if it's a creature card.)
+ Common
+ MID: 391837
+ Illus. Cliff Childs \ No newline at end of file