Fix: changed test names for InvetorTest, BuilderTest; Update: DecksCreatorTest
This commit is contained in:
+2
-2
@@ -90,14 +90,14 @@ class BuilderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void constructorShouldThrowIfReductionValueNegative() {
|
void negativeReductionValue() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
new Builder(1, -1, 3);
|
new Builder(1, -1, 3);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void constructorShouldThrowIfPrestigeValueNegative() {
|
void negativePrestigeValue() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
new Builder(1, 2, -3);
|
new Builder(1, 2, -3);
|
||||||
});
|
});
|
||||||
|
|||||||
+4
-4
@@ -84,28 +84,28 @@ class InventorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void constructorShouldThrowIfIconIsNegative() {
|
void negativeIcon() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
new Inventor(1, -1);
|
new Inventor(1, -1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void constructorShouldThrowIfIconIsGreaterThanNine() {
|
void iconGreaterThanNine() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
new Inventor(1, 10);
|
new Inventor(1, 10);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void constructorWithNMinShouldThrowIfIconIsNegative() {
|
void negativeIconWithNMin() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
new Inventor(1, -1, 3);
|
new Inventor(1, -1, 3);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void constructorWithNMinShouldThrowIfIconIsGreaterThanNine() {
|
void iconGreaterThanNineWithNMin() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
new Inventor(1, 10, 3);
|
new Inventor(1, 10, 3);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package it.polimi.ingsw.gc14.Model;
|
package it.polimi.ingsw.gc14.Model;
|
||||||
|
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@@ -18,4 +19,63 @@ class DecksCreatorTest {
|
|||||||
List<TribeCard> cards3 = DecksCreator.loadTribeDeck("/Cards/tribe_era3.json");
|
List<TribeCard> cards3 = DecksCreator.loadTribeDeck("/Cards/tribe_era3.json");
|
||||||
assertEquals(29,cards3.size());
|
assertEquals(29,cards3.size());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
|
void loadDeckWrongEra() {
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> DecksCreator.loadTribeDeckByEra(0));
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> DecksCreator.loadTribeDeckByEra(4));
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> DecksCreator.loadTribeDeckByEra(-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadDeckWrongPath() {
|
||||||
|
assertThrows(RuntimeException.class, () -> DecksCreator.loadTribeDeck("/Cards/not_found.json"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadBuildingDeck() {
|
||||||
|
List<BuildingCard> allCards = DecksCreator.loadBuildingDeck("/Cards/buildingCards.json");
|
||||||
|
|
||||||
|
assertNotNull(allCards);
|
||||||
|
assertFalse(allCards.isEmpty());
|
||||||
|
assertFalse(allCards.contains(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadBuildingDeckByEra() {
|
||||||
|
List<BuildingCard> allCards = DecksCreator.loadBuildingDeck("/Cards/buildingCards.json");
|
||||||
|
|
||||||
|
List<BuildingCard> era1 = DecksCreator.loadBuildingDeckByEra(1);
|
||||||
|
List<BuildingCard> era2 = DecksCreator.loadBuildingDeckByEra(2);
|
||||||
|
List<BuildingCard> era3 = DecksCreator.loadBuildingDeckByEra(3);
|
||||||
|
|
||||||
|
assertEquals(allCards.stream().filter(c -> c.getEra() == 1).count(), era1.size());
|
||||||
|
assertEquals(allCards.stream().filter(c -> c.getEra() == 2).count(), era2.size());
|
||||||
|
assertEquals(allCards.stream().filter(c -> c.getEra() == 3).count(), era3.size());
|
||||||
|
|
||||||
|
assertTrue(era1.stream().allMatch(c -> c.getEra() == 1));
|
||||||
|
assertTrue(era2.stream().allMatch(c -> c.getEra() == 2));
|
||||||
|
assertTrue(era3.stream().allMatch(c -> c.getEra() == 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadBuildingDeckWrongEra() {
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> DecksCreator.loadBuildingDeckByEra(0));
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> DecksCreator.loadBuildingDeckByEra(4));
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> DecksCreator.loadBuildingDeckByEra(-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadBuildingDeckWrongPath() {
|
||||||
|
assertThrows(RuntimeException.class, () -> DecksCreator.loadBuildingDeck("/Cards/not_found.json"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadSlotDeck() {
|
||||||
|
List<Slot> slots = DecksCreator.loadSlotDeck();
|
||||||
|
|
||||||
|
assertNotNull(slots);
|
||||||
|
assertEquals(7, slots.size());
|
||||||
|
assertFalse(slots.contains(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user