Fix: Board, tribe_era1.json
Add: BoardTest
This commit is contained in:
@@ -3,14 +3,14 @@ package it.polimi.ingsw.gc14.Model.GamePackage;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
|
||||
import it.polimi.ingsw.gc14.Model.DecksCreator;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import it.polimi.ingsw.gc14.Model.Slot;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -69,16 +69,33 @@ class BoardTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Testing constructor")
|
||||
void testConstructor() {
|
||||
@DisplayName("Testing TribeDeck size with different player number")
|
||||
void getTribeDeckSize() {
|
||||
Board bd2 = new Board(2);
|
||||
Board bd3 = new Board(3);
|
||||
Board bd4 = new Board(4);
|
||||
Board bd5 = new Board(5);
|
||||
|
||||
assertEquals(61 + 2 - (2+4) - (2+1), bd2.getTribeDeckSize());
|
||||
assertEquals(72 + 2 - (3+4) - (3+1), bd3.getTribeDeckSize());
|
||||
assertEquals(83 + 2 - (4+4) - (4+1), bd4.getTribeDeckSize());
|
||||
assertEquals(94 + 2 - (5+4) - (5+1), bd5.getTribeDeckSize());
|
||||
}
|
||||
|
||||
// TODO non ho idea di come testare delle estrazioni randomiche
|
||||
@Test
|
||||
@DisplayName("Testing constructor")
|
||||
void generateTribeDeck() {
|
||||
void testConstructor() {
|
||||
int numPlayer = 5;
|
||||
Board bd = new Board(numPlayer);
|
||||
|
||||
assertEquals(96 - (numPlayer+4) - (numPlayer+1), bd.getTribeDeckSize()); // Verifica che dal mazzo TribeDeck venga pescato il numero corretto di carte
|
||||
|
||||
assertEquals(numPlayer+1, bd.lowerListTribe.size()); // Verifica che la dimensione della lista inferiore sia corretta
|
||||
assertTrue(bd.lowerListTribe.stream().noneMatch(card -> card.IsEventCard())); // Verifica che non ci siano EventCard dentro alla lista inferiore
|
||||
|
||||
assertEquals(numPlayer+4, bd.upperListTribe.size()); // Verifica che la dimensione della lista superiore sia corretta
|
||||
|
||||
assertEquals(2, bd.upperListBuilding.size()); // Verifica che ci sia il giusto numero di buildings (2 edifici per 3+ giocatori)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -125,7 +142,7 @@ class BoardTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Removing a card from upper row of building cards")
|
||||
@DisplayName("RemgetTribeDeckSizeoving a card from upper row of building cards")
|
||||
void removeUpperBuildingCard() {
|
||||
Board bd = new Board(3);
|
||||
|
||||
@@ -142,7 +159,9 @@ class BoardTest {
|
||||
@DisplayName("Removing a card from lower row of building cards")
|
||||
void removeLowerBuildingCard() {
|
||||
Board bd = new Board(3);
|
||||
bd.nextEra();
|
||||
bd.lowerListBuilding.add(new BuildingCard(2, 1, 5, 10));
|
||||
bd.lowerListBuilding.add(new BuildingCard(3, 2, 2, 1));
|
||||
|
||||
|
||||
List<BuildingCard> before = bd.lowerListBuilding;
|
||||
BuildingCard cardToRemove = before.get(0);
|
||||
@@ -153,5 +172,18 @@ class BoardTest {
|
||||
assertEquals(before, bd.lowerListBuilding);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Testing next round")
|
||||
void nextRound() {
|
||||
int numPlayer = 3;
|
||||
Board bd = new Board(numPlayer);
|
||||
assertTrue(!bd.lowerListTribe.isEmpty());
|
||||
List<TribeCard> upperListBefore = new ArrayList<>(bd.upperListTribe);
|
||||
|
||||
bd.nextRound();
|
||||
assertEquals(upperListBefore, bd.lowerListTribe); // Verifica che la lista superiore è stata spostata sotto
|
||||
assertNotEquals(upperListBefore, bd.upperListTribe); // Verifica che la lista superiore sia stata cambiata
|
||||
assertEquals(numPlayer+4, bd.upperListTribe.size()); // Verifica che la nuova dimensione della lista superiore sia corretta
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user