Fix: all building tests, Added: BuildingCardTest, Modified: ShamanicRitualTest, PlayableCardTest
This commit is contained in:
@@ -33,7 +33,12 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
|
|||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
this.prestigeValue = prestigeValue;
|
if (prestigeValue >= 0) {
|
||||||
|
this.prestigeValue = prestigeValue;
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
bought = false;
|
bought = false;
|
||||||
}
|
}
|
||||||
public BuildingCard(int effectId,EffectType effectType ,int era,int price,int prestigeValue) throws IllegalArgumentException{
|
public BuildingCard(int effectId,EffectType effectType ,int era,int price,int prestigeValue) throws IllegalArgumentException{
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Building0Test {
|
|||||||
void applyEffect() {
|
void applyEffect() {
|
||||||
int Era = 1;
|
int Era = 1;
|
||||||
// Corretta creazione / esecuzione building card
|
// Corretta creazione / esecuzione building card
|
||||||
Building0 b0 = new Building0(1, 1);
|
Building0 b0 = new Building0(1, 1, 1);
|
||||||
Player p = new Player("test");
|
Player p = new Player("test");
|
||||||
p.addFood(b0.getPrice());
|
p.addFood(b0.getPrice());
|
||||||
b0.buy(p);
|
b0.buy(p);
|
||||||
@@ -59,7 +59,7 @@ class Building0Test {
|
|||||||
assertEquals(0, p.getFoodValue());
|
assertEquals(0, p.getFoodValue());
|
||||||
|
|
||||||
// Corretta creazione / esecuzione building card
|
// Corretta creazione / esecuzione building card
|
||||||
Building0 b0 = new Building0(1, 1);
|
Building0 b0 = new Building0(1, 1, 1);
|
||||||
p.addFood(b0.getPrice());
|
p.addFood(b0.getPrice());
|
||||||
b0.buy(p);
|
b0.buy(p);
|
||||||
assertEquals(1, b0.numSet);
|
assertEquals(1, b0.numSet);
|
||||||
@@ -71,7 +71,7 @@ class Building0Test {
|
|||||||
@DisplayName("Exception Test")
|
@DisplayName("Exception Test")
|
||||||
void applyEffect3() {
|
void applyEffect3() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
Building0 b0 = new Building0(1, 1);
|
Building0 b0 = new Building0(1, 1, 1);
|
||||||
Player p = new Player("test");
|
Player p = new Player("test");
|
||||||
b0.applyEffect(p);
|
b0.applyEffect(p);
|
||||||
});
|
});
|
||||||
@@ -80,7 +80,7 @@ class Building0Test {
|
|||||||
@Test
|
@Test
|
||||||
@DisplayName("Buying Of Same Card By Two Different Players")
|
@DisplayName("Buying Of Same Card By Two Different Players")
|
||||||
void applyEffect4() {
|
void applyEffect4() {
|
||||||
Building0 b0 = new Building0(1, 1);
|
Building0 b0 = new Building0(1, 1, 1);
|
||||||
Player p1 = new Player("test1");
|
Player p1 = new Player("test1");
|
||||||
Player p2 = new Player("test2");
|
Player p2 = new Player("test2");
|
||||||
p1.addFood(b0.getPrice());
|
p1.addFood(b0.getPrice());
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Building10Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void applyEffect() {
|
void applyEffect() {
|
||||||
Building10 b10 = new Building10(1, 1);
|
Building10 b10 = new Building10(1, 1, 1);
|
||||||
Player p = new Player("test");
|
Player p = new Player("test");
|
||||||
p.addFood(b10.getPrice());
|
p.addFood(b10.getPrice());
|
||||||
b10.buy(p);
|
b10.buy(p);
|
||||||
@@ -50,7 +50,7 @@ class Building10Test {
|
|||||||
@Test
|
@Test
|
||||||
void applyEffectException() {
|
void applyEffectException() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
Building10 b10 = new Building10(1, 1);
|
Building10 b10 = new Building10(1, 1, 1);
|
||||||
Player p = new Player("test");
|
Player p = new Player("test");
|
||||||
b10.applyEffect(p);
|
b10.applyEffect(p);
|
||||||
});
|
});
|
||||||
@@ -58,7 +58,7 @@ class Building10Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void applyEffectMultiplePlayerException() {
|
void applyEffectMultiplePlayerException() {
|
||||||
Building10 b10 = new Building10(1, 1);
|
Building10 b10 = new Building10(1, 1, 1);
|
||||||
Player p1 = new Player("test1");
|
Player p1 = new Player("test1");
|
||||||
Player p2 = new Player("test2");
|
Player p2 = new Player("test2");
|
||||||
b10.buy(p1);
|
b10.buy(p1);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Building11Test {
|
|||||||
void applyEffectBuyWithoutFood() {
|
void applyEffectBuyWithoutFood() {
|
||||||
|
|
||||||
Player p1 = new Player("Xiaomi");
|
Player p1 = new Player("Xiaomi");
|
||||||
Building11 b1 = new Building11(2, 10, ARTIST, -3);
|
Building11 b1 = new Building11(2, 10, 1, ARTIST, -3);
|
||||||
Artist a1 = new Artist(2);
|
Artist a1 = new Artist(2);
|
||||||
b1.buy(p1);
|
b1.buy(p1);
|
||||||
assertFalse(b1.buy(p1));
|
assertFalse(b1.buy(p1));
|
||||||
@@ -33,7 +33,7 @@ class Building11Test {
|
|||||||
@Test
|
@Test
|
||||||
void applyEffectWithTwoCards() {
|
void applyEffectWithTwoCards() {
|
||||||
Player p2 = new Player("Giacomo");
|
Player p2 = new Player("Giacomo");
|
||||||
Building11 b2 = new Building11(2, 10, ARTIST, 4);
|
Building11 b2 = new Building11(2, 10, 1, ARTIST, 4);
|
||||||
Artist a2 = new Artist(2);
|
Artist a2 = new Artist(2);
|
||||||
Artist a3 = new Artist(2);
|
Artist a3 = new Artist(2);
|
||||||
p2.addFood(b2.getPrice());
|
p2.addFood(b2.getPrice());
|
||||||
@@ -50,7 +50,7 @@ class Building11Test {
|
|||||||
void applyEffectTwoPlayersBuyTheSameCard() {
|
void applyEffectTwoPlayersBuyTheSameCard() {
|
||||||
Player p3 = new Player("AAAAAAAAAA");
|
Player p3 = new Player("AAAAAAAAAA");
|
||||||
Player p4 = new Player("BBBBBBBBBB");
|
Player p4 = new Player("BBBBBBBBBB");
|
||||||
Building11 b3 = new Building11(1, 15, HUNTER, 5);
|
Building11 b3 = new Building11(1, 15, 1, HUNTER, 5);
|
||||||
p3.addFood(b3.getPrice());
|
p3.addFood(b3.getPrice());
|
||||||
assertTrue(b3.buy(p3));
|
assertTrue(b3.buy(p3));
|
||||||
p4.addFood(b3.getPrice());
|
p4.addFood(b3.getPrice());
|
||||||
@@ -61,7 +61,7 @@ class Building11Test {
|
|||||||
@Test
|
@Test
|
||||||
void applyEffectApplyEffectWithoutBuyingFirst() {
|
void applyEffectApplyEffectWithoutBuyingFirst() {
|
||||||
Player p5 = new Player("DRTFGBHJN");
|
Player p5 = new Player("DRTFGBHJN");
|
||||||
Building11 b4 = new Building11(3, 10, ARTIST, 4);
|
Building11 b4 = new Building11(3, 10, 1, ARTIST, 4);
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
b4.applyEffect(p5);
|
b4.applyEffect(p5);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,26 +11,26 @@ class Building13Test {
|
|||||||
@Test
|
@Test
|
||||||
void Building13() {
|
void Building13() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
Building13 b2 = new Building13(0, 15);
|
Building13 b2 = new Building13(0, 15, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
Building13 b3 = new Building13(-1, 15);
|
Building13 b3 = new Building13(-1, 15, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
Building13 b4 = new Building13(4, 15);
|
Building13 b4 = new Building13(4, 15, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
Building13 b5 = new Building13(2, 0);
|
Building13 b5 = new Building13(2, 0, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
Building13 b6 = new Building13(1, -15);
|
Building13 b6 = new Building13(1, -15, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
Building13 b1 = new Building13(1, 10);
|
Building13 b1 = new Building13(1, 10, 1);
|
||||||
assertEquals(1, b1.getEra());
|
assertEquals(1, b1.getEra());
|
||||||
|
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ class Building13Test {
|
|||||||
void applyEffect() {
|
void applyEffect() {
|
||||||
Player p1 = new Player("gigi");
|
Player p1 = new Player("gigi");
|
||||||
p1.addPrestige(10);
|
p1.addPrestige(10);
|
||||||
Building13 b1 = new Building13(1, 10);
|
Building13 b1 = new Building13(1, 10, 1);
|
||||||
p1.addFood(b1.getPrice());
|
p1.addFood(b1.getPrice());
|
||||||
b1.buy(p1);
|
b1.buy(p1);
|
||||||
|
|
||||||
@@ -51,14 +51,14 @@ class Building13Test {
|
|||||||
@Test
|
@Test
|
||||||
void applyEffectException() {
|
void applyEffectException() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
Building13 b13 = new Building13(1, 10);
|
Building13 b13 = new Building13(1, 10, 1);
|
||||||
Player p = new Player("test");
|
Player p = new Player("test");
|
||||||
b13.applyEffect(p);
|
b13.applyEffect(p);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void applyEffectMultiplePlayerException() {
|
void applyEffectMultiplePlayerException() {
|
||||||
Building13 b13 = new Building13(1, 10);
|
Building13 b13 = new Building13(1, 10, 1);
|
||||||
Player p1 = new Player("test1");
|
Player p1 = new Player("test1");
|
||||||
Player p2 = new Player("test2");
|
Player p2 = new Player("test2");
|
||||||
b13.buy(p1);
|
b13.buy(p1);
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class Building1Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getIcon() {
|
||||||
|
// NO TEST NEEDED
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ class Building4Test {
|
|||||||
@Test
|
@Test
|
||||||
void buy() {
|
void buy() {
|
||||||
Player p = new Player("test");
|
Player p = new Player("test");
|
||||||
Building4 b4 = new Building4(1,1);
|
Building4 b4 = new Building4(1, 1,1);
|
||||||
|
|
||||||
assertFalse(b4.buy(p));
|
assertFalse(b4.buy(p));
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ class Building4Test {
|
|||||||
void applyEffect() {
|
void applyEffect() {
|
||||||
Player p = new Player("test");
|
Player p = new Player("test");
|
||||||
p.addFood(1);
|
p.addFood(1);
|
||||||
Building4 b4 = new Building4(1,1);
|
Building4 b4 = new Building4(1,1, 1);
|
||||||
b4.buy(p);
|
b4.buy(p);
|
||||||
|
|
||||||
b4.applyEffect(p);
|
b4.applyEffect(p);
|
||||||
@@ -50,7 +50,7 @@ class Building4Test {
|
|||||||
new Inventor(1,1).insert(p2);
|
new Inventor(1,1).insert(p2);
|
||||||
new Inventor(1,1).insert(p2);
|
new Inventor(1,1).insert(p2);
|
||||||
p2.addFood(1);
|
p2.addFood(1);
|
||||||
Building4 b4b = new Building4(1,1);
|
Building4 b4b = new Building4(1,1, 1);
|
||||||
b4b.buy(p2);
|
b4b.buy(p2);
|
||||||
b4b.applyEffect(p2);
|
b4b.applyEffect(p2);
|
||||||
assertEquals(0, p2.getFoodValue());
|
assertEquals(0, p2.getFoodValue());
|
||||||
@@ -60,7 +60,7 @@ class Building4Test {
|
|||||||
@Test
|
@Test
|
||||||
void applyEffectException() {
|
void applyEffectException() {
|
||||||
Player p = new Player("test");
|
Player p = new Player("test");
|
||||||
Building4 b4 = new Building4(1,1);
|
Building4 b4 = new Building4(1,1, 1);
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class, () -> b4.applyEffect(p));
|
assertThrows(IllegalArgumentException.class, () -> b4.applyEffect(p));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class Building8Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void applyEffect() {
|
void applyEffect() {
|
||||||
Building8 b8 = new Building8(1, 1);
|
Building8 b8 = new Building8(1, 1, 1);
|
||||||
Player p = new Player("test");
|
Player p = new Player("test");
|
||||||
p.addFood(b8.getPrice());
|
p.addFood(b8.getPrice());
|
||||||
b8.buy(p);
|
b8.buy(p);
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package it.polimi.ingsw.gc14.Model.Cards;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class BuildingCardTest {
|
||||||
|
@Test
|
||||||
|
void checkOnParameters() { // ERA CHECKED IN PlayableCardTest
|
||||||
|
assertDoesNotThrow(() -> {
|
||||||
|
new BuildingCard(1, 1,1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assertDoesNotThrow(() -> {
|
||||||
|
new BuildingCard(1, 2,1);
|
||||||
|
});
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
|
new BuildingCard(1, 0,1);
|
||||||
|
});
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
|
new BuildingCard(1, -1,1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assertDoesNotThrow(() -> {
|
||||||
|
new BuildingCard(1, 1,2);
|
||||||
|
});
|
||||||
|
assertDoesNotThrow(() -> {
|
||||||
|
new BuildingCard(1, 1,0);
|
||||||
|
});
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
|
new BuildingCard(1, 1,-1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -64,7 +64,7 @@ class ShamanicRitualTest {
|
|||||||
new Shaman(1, 3).insert(p1);
|
new Shaman(1, 3).insert(p1);
|
||||||
new Shaman(1, 1).insert(p2);
|
new Shaman(1, 1).insert(p2);
|
||||||
|
|
||||||
BuildingCard b = new BuildingCard(6, EffectType.ON_EVENT, 1, 5);
|
BuildingCard b = new BuildingCard(6, EffectType.ON_EVENT, 1, 5, 1);
|
||||||
p1.addFood(5);
|
p1.addFood(5);
|
||||||
b.buy(p1);
|
b.buy(p1);
|
||||||
|
|
||||||
|
|||||||
@@ -11,23 +11,23 @@ class PlayableCardTest {
|
|||||||
@Test
|
@Test
|
||||||
void PlayableCardWrongEraException() {
|
void PlayableCardWrongEraException() {
|
||||||
assertDoesNotThrow(() -> {
|
assertDoesNotThrow(() -> {
|
||||||
new BuildingCard(1, 5);
|
new BuildingCard(1, 5, 1);
|
||||||
});
|
});
|
||||||
assertDoesNotThrow(() -> {
|
assertDoesNotThrow(() -> {
|
||||||
new BuildingCard(2, 5);
|
new BuildingCard(2, 5, 1);
|
||||||
});
|
});
|
||||||
assertDoesNotThrow(() -> {
|
assertDoesNotThrow(() -> {
|
||||||
new BuildingCard(3, 5);
|
new BuildingCard(3, 5, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
new BuildingCard(0, 5);
|
new BuildingCard(0, 5, 1);
|
||||||
});
|
});
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
new BuildingCard(4, 5);
|
new BuildingCard(4, 5, 1);
|
||||||
});
|
});
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
new BuildingCard(-1, 5);
|
new BuildingCard(-1, 5, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user