diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2017-05-08 21:52:08 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2017-05-08 21:52:08 +0200 |
commit | c62d26e808f994c991a6759cbd4014706a1cc821 (patch) | |
tree | 10f9cc902ae2643c99c099ff612b1da84a59d5c6 /backend/src/test/java/org | |
parent | Extract test method createRequirements() (diff) | |
download | seven-wonders-c62d26e808f994c991a6759cbd4014706a1cc821.tar.gz seven-wonders-c62d26e808f994c991a6759cbd4014706a1cc821.tar.bz2 seven-wonders-c62d26e808f994c991a6759cbd4014706a1cc821.zip |
Refac resources
Diffstat (limited to 'backend/src/test/java/org')
-rw-r--r-- | backend/src/test/java/org/luxons/sevenwonders/game/resources/ResourcesTest.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/backend/src/test/java/org/luxons/sevenwonders/game/resources/ResourcesTest.java b/backend/src/test/java/org/luxons/sevenwonders/game/resources/ResourcesTest.java index cd352c8b..a2bad8b9 100644 --- a/backend/src/test/java/org/luxons/sevenwonders/game/resources/ResourcesTest.java +++ b/backend/src/test/java/org/luxons/sevenwonders/game/resources/ResourcesTest.java @@ -1,6 +1,10 @@ package org.luxons.sevenwonders.game.resources; +import java.util.NoSuchElementException; + +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -8,6 +12,9 @@ import static org.junit.Assert.assertTrue; public class ResourcesTest { + @Rule + public ExpectedException thrown = ExpectedException.none(); + @Test public void init_shouldBeEmpty() { Resources resources = new Resources(); @@ -49,6 +56,31 @@ public class ResourcesTest { } @Test + public void remove_some() { + Resources resources = new Resources(); + resources.add(ResourceType.WOOD, 3); + resources.remove(ResourceType.WOOD, 2); + assertEquals(1, resources.getQuantity(ResourceType.WOOD)); + } + + @Test + public void remove_all() { + Resources resources = new Resources(); + resources.add(ResourceType.WOOD, 3); + resources.remove(ResourceType.WOOD, 3); + assertEquals(0, resources.getQuantity(ResourceType.WOOD)); + } + + @Test + public void remove_tooMany() { + Resources resources = new Resources(); + resources.add(ResourceType.WOOD, 2); + + thrown.expect(NoSuchElementException.class); + resources.remove(ResourceType.WOOD, 3); + } + + @Test public void addAll_empty() { Resources resources = new Resources(); resources.add(ResourceType.STONE, 1); |