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 | |
parent | 59306d5db84daef508119f9ced39d0eb31c7b685 (diff) |
Added travis, perusal tests
Diffstat (limited to 'test/eu/equalparts/cardbase')
-rw-r--r-- | test/eu/equalparts/cardbase/cli/CardbaseCLITest.java | 68 | ||||
-rw-r--r-- | test/eu/equalparts/cardbase/cli/multipleCardsPerusal | 52 | ||||
-rw-r--r-- | test/eu/equalparts/cardbase/cli/singleCardPerusal | 11 |
3 files changed, 130 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 diff --git a/test/eu/equalparts/cardbase/cli/multipleCardsPerusal b/test/eu/equalparts/cardbase/cli/multipleCardsPerusal new file mode 100644 index 0000000..b82afc4 --- /dev/null +++ b/test/eu/equalparts/cardbase/cli/multipleCardsPerusal @@ -0,0 +1,52 @@ +1 Reverberate (M12, 152) + Instant + Cost: {R}{R} + Copy target instant or sorcery spell. You may choose new targets for the copy. + For every action, there is a swifter and more violent reaction. + Rare + MID: 233722 + Illus. jD +1 Mighty Leap (M12, 26) + Instant + Cost: {1}{W} + Target creature gets +2/+2 and gains flying until end of turn. (It can't be blocked except by creatures with flying or reach.) + "The southern fortress taken by invaders? Heh, sure . . . when elephants fly." + —Brezard Skeinbow, captain of the guard + Common + MID: 241989 + Illus. rk post +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 +1 Feral Krushok (FRF, 128) + Creature — Beast + Cost: {4}{G} + 5/4 + In a stunning act of diplomacy, Yasova Dragonclaw ceded a portion of Temur lands to the Sultai. Her clan protested until they saw she had given the Sultai the breeding grounds of the krushoks. They hadn't realized she had a sense of humor. + Common + MID: 391831 + Illus. Kev Walker +1 Destructor Dragon (FRF, 127) + Creature — Dragon + Cost: {4}{G}{G} + 4/4 + Flying + When Destructor Dragon dies, destroy target noncreature permanent. + After countless attacks on the Salt Road where it passes through the frozen tundra, the Abzan began to refer to the area as Atarka territory rather than Temur lands. + Uncommon + MID: 391818 + Illus. Peter Mohrbacher +2 Siege Mastodon (M12, 34) + Creature — Elephant + Cost: {4}{W} + 3/5 + "The walls of the wicked will fall before us. Ready the siege engines. We proceed to war!" + —General Avitora + Common + MID: 222635 + Illus. Matt Cavotta +Total: 14
\ No newline at end of file diff --git a/test/eu/equalparts/cardbase/cli/singleCardPerusal b/test/eu/equalparts/cardbase/cli/singleCardPerusal new file mode 100644 index 0000000..26ba57b --- /dev/null +++ b/test/eu/equalparts/cardbase/cli/singleCardPerusal @@ -0,0 +1,11 @@ +1 Shivan Dragon (M15, 281) + Creature — Dragon + Cost: {4}{R}{R} + 5/5 + Flying (This creature can't be blocked except by creatures with flying or reach.) + {R}: Shivan Dragon gets +1/+0 until end of turn. + The undisputed master of the mountains of Shiv. + Rare + MID: 383172 + Illus. Donato Giancola +Total: 1
\ No newline at end of file |