diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-29 15:50:24 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-29 15:50:24 +0200 |
commit | eea456991cc9e3d29ab51e8907b0374a61c77a96 (patch) | |
tree | 71afd4fe7621f5ae68b9df3e38f5dd652b4d9be9 /test/jrummikub/model | |
parent | 89e59b2f2c65234bafc34e1360feabdcec367b01 (diff) | |
download | JRummikub-eea456991cc9e3d29ab51e8907b0374a61c77a96.tar JRummikub-eea456991cc9e3d29ab51e8907b0374a61c77a96.zip |
Calculate accumulated score in game state
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@297 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/model')
-rw-r--r-- | test/jrummikub/model/GameStateTest.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/jrummikub/model/GameStateTest.java b/test/jrummikub/model/GameStateTest.java new file mode 100644 index 0000000..8f311a6 --- /dev/null +++ b/test/jrummikub/model/GameStateTest.java @@ -0,0 +1,47 @@ +package jrummikub.model; + +import static org.junit.Assert.*; + +import java.util.Arrays; + +import org.junit.Test; + +public class GameStateTest { + GameState gameState = new GameState(); + + @Test + public void testAccumulatedScore() { + Score score1 = new Score(Arrays.asList(true, false, false), Arrays.asList( + 30, -20, -10)); + Score score2 = new Score(Arrays.asList(true, true, false), Arrays.asList( + -10, -10, -50)); + Score score3 = new Score(Arrays.asList(false, false, true), Arrays.asList( + -30, -20, 50)); + Score score4 = new Score(Arrays.asList(false, true, false), Arrays.asList( + -20, -10, -30)); + + gameState.getScores().addAll(Arrays.asList(score1, score2, score3, score4)); + + Score accum = gameState.getAccumulatedScore(); + assertEquals(Arrays.asList(true, false, false), accum.getWinners()); + assertEquals(Arrays.asList(-30, -60, -40), accum.getPoints()); + } + + @Test + public void testAccumulatedScoreDraw() { + Score score1 = new Score(Arrays.asList(true, false, false), Arrays.asList( + 10, -10, -5)); + Score score2 = new Score(Arrays.asList(true, true, false), Arrays.asList( + -10, -10, -50)); + Score score3 = new Score(Arrays.asList(false, false, true), Arrays.asList( + -20, -10, 30)); + Score score4 = new Score(Arrays.asList(false, true, false), Arrays.asList( + -20, -10, -30)); + + gameState.getScores().addAll(Arrays.asList(score1, score2, score3, score4)); + + Score accum = gameState.getAccumulatedScore(); + assertEquals(Arrays.asList(true, true, false), accum.getWinners()); + assertEquals(Arrays.asList(-40, -40, -55), accum.getPoints()); + } +} |