Fix: Building10, Building13, Building10Test, Building11Test, Building13Test, Building4Test, Building8Test
This commit is contained in:
@@ -16,7 +16,7 @@ public class Building10 extends BuildingCard {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public BuildingCard clone() {
|
public BuildingCard clone() {
|
||||||
return new Building8(getEra(),getPrice(),getPrestigeValue());
|
return new Building10(getEra(),getPrice(),getPrestigeValue());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void applyEffect(Player player) throws IllegalArgumentException {
|
public void applyEffect(Player player) throws IllegalArgumentException {
|
||||||
|
|||||||
@@ -22,6 +22,6 @@ public class Building13 extends BuildingCard{
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Era:"+String.valueOf(getEra())+"\nPrice:"+String.valueOf(getPrice())+"\n";
|
return "Era:"+String.valueOf(getEra())+"\nPrice:"+String.valueOf(getPrice())+"\nPrestige:"+String.valueOf(getPrestigeValue()+"\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
||||||
|
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
|
||||||
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;
|
||||||
@@ -10,6 +12,38 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
|
|
||||||
class Building10Test {
|
class Building10Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing constructor")
|
||||||
|
void testConstructor() {
|
||||||
|
int era = 1;
|
||||||
|
int price = 10;
|
||||||
|
int prestigeValue = 5;
|
||||||
|
|
||||||
|
Building10 b0 = new Building10(era, price, prestigeValue);
|
||||||
|
|
||||||
|
assertEquals(EffectType.FINAL, b0.getEffectType());
|
||||||
|
assertEquals(10, b0.getEffectId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing clone method")
|
||||||
|
void testClone() {
|
||||||
|
int effectID = 10;
|
||||||
|
EffectType effectType = EffectType.FINAL;
|
||||||
|
int era = 1;
|
||||||
|
int price = 1;
|
||||||
|
int prestigeValue = 1;
|
||||||
|
Building10 b0 = new Building10(era, price, prestigeValue);
|
||||||
|
|
||||||
|
Building10 b1 = (Building10) b0.clone();
|
||||||
|
|
||||||
|
assertEquals(effectID, b1.getEffectId());
|
||||||
|
assertEquals(effectType, b1.getEffectType());
|
||||||
|
assertEquals(era, b1.getEra());
|
||||||
|
assertEquals(price, b1.getPrice());
|
||||||
|
assertEquals(prestigeValue, b1.getPrestigeValue());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void applyEffect() {
|
void applyEffect() {
|
||||||
Building10 b10 = new Building10(1, 1, 1);
|
Building10 b10 = new Building10(1, 1, 1);
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
||||||
|
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Artist;
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Artist;
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Hunter;
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Hunter;
|
||||||
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 static it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType.ARTIST;
|
import static it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType.ARTIST;
|
||||||
@@ -11,6 +14,46 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
|
|
||||||
class Building11Test {
|
class Building11Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing constructor")
|
||||||
|
void testConstructor() {
|
||||||
|
int era = 1;
|
||||||
|
int price = 10;
|
||||||
|
int prestigeValue = 5;
|
||||||
|
CharacterType ct = CharacterType.ARTIST;
|
||||||
|
int pm = 5;
|
||||||
|
|
||||||
|
Building11 b0 = new Building11(era, price, prestigeValue, ct, pm);
|
||||||
|
|
||||||
|
assertEquals(EffectType.FINAL, b0.getEffectType());
|
||||||
|
assertEquals(11, b0.getEffectId());
|
||||||
|
assertEquals(ct, b0.getIcon());
|
||||||
|
assertEquals(pm, b0.getPrestigeMul());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing clone method")
|
||||||
|
void testClone() {
|
||||||
|
int effectID = 11;
|
||||||
|
EffectType effectType = EffectType.FINAL;
|
||||||
|
int era = 1;
|
||||||
|
int price = 1;
|
||||||
|
int prestigeValue = 1;
|
||||||
|
CharacterType ct = CharacterType.ARTIST;
|
||||||
|
int pm = 5;
|
||||||
|
Building11 b0 = new Building11(era, price, prestigeValue, ct, pm);
|
||||||
|
|
||||||
|
Building11 b1 = (Building11) b0.clone();
|
||||||
|
|
||||||
|
assertEquals(effectID, b1.getEffectId());
|
||||||
|
assertEquals(effectType, b1.getEffectType());
|
||||||
|
assertEquals(era, b1.getEra());
|
||||||
|
assertEquals(price, b1.getPrice());
|
||||||
|
assertEquals(prestigeValue, b1.getPrestigeValue());
|
||||||
|
assertEquals(ct, b0.getIcon());
|
||||||
|
assertEquals(pm, b0.getPrestigeMul());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void applyEffectBuyWithoutFood() {
|
void applyEffectBuyWithoutFood() {
|
||||||
|
|
||||||
|
|||||||
+36
-23
@@ -1,39 +1,44 @@
|
|||||||
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
||||||
|
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
|
||||||
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 static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
class Building13Test {
|
class Building13Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing constructor")
|
||||||
|
void testConstructor() {
|
||||||
|
int era = 1;
|
||||||
|
int price = 10;
|
||||||
|
int prestigeValue = 5;
|
||||||
|
|
||||||
|
Building13 b0 = new Building13(era, price, prestigeValue);
|
||||||
|
|
||||||
|
assertEquals(EffectType.FINAL, b0.getEffectType());
|
||||||
|
assertEquals(13, b0.getEffectId());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void Building13() {
|
@DisplayName("Testing clone method")
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
void testClone() {
|
||||||
Building13 b2 = new Building13(0, 15, 1);
|
int effectID = 13;
|
||||||
});
|
EffectType effectType = EffectType.FINAL;
|
||||||
|
int era = 1;
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
int price = 1;
|
||||||
Building13 b3 = new Building13(-1, 15, 1);
|
int prestigeValue = 1;
|
||||||
});
|
Building13 b0 = new Building13(era, price,prestigeValue);
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
Building13 b4 = new Building13(4, 15, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
Building13 b5 = new Building13(2, 0, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class, () -> {
|
|
||||||
Building13 b6 = new Building13(1, -15, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
Building13 b1 = new Building13(1, 10, 1);
|
|
||||||
assertEquals(1, b1.getEra());
|
|
||||||
|
|
||||||
|
Building13 b1 = (Building13) b0.clone();
|
||||||
|
|
||||||
|
assertEquals(effectID, b1.getEffectId());
|
||||||
|
assertEquals(effectType, b1.getEffectType());
|
||||||
|
assertEquals(era, b1.getEra());
|
||||||
|
assertEquals(price, b1.getPrice());
|
||||||
|
assertEquals(prestigeValue, b1.getPrestigeValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -64,4 +69,12 @@ class Building13Test {
|
|||||||
b13.buy(p1);
|
b13.buy(p1);
|
||||||
assertFalse(b13.buy(p2));
|
assertFalse(b13.buy(p2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing toString method")
|
||||||
|
void testToString() {
|
||||||
|
Building13 b0 = new Building13(1, 2,3);
|
||||||
|
|
||||||
|
assertEquals("Era:1\nPrice:2\nPrestige:3\n", b0.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@ class Building4Test {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@DisplayName("Testing buy method")
|
||||||
void buy() {
|
void buy() {
|
||||||
Player p = new Player("test");
|
Player p = new Player("test");
|
||||||
Building4 b4 = new Building4(1, 1,1);
|
Building4 b4 = new Building4(1, 1,1);
|
||||||
|
|||||||
@@ -1,13 +1,47 @@
|
|||||||
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
||||||
|
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
|
||||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Builder;
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Builder;
|
||||||
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 static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
class Building8Test {
|
class Building8Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing constructor")
|
||||||
|
void testConstructor() {
|
||||||
|
int era = 1;
|
||||||
|
int price = 10;
|
||||||
|
int prestigeValue = 5;
|
||||||
|
|
||||||
|
Building8 b0 = new Building8(era, price, prestigeValue);
|
||||||
|
|
||||||
|
assertEquals(EffectType.FINAL, b0.getEffectType());
|
||||||
|
assertEquals(8, b0.getEffectId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Testing clone method")
|
||||||
|
void testClone() {
|
||||||
|
int effectID = 8;
|
||||||
|
EffectType effectType = EffectType.FINAL;
|
||||||
|
int era = 1;
|
||||||
|
int price = 1;
|
||||||
|
int prestigeValue = 1;
|
||||||
|
Building8 b0 = new Building8(era, price,prestigeValue);
|
||||||
|
|
||||||
|
Building8 b1 = (Building8) b0.clone();
|
||||||
|
|
||||||
|
assertEquals(effectID, b1.getEffectId());
|
||||||
|
assertEquals(effectType, b1.getEffectType());
|
||||||
|
assertEquals(era, b1.getEra());
|
||||||
|
assertEquals(price, b1.getPrice());
|
||||||
|
assertEquals(prestigeValue, b1.getPrestigeValue());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void applyEffect() {
|
void applyEffect() {
|
||||||
Building8 b8 = new Building8(1, 1, 1);
|
Building8 b8 = new Building8(1, 1, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user