diff options
author | Eduardo Pedroni <e.pedroni91@gmail.com> | 2015-08-29 20:26:13 +0200 |
---|---|---|
committer | Eduardo Pedroni <e.pedroni91@gmail.com> | 2015-08-29 20:26:13 +0200 |
commit | 262e5c8fb03dff7546c8b47ead571ec71b468e88 (patch) | |
tree | 7972b261f1ec77aef09475803ab4467bde5652eb /test/eu/equalparts/cardbase/cli/CardbaseCLITest.java | |
parent | 59306d5db84daef508119f9ced39d0eb31c7b685 (diff) |
Added travis, perusal tests
Diffstat (limited to 'test/eu/equalparts/cardbase/cli/CardbaseCLITest.java')
-rw-r--r-- | test/eu/equalparts/cardbase/cli/CardbaseCLITest.java | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/test/eu/equalparts/cardbase/cli/CardbaseCLITest.java b/test/eu/equalparts/cardbase/cli/CardbaseCLITest.java index cd96b61..528362e 100644 --- a/test/eu/equalparts/cardbase/cli/CardbaseCLITest.java +++ b/test/eu/equalparts/cardbase/cli/CardbaseCLITest.java @@ -372,7 +372,8 @@ public class CardbaseCLITest { assertEquals("LEA : Limited Edition Alpha\n" + "LEB : Limited Edition Beta\n" - + "ARN : Arabian Nights" + EOL, testOutput.toString()); + + "ARN : Arabian Nights\n" + + "M15 : Magic 2015 Core Set" + EOL, testOutput.toString()); } /* @@ -415,6 +416,25 @@ public class CardbaseCLITest { assertEquals(uut.selectedSet.code, "M15"); } + /* + * Edge cases + */ + @Test + public void invalidSetIsProvided() throws Exception { + uut.mtgUniverse = new MTGUniverse(getClass().getResource("").toString()); + + try { + System.setOut(new PrintStream(testOutput)); + uut.set("not a set"); + } finally { + System.setOut(console); + } + + assertEquals("\"not a set\" does not correspond to any set (use \"sets\" to see all valid set codes)." + + EOL, testOutput.toString()); + assertNull(uut.selectedSet); + } + /*********************************************************************************** * glance() tests, happy path ***********************************************************************************/ @@ -465,9 +485,55 @@ public class CardbaseCLITest { + "2 Siege Mastodon (M12, 34)\n" + "Total: 14" + EOL, testOutput.toString()); } + /*********************************************************************************** * peruse() tests, happy path ***********************************************************************************/ + @Test + public void perusalIsPrintedWithOneCard() throws Exception { + Card testCard = new ObjectMapper().readValue(getClass().getResourceAsStream("/shivandragon.json"), Card.class); + testCard.count = 1; + uut.cardbase.addCard(testCard); + + try { + System.setOut(new PrintStream(testOutput)); + uut.peruse(); + } finally { + System.setOut(console); + } + + try (Scanner scanner = new Scanner(getClass().getResourceAsStream("singleCardPerusal"))) { + assertEquals(scanner.useDelimiter("\\Z").next() + EOL, testOutput.toString()); + } + } + + @Test + public void perusalIsPrintedWithZeroCards() throws Exception { + try { + System.setOut(new PrintStream(testOutput)); + uut.peruse(); + } finally { + System.setOut(console); + } + + assertEquals("Total: 0" + EOL, testOutput.toString()); + } + + @Test + public void perusalIsPrintedWithManyCards() throws Exception { + uut = new CardbaseCLI(getClass().getResource("/testbase.cb").getFile()); + + try { + System.setOut(new PrintStream(testOutput)); + uut.peruse(); + } finally { + System.setOut(console); + } + + try (Scanner scanner = new Scanner(getClass().getResourceAsStream("multipleCardsPerusal"))) { + assertEquals(scanner.useDelimiter("\\Z").next() + EOL, testOutput.toString()); + } + } /*********************************************************************************** * undo() tests, happy path |