Fixed: compilation errors
Added: line coverage improved
This commit is contained in:
@@ -62,7 +62,7 @@ public abstract class EventCard extends TribeCard {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString()+" "+type.toString();
|
return super.toString()+", "+type.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -70,4 +70,5 @@ public class Hunt extends EventCard {
|
|||||||
public EventCard clone() {
|
public EventCard clone() {
|
||||||
return new Hunt(getEra(), prestigeMultiplier);
|
return new Hunt(getEra(), prestigeMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ public class Board implements Serializable {
|
|||||||
return this.tribeDeck.size();
|
return this.tribeDeck.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the game era
|
||||||
|
*/
|
||||||
|
public int getEra() {return this.era;}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and initializes a new board:
|
* Creates and initializes a new board:
|
||||||
@@ -234,7 +239,7 @@ public class Board implements Serializable {
|
|||||||
upperListBuilding.addAll( buildingCards.subList(0,3));
|
upperListBuilding.addAll( buildingCards.subList(0,3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(era==3)
|
else // Era 3
|
||||||
{
|
{
|
||||||
if(nTotem==2)
|
if(nTotem==2)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ class BuilderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void constructorWithNMinTest() {
|
void constructorWithNMinTest() {
|
||||||
|
// Correct case
|
||||||
Builder b = new Builder(1, 2, 3, 4);
|
Builder b = new Builder(1, 2, 3, 4);
|
||||||
|
|
||||||
assertEquals(1, b.getEra());
|
assertEquals(1, b.getEra());
|
||||||
@@ -87,6 +88,12 @@ class BuilderTest {
|
|||||||
assertEquals(3, b.getPrestigeValue());
|
assertEquals(3, b.getPrestigeValue());
|
||||||
assertEquals(4, b.getNMin());
|
assertEquals(4, b.getNMin());
|
||||||
assertFalse(b.IsEventCard());
|
assertFalse(b.IsEventCard());
|
||||||
|
|
||||||
|
// Wrong reductionValue
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> {new Builder(1, -1, 3, 4);});
|
||||||
|
|
||||||
|
// Wrong prestigeValue
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> {new Builder(1, 2, -1, 4);});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+8
@@ -105,4 +105,12 @@ class CavePaintingsTest {
|
|||||||
assertEquals(1, cv2.getEra());
|
assertEquals(1, cv2.getEra());
|
||||||
assertEquals(EventType.CAVE_PAINTINGS, cv2.getType());
|
assertEquals(EventType.CAVE_PAINTINGS, cv2.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("ToString testing")
|
||||||
|
void toStringTest() {
|
||||||
|
CavePaintings cv1 = new CavePaintings(1, 1,1,1);
|
||||||
|
|
||||||
|
assertEquals("Era:1, CAVE_PAINTINGS", cv1.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -107,4 +107,12 @@ class HuntTest {
|
|||||||
assertEquals(1, h2.getEra());
|
assertEquals(1, h2.getEra());
|
||||||
assertEquals(EventType.HUNT, h2.getType());
|
assertEquals(EventType.HUNT, h2.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("ToString testing")
|
||||||
|
void toStringTest() {
|
||||||
|
Hunt h1 = new Hunt(1, 3);
|
||||||
|
|
||||||
|
assertEquals("Era:1, HUNT", h1.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+8
@@ -206,4 +206,12 @@ class ShamanicRitualTest {
|
|||||||
assertEquals(prestigeToRemove, sr2.prestigeToRemove);
|
assertEquals(prestigeToRemove, sr2.prestigeToRemove);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("ToString testing")
|
||||||
|
void toStringTest() {
|
||||||
|
ShamanicRitual sr1 = new ShamanicRitual(1, 5,2);
|
||||||
|
|
||||||
|
assertEquals("Era:1, SHAMANIC_RITUAL", sr1.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -116,6 +116,14 @@ class SustenanceTest {
|
|||||||
assertEquals(EventType.SUSTENANCE, s2.getType());
|
assertEquals(EventType.SUSTENANCE, s2.getType());
|
||||||
assertEquals(prestigeDebt, s2.getPrestigeDebt());
|
assertEquals(prestigeDebt, s2.getPrestigeDebt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("ToString testing")
|
||||||
|
void toStringTest() {
|
||||||
|
Sustenance s1 = new Sustenance(1, 5);
|
||||||
|
|
||||||
|
assertEquals("Era:1, SUSTENANCE", s1.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ class BoardTest {
|
|||||||
assertEquals(94 + 2 - (5+4) - (5+1), bd5.getTribeDeckSize());
|
assertEquals(94 + 2 - (5+4) - (5+1), bd5.getTribeDeckSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing era getter")
|
||||||
|
void getEra() {
|
||||||
|
Board bd = new Board(3);
|
||||||
|
assertEquals(1, bd.getEra());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Testing constructor")
|
@DisplayName("Testing constructor")
|
||||||
void testConstructor() {
|
void testConstructor() {
|
||||||
@@ -159,15 +166,16 @@ class BoardTest {
|
|||||||
@DisplayName("Removing a card from lower row of building cards")
|
@DisplayName("Removing a card from lower row of building cards")
|
||||||
void removeLowerBuildingCard() {
|
void removeLowerBuildingCard() {
|
||||||
Board bd = new Board(3);
|
Board bd = new Board(3);
|
||||||
bd.lowerListBuilding.add(new BuildingCard(2, 1, 5, 10));
|
|
||||||
bd.lowerListBuilding.add(new BuildingCard(3, 2, 2, 1));
|
|
||||||
|
|
||||||
|
for (int i=0;i<3;i++) {
|
||||||
|
bd.nextRound(); // Skip to era 2
|
||||||
|
}
|
||||||
|
|
||||||
List<BuildingCard> before = bd.lowerListBuilding;
|
List<BuildingCard> before = bd.lowerListBuilding;
|
||||||
BuildingCard cardToRemove = before.get(0);
|
BuildingCard cardToRemove = before.get(0);
|
||||||
|
|
||||||
before.remove(0);
|
before.remove(0);
|
||||||
bd.removeUpperBuildingCard(cardToRemove);
|
bd.removeLowerBuildingCard(cardToRemove);
|
||||||
|
|
||||||
assertEquals(before, bd.lowerListBuilding);
|
assertEquals(before, bd.lowerListBuilding);
|
||||||
}
|
}
|
||||||
@@ -186,4 +194,89 @@ class BoardTest {
|
|||||||
assertEquals(numPlayer+4, bd.upperListTribe.size()); // Verifica che la nuova dimensione della lista superiore sia corretta
|
assertEquals(numPlayer+4, bd.upperListTribe.size()); // Verifica che la nuova dimensione della lista superiore sia corretta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing nextEra")
|
||||||
|
void nextEra() {
|
||||||
|
// Since nextEra is private, it must be tested through nextRound.
|
||||||
|
// In this test we simulate multiple rounds to trigger the next era activation.
|
||||||
|
// NOTE: after 3 rounds we are in era 2. After 6 we are in era 3.
|
||||||
|
int numPlayer;
|
||||||
|
List<BuildingCard> upperListBefore;
|
||||||
|
|
||||||
|
// Era 2, nTotem <= 3
|
||||||
|
numPlayer = 3;
|
||||||
|
Board bd1 = new Board(numPlayer);
|
||||||
|
upperListBefore = new ArrayList<>(bd1.upperListBuilding);
|
||||||
|
for (int i=0;i<3;i++) {
|
||||||
|
bd1.nextRound(); // Skip to era 2
|
||||||
|
}
|
||||||
|
assertEquals(2, bd1.getEra());
|
||||||
|
assertEquals(upperListBefore, bd1.lowerListBuilding);
|
||||||
|
assertNotEquals(upperListBefore, bd1.upperListBuilding);
|
||||||
|
assertEquals(2, bd1.upperListBuilding.size());
|
||||||
|
|
||||||
|
|
||||||
|
// Era 2, nTotem > 3
|
||||||
|
numPlayer = 4;
|
||||||
|
Board bd2 = new Board(numPlayer);
|
||||||
|
upperListBefore = new ArrayList<>(bd2.upperListBuilding);
|
||||||
|
for (int i=0;i<3;i++) {
|
||||||
|
bd2.nextRound(); // Skip to era 2
|
||||||
|
}
|
||||||
|
assertEquals(2, bd2.getEra());
|
||||||
|
assertEquals(upperListBefore, bd2.lowerListBuilding);
|
||||||
|
assertNotEquals(upperListBefore, bd2.upperListBuilding);
|
||||||
|
assertEquals(3, bd2.upperListBuilding.size());
|
||||||
|
|
||||||
|
|
||||||
|
// Era 3, nTotem == 2
|
||||||
|
numPlayer = 2;
|
||||||
|
Board bd3 = new Board(numPlayer);
|
||||||
|
for (int i=0;i<3;i++) {
|
||||||
|
bd3.nextRound(); // Skip to era 2
|
||||||
|
}
|
||||||
|
upperListBefore = new ArrayList<>(bd3.upperListBuilding); // We need to take the list of the era 2
|
||||||
|
for (int i=0;i<3;i++) {
|
||||||
|
bd3.nextRound(); // Skip to era 3
|
||||||
|
}
|
||||||
|
assertEquals(3, bd3.getEra());
|
||||||
|
assertEquals(upperListBefore, bd3.lowerListBuilding);
|
||||||
|
assertNotEquals(upperListBefore, bd3.upperListBuilding);
|
||||||
|
assertEquals(3, bd3.upperListBuilding.size());
|
||||||
|
|
||||||
|
|
||||||
|
// Era 3, nTotem == 5
|
||||||
|
numPlayer = 5;
|
||||||
|
Board bd4 = new Board(numPlayer);
|
||||||
|
for (int i=0;i<3;i++) {
|
||||||
|
bd4.nextRound(); // Skip to era 2
|
||||||
|
}
|
||||||
|
upperListBefore = new ArrayList<>(bd4.upperListBuilding); // We need to take the list of the era 2
|
||||||
|
for (int i=0;i<3;i++) {
|
||||||
|
bd4.nextRound(); // Skip to era 3
|
||||||
|
}
|
||||||
|
assertEquals(3, bd4.getEra());
|
||||||
|
assertEquals(upperListBefore, bd4.lowerListBuilding);
|
||||||
|
assertNotEquals(upperListBefore, bd4.upperListBuilding);
|
||||||
|
assertEquals(5, bd4.upperListBuilding.size());
|
||||||
|
|
||||||
|
|
||||||
|
// Era 3, nTotem != 2, 5
|
||||||
|
numPlayer = 3;
|
||||||
|
Board bd5 = new Board(numPlayer);
|
||||||
|
for (int i=0;i<3;i++) {
|
||||||
|
bd5.nextRound(); // Skip to era 2
|
||||||
|
}
|
||||||
|
upperListBefore = new ArrayList<>(bd5.upperListBuilding); // We need to take the list of the era 2
|
||||||
|
for (int i=0;i<3;i++) {
|
||||||
|
bd5.nextRound(); // Skip to era 3
|
||||||
|
}
|
||||||
|
assertEquals(3, bd5.getEra());
|
||||||
|
assertEquals(upperListBefore, bd5.lowerListBuilding);
|
||||||
|
assertNotEquals(upperListBefore, bd5.upperListBuilding);
|
||||||
|
assertEquals(4, bd5.upperListBuilding.size());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package it.polimi.ingsw.gc14.Model.Orders;
|
|||||||
|
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||||
import it.polimi.ingsw.gc14.Model.Player;
|
import it.polimi.ingsw.gc14.Model.Player;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -10,6 +11,16 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
|
|
||||||
class Order2Test {
|
class Order2Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing Order2 constructor with wrong number of player")
|
||||||
|
void constructorTest() {
|
||||||
|
Player p1 = new Player("p1");
|
||||||
|
ArrayList<Player> players = new ArrayList<>();
|
||||||
|
players.add(p1);
|
||||||
|
assertThrows(NoSuchElementException.class, () -> {new Order2(players);});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void firstReturnGetsFood() {
|
void firstReturnGetsFood() {
|
||||||
Player p1 = new Player("p1");
|
Player p1 = new Player("p1");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package it.polimi.ingsw.gc14.Model.Orders;
|
|||||||
|
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||||
import it.polimi.ingsw.gc14.Model.Player;
|
import it.polimi.ingsw.gc14.Model.Player;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -10,6 +11,15 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
|
|
||||||
class Order3Test {
|
class Order3Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing Order3 constructor with wrong number of player")
|
||||||
|
void constructorTest() {
|
||||||
|
Player p1 = new Player("p1");
|
||||||
|
ArrayList<Player> players = new ArrayList<>();
|
||||||
|
players.add(p1);
|
||||||
|
assertThrows(NoSuchElementException.class, () -> {new Order3(players);});
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void firstReturnGetsFood() {
|
void firstReturnGetsFood() {
|
||||||
Player p1 = new Player("p1");
|
Player p1 = new Player("p1");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package it.polimi.ingsw.gc14.Model.Orders;
|
|||||||
|
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||||
import it.polimi.ingsw.gc14.Model.Player;
|
import it.polimi.ingsw.gc14.Model.Player;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -10,6 +11,15 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
|
|
||||||
class Order4Test {
|
class Order4Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing Order4 constructor with wrong number of player")
|
||||||
|
void constructorTest() {
|
||||||
|
Player p1 = new Player("p1");
|
||||||
|
ArrayList<Player> players = new ArrayList<>();
|
||||||
|
players.add(p1);
|
||||||
|
assertThrows(NoSuchElementException.class, () -> {new Order4(players);});
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void firstReturnGetsFood() {
|
void firstReturnGetsFood() {
|
||||||
Player p1 = new Player("p1");
|
Player p1 = new Player("p1");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package it.polimi.ingsw.gc14.Model.Orders;
|
|||||||
|
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||||
import it.polimi.ingsw.gc14.Model.Player;
|
import it.polimi.ingsw.gc14.Model.Player;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -15,6 +16,15 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
|
|
||||||
class Order5Test {
|
class Order5Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing Order5 constructor with wrong number of player")
|
||||||
|
void constructorTest() {
|
||||||
|
Player p1 = new Player("p1");
|
||||||
|
ArrayList<Player> players = new ArrayList<>();
|
||||||
|
players.add(p1);
|
||||||
|
assertThrows(NoSuchElementException.class, () -> {new Order5(players);});
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void firstReturnGetsFood() {
|
void firstReturnGetsFood() {
|
||||||
Player p1 = new Player("p1");
|
Player p1 = new Player("p1");
|
||||||
|
|||||||
Reference in New Issue
Block a user