From 800633586ab29cf8f178a78df2542fdd7f0d7114 Mon Sep 17 00:00:00 2001 From: jbion Date: Sat, 24 Dec 2016 11:37:08 +0100 Subject: Add test for RawPointsIncrease --- .../game/effects/RawPointsIncreaseTest.java | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java diff --git a/src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java b/src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java new file mode 100644 index 00000000..a1c8a8de --- /dev/null +++ b/src/test/java/org/luxons/sevenwonders/game/effects/RawPointsIncreaseTest.java @@ -0,0 +1,61 @@ +package org.luxons.sevenwonders.game.effects; + +import org.junit.experimental.theories.DataPoints; +import org.junit.experimental.theories.Theories; +import org.junit.experimental.theories.Theory; +import org.junit.runner.RunWith; +import org.luxons.sevenwonders.game.api.Table; +import org.luxons.sevenwonders.game.test.TestUtils; + +import static org.junit.Assert.*; + +@RunWith(Theories.class) +public class RawPointsIncreaseTest { + + @DataPoints + public static int[] points() { + return new int[] {0, 1, 2, 3, 5}; + } + + @Theory + public void computePoints_equalsNbOfPoints(int points) { + RawPointsIncrease rawPointsIncrease = new RawPointsIncrease(points); + Table table = TestUtils.createTable(5); + assertEquals(points, rawPointsIncrease.computePoints(table, 0)); + } + + @Theory + public void equals_falseWhenNull(int points) { + RawPointsIncrease rawPointsIncrease = new RawPointsIncrease(points); + //noinspection ObjectEqualsNull + assertFalse(rawPointsIncrease.equals(null)); + } + + @Theory + public void equals_falseWhenDifferentClass(int points) { + RawPointsIncrease rawPointsIncrease = new RawPointsIncrease(points); + GoldIncrease goldIncrease = new GoldIncrease(points); + //noinspection EqualsBetweenInconvertibleTypes + assertFalse(rawPointsIncrease.equals(goldIncrease)); + } + + @Theory + public void equals_trueWhenSame(int points) { + RawPointsIncrease rawPointsIncrease = new RawPointsIncrease(points); + assertEquals(rawPointsIncrease, rawPointsIncrease); + } + + @Theory + public void equals_trueWhenSameContent(int points) { + RawPointsIncrease rawPointsIncrease1 = new RawPointsIncrease(points); + RawPointsIncrease rawPointsIncrease2 = new RawPointsIncrease(points); + assertTrue(rawPointsIncrease1.equals(rawPointsIncrease2)); + } + + @Theory + public void hashCode_sameWhenSameContent(int points) { + RawPointsIncrease rawPointsIncrease1 = new RawPointsIncrease(points); + RawPointsIncrease rawPointsIncrease2 = new RawPointsIncrease(points); + assertEquals(rawPointsIncrease1.hashCode(), rawPointsIncrease2.hashCode()); + } +} \ No newline at end of file -- cgit