diff options
author | jbion <joffrey.bion@amadeus.com> | 2016-12-29 18:50:34 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2016-12-29 18:50:34 +0100 |
commit | 6077d9a54f6fc64345315d7c28a8f53b0921a733 (patch) | |
tree | 64ee39c3f449477f7f71b5453cea49b675bee624 /src/test/java | |
parent | Add player reordering support in Lobby (diff) | |
download | seven-wonders-6077d9a54f6fc64345315d7c28a8f53b0921a733.tar.gz seven-wonders-6077d9a54f6fc64345315d7c28a8f53b0921a733.tar.bz2 seven-wonders-6077d9a54f6fc64345315d7c28a8f53b0921a733.zip |
Add test for Board.removeGold
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java b/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java index 952561ac..35b2df7d 100644 --- a/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java +++ b/src/test/java/org/luxons/sevenwonders/game/boards/BoardTest.java @@ -3,12 +3,15 @@ package org.luxons.sevenwonders.game.boards; import java.util.Arrays; import java.util.Collections; +import org.junit.Rule; import org.junit.experimental.theories.DataPoints; import org.junit.experimental.theories.FromDataPoints; import org.junit.experimental.theories.Theories; import org.junit.experimental.theories.Theory; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.luxons.sevenwonders.game.Settings; +import org.luxons.sevenwonders.game.boards.Board.InsufficientFundsException; import org.luxons.sevenwonders.game.cards.Color; import org.luxons.sevenwonders.game.resources.ResourceType; import org.luxons.sevenwonders.game.resources.Resources; @@ -16,6 +19,7 @@ import org.luxons.sevenwonders.game.test.TestUtils; import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assume.*; @RunWith(Theories.class) public class BoardTest { @@ -40,6 +44,9 @@ public class BoardTest { return Color.values(); } + @Rule + public ExpectedException thrown = ExpectedException.none(); + @Theory public void initialGold_respectsSettings(@FromDataPoints("gold") int goldAmountInSettings) { Settings settings = new Settings(); @@ -56,6 +63,28 @@ public class BoardTest { } @Theory + public void removeOld_successfulWhenNotTooMuch(@FromDataPoints("gold") int initialGold, + @FromDataPoints("gold") int goldRemoved) { + assumeTrue(goldRemoved >= 0); + assumeTrue(initialGold >= goldRemoved); + Board board = new Board(TestUtils.createWonder(), null, new Settings()); + board.setGold(initialGold); + board.removeGold(goldRemoved); + assertEquals(initialGold - goldRemoved, board.getGold()); + } + + @Theory + public void removeOld_failsWhenTooMuch(@FromDataPoints("gold") int initialGold, + @FromDataPoints("gold") int goldRemoved) { + assumeTrue(goldRemoved >= 0); + assumeTrue(initialGold < goldRemoved); + thrown.expect(InsufficientFundsException.class); + Board board = new Board(TestUtils.createWonder(), null, new Settings()); + board.setGold(initialGold); + board.removeGold(goldRemoved); + } + + @Theory public void getNbCardsOfColor_properCount_singleColor(ResourceType type, @FromDataPoints("nbCards") int nbCards, @FromDataPoints("nbCards") int nbOtherCards, Color color) { Board board = new Board(TestUtils.createWonder(type), null, new Settings()); |