diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintingsTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintingsTest.java index 2f8656d..95e48b5 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintingsTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintingsTest.java @@ -1,7 +1,10 @@ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events; +import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Artist; +import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType; import it.polimi.ingsw.gc14.Model.Player; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -12,36 +15,94 @@ import static org.junit.jupiter.api.Assertions.*; class CavePaintingsTest { @Test + @DisplayName("Testing constructor") + void testConstructor() { + // Gli attributi di CavePainting era e EventType vengono testati in EventCardTest. + + // Gli attributi NLower, NPrestigeRem e NPrestigeMul non possono essere testati singolarmente in quanto non hanno metodi getter + // Ne viene testato il corretto funzionamento indirettamente attraverso applyEffect. + + // Come conseguenza finale, non può essere testato il costruttore di CavePainting + } + + @Test + @DisplayName("No edge case test") void activateEvent() { Player p1 = new Player("Marco"); - - ArrayList players = new ArrayList<>(Arrays.asList(p1)); + Player p2 = new Player("Giacomo"); + ArrayList players = new ArrayList<>(Arrays.asList(p1, p2)); CavePaintings cp1 = new CavePaintings(1, 1, 3, 2); + + p2.artists.add(new Artist(1)); cp1.activateEvent(players); assertEquals(-3, p1.getPrestigeValue()); assertEquals(0, p1.getFoodValue()); + assertEquals(2, p2.getPrestigeValue()); + assertEquals(0, p2.getFoodValue()); + } + @Test + @DisplayName("Multiple activations test") + void activateEvent1() { + Player p1 = new Player("Marco"); + ArrayList players = new ArrayList<>(Arrays.asList(p1)); + CavePaintings cp1 = new CavePaintings(1, 1, 3, 2); + CavePaintings cp2 = new CavePaintings(1, 1, 3, 4); + CavePaintings cp3 = new CavePaintings(1, 1, 10, 2); - new Artist(1).insert(p1); + cp1.activateEvent(players); + assertEquals(-3, p1.getPrestigeValue()); + assertEquals(0, p1.getFoodValue()); - - CavePaintings cp2 = new CavePaintings(1, 1, 3, 2); + p1.artists.add(new Artist(1)); + p1.artists.add(new Artist(1)); cp2.activateEvent(players); - - assertEquals(-1, p1.getPrestigeValue()); + assertEquals(5, p1.getPrestigeValue()); assertEquals(0, p1.getFoodValue()); - - - new Artist(1).insert(p1); - - - CavePaintings cp3 = new CavePaintings(1, 1, 3, 5); + p1.artists.clear(); cp3.activateEvent(players); - - assertEquals(9, p1.getPrestigeValue()); + assertEquals(-5, p1.getPrestigeValue()); assertEquals(0, p1.getFoodValue()); + } + @Test + @DisplayName("Building 9 test") + void activateEvent2() { + Player p1 = new Player("Marco"); + ArrayList players = new ArrayList<>(Arrays.asList(p1)); + CavePaintings cp1 = new CavePaintings(1, 1, 3, 2); + BuildingCard bc1 = new BuildingCard(9,1,5,5); + p1.addFood(5); + bc1.buy(p1); + p1.artists.add(new Artist(1)); + cp1.activateEvent(players); + + assertEquals(2, p1.getPrestigeValue()); + assertEquals(1, p1.getFoodValue()); + + + BuildingCard bc2 = new BuildingCard(9,1,5,5); + p1.addFood(5); + bc2.buy(p1); + p1.artists.add(new Artist(1)); + p1.artists.add(new Artist(1)); + cp1.activateEvent(players); + + assertEquals(8, p1.getPrestigeValue()); + assertEquals(7, p1.getFoodValue()); + } + + @Test + @DisplayName("Clone testing") + void cloneTest() { + int era = 1; + + CavePaintings cv1 = new CavePaintings(era, 1,1,1); + CavePaintings cv2 = (CavePaintings) cv1.clone(); + + assertEquals(1, cv2.getEra()); + assertEquals(EventType.CAVE_PAINTINGS, cv2.getType()); } } \ No newline at end of file diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java index 3cbc8d5..ff8d912 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java @@ -4,6 +4,8 @@ import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType; import it.polimi.ingsw.gc14.Model.Cards.Building.Effects.Building0; import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Hunter; +import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard; +import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType; import it.polimi.ingsw.gc14.Model.Player; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -98,4 +100,19 @@ class HuntTest { assertEquals(3, p3.getPrestigeValue()); assertEquals(1, p3.getFoodValue()); } + + @Test + @DisplayName("clone testing") + void cloneTest() { + int era = 1; + int prestigeMultiplier = 3; + + Hunt h1 = new Hunt(era, prestigeMultiplier); + Hunt h2 = (Hunt) h1.clone(); + + assertEquals(1, h2.foodToAdd); + assertEquals(3, h2.prestigeMultiplier); + assertEquals(1, h2.getEra()); + assertEquals(EventType.HUNT, h2.getType()); + } } \ No newline at end of file