From e0d4673c6ec0f0dc829c35b3db4d3405ca132f3c Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Sat, 21 Mar 2026 15:50:35 +0100 Subject: [PATCH] Add: PlayableCardTest, SlotTest --- .../ingsw/gc14/Model/PlayableCardTest.java | 34 ++++++++++++++++++ .../it/polimi/ingsw/gc14/Model/SlotTest.java | 35 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/test/java/it/polimi/ingsw/gc14/Model/PlayableCardTest.java create mode 100644 src/test/java/it/polimi/ingsw/gc14/Model/SlotTest.java diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/PlayableCardTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/PlayableCardTest.java new file mode 100644 index 0000000..4c84fdc --- /dev/null +++ b/src/test/java/it/polimi/ingsw/gc14/Model/PlayableCardTest.java @@ -0,0 +1,34 @@ +package it.polimi.ingsw.gc14.Model; + +import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; +import it.polimi.ingsw.gc14.Model.Cards.TribeCard; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class PlayableCardTest { + + @Test + void PlayableCardWrongEraException() { + assertDoesNotThrow(() -> { + new BuildingCard(1, 5); + }); + assertDoesNotThrow(() -> { + new BuildingCard(2, 5); + }); + assertDoesNotThrow(() -> { + new BuildingCard(3, 5); + }); + + assertThrows(IllegalArgumentException.class, () -> { + new BuildingCard(0, 5); + }); + assertThrows(IllegalArgumentException.class, () -> { + new BuildingCard(4, 5); + }); + assertThrows(IllegalArgumentException.class, () -> { + new BuildingCard(-1, 5); + }); + + } +} \ No newline at end of file diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/SlotTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/SlotTest.java new file mode 100644 index 0000000..25a2359 --- /dev/null +++ b/src/test/java/it/polimi/ingsw/gc14/Model/SlotTest.java @@ -0,0 +1,35 @@ +package it.polimi.ingsw.gc14.Model; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class SlotTest { + + @Test + void SlotWrongArgument() { // TODO: Cos'รจ il parametro nMinPlayer? come va testato? + assertDoesNotThrow(() -> { + Slot sl1 = new Slot(0,0,1,1); + }); + assertDoesNotThrow(() -> { + Slot sl1 = new Slot(0,1,0,1); + }); + assertDoesNotThrow(() -> { + Slot sl1 = new Slot(1,0,0,1); + }); + assertDoesNotThrow(() -> { + Slot sl1 = new Slot(1,1,0,1); + }); + + + assertThrows(IllegalArgumentException.class, () -> { + Slot sl1 = new Slot(1,0,1,1); + }); + assertThrows(IllegalArgumentException.class, () -> { + Slot sl1 = new Slot(0,1,1,1); + }); + assertThrows(IllegalArgumentException.class, () -> { + Slot sl1 = new Slot(1,1,1,1); + }); + } +} \ No newline at end of file