summaryrefslogtreecommitdiffstats
path: root/test/jrummikub
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-04-28 15:46:23 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-04-28 15:46:23 +0200
commitdcba4cc235ae698b9dc2dcefefa638e19231ea41 (patch)
tree0a6cc4922f22d05597c7be72cf91e25d813532e6 /test/jrummikub
parent10a338637d4e2c695ac4ab0e4d90719559e58888 (diff)
downloadJRummikub-dcba4cc235ae698b9dc2dcefefa638e19231ea41.tar
JRummikub-dcba4cc235ae698b9dc2dcefefa638e19231ea41.zip
StoneHeapTestklasse
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@9 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub')
-rw-r--r--test/jrummikub/model/StoneHeapTest.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/jrummikub/model/StoneHeapTest.java b/test/jrummikub/model/StoneHeapTest.java
new file mode 100644
index 0000000..01f5da3
--- /dev/null
+++ b/test/jrummikub/model/StoneHeapTest.java
@@ -0,0 +1,68 @@
+package jrummikub.model;
+
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.*;
+import static org.junit.Assert.*;
+
+public class StoneHeapTest {
+ private StoneHeap testHeap;
+
+ @Before
+ public void createHeap() {
+ testHeap = new StoneHeap();
+ }
+
+ // Is the right number of Stones in heap?
+ @Test
+ public void fullStoneHeap() {
+ assertEquals(106, testHeap.heap.size());
+ }
+
+ // Enough stones of each color in heap?
+ @Test
+ public void fullColor() {
+ Map<StoneColor, Integer> counters = new HashMap<StoneColor, Integer>();
+ for (StoneColor c : EnumSet.allOf(StoneColor.class)) {
+ counters.put(c, 0);
+ }
+ for (Stone i : testHeap.heap) {
+ if (i.isJoker())
+ continue;
+ int count = counters.get(i.getColor());
+ counters.put(i.getColor(), count + 1);
+ }
+ for (StoneColor c : EnumSet.allOf(StoneColor.class)) {
+ assertEquals(26, (long) counters.get(c));
+ }
+ }
+
+ // Enough Jokers?
+ @Test
+ public void fullJoker() {
+ int countJoker = 0;
+ for (Stone i : testHeap.heap) {
+ if (i.isJoker())
+ countJoker++;
+ }
+ assertEquals(2, countJoker);
+ }
+
+ // Draw Stone Test
+ @Test
+ public void drawStoneTest() {
+ assertNotNull(testHeap.drawStone());
+ assertEquals(105, testHeap.heap.size());
+ }
+
+ // Draw Stones Test
+ @Test
+ public void drawStonesTest() {
+ List<Stone> testStones = testHeap.drawStones(5);
+ assertEquals(5, testStones.size());
+ assertEquals(101, testHeap.heap.size());
+ }
+}