summaryrefslogtreecommitdiff
path: root/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java52
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java4
2 files changed, 55 insertions, 1 deletions
diff --git a/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java b/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java
index a655fd87..0748f005 100644
--- a/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java
+++ b/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java
@@ -14,7 +14,8 @@ import org.luxons.sevenwonders.game.effects.ProductionIncrease;
import org.luxons.sevenwonders.game.resources.ResourceType;
import org.luxons.sevenwonders.game.wonders.Wonder;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
+import static org.luxons.sevenwonders.game.test.TestUtils.*;
public class CardTest {
@@ -53,4 +54,53 @@ public class CardTest {
assertEquals(3, table.getBoard(1).getGold());
assertEquals(3, table.getBoard(2).getGold());
}
+
+ @Test
+ public void equals_falseWhenNull() {
+ Card card = createCard("TestCard");
+ //noinspection ObjectEqualsNull
+ assertFalse(card.equals(null));
+ }
+
+ @Test
+ public void equals_falseWhenDifferentClass() {
+ Card card = createCard("TestCard");
+ Object object = new Object();
+ //noinspection EqualsBetweenInconvertibleTypes
+ assertFalse(card.equals(object));
+ }
+
+ @Test
+ public void equals_trueWhenSame() {
+ Card card = createCard("TestCard");
+ assertEquals(card, card);
+ }
+
+ @Test
+ public void equals_trueWhenSameContent() {
+ Card card1 = createCard("TestCard");
+ Card card2 = createCard("TestCard");
+ assertTrue(card1.equals(card2));
+ }
+
+ @Test
+ public void equals_falseWhenDifferentName() {
+ Card card1 = createCard("TestCard1");
+ Card card2 = createCard("TestCard2");
+ assertFalse(card1.equals(card2));
+ }
+
+ @Test
+ public void hashCode_sameWhenSameContent() {
+ Card card1 = createCard("TestCard");
+ Card card2 = createCard("TestCard");
+ assertEquals(card1.hashCode(), card2.hashCode());
+ }
+
+ @Test
+ public void hashCode_differentWhenDifferentName() {
+ Card card1 = createCard("TestCard1");
+ Card card2 = createCard("TestCard2");
+ assertNotEquals(card1.hashCode(), card2.hashCode());
+ }
}
diff --git a/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java b/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java
index 2f4fd13a..1f2df0ab 100644
--- a/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java
+++ b/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java
@@ -114,6 +114,10 @@ public class TestUtils {
return sampleCards;
}
+ public static Card createCard(String name) {
+ return new Card(name, Color.BLUE, new Requirements(), null, null, null, null);
+ }
+
private static Card createCard(int num, Color color) {
return new Card("Test Card " + num, color, new Requirements(), null, null, null, null);
}
bgstack15