Fix: Building4, Building4Test added
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Inventor;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class Building4Test {
|
||||
|
||||
@Test
|
||||
void buy() {
|
||||
Player p = new Player("test");
|
||||
Building4 b4 = new Building4(1,1);
|
||||
|
||||
assertFalse(b4.buy(p));
|
||||
|
||||
p.addFood(1);
|
||||
assertTrue(b4.buy(p));
|
||||
assertEquals(0, p.getFoodValue());
|
||||
|
||||
p.addFood(1);
|
||||
assertFalse(b4.buy(p));
|
||||
}
|
||||
|
||||
@Test
|
||||
void applyEffect() {
|
||||
Player p = new Player("test");
|
||||
p.addFood(1);
|
||||
Building4 b4 = new Building4(1,1);
|
||||
b4.buy(p);
|
||||
|
||||
b4.applyEffect(p);
|
||||
assertEquals(0, p.getFoodValue());
|
||||
|
||||
new Inventor(1,1).insert(p);
|
||||
new Inventor(1,1).insert(p);
|
||||
b4.applyEffect(p);
|
||||
assertEquals(3, p.getFoodValue());
|
||||
|
||||
b4.applyEffect(p);
|
||||
assertEquals(3, p.getFoodValue());
|
||||
|
||||
new Inventor(1,2).insert(p);
|
||||
new Inventor(1,2).insert(p);
|
||||
b4.applyEffect(p);
|
||||
assertEquals(6, p.getFoodValue());
|
||||
|
||||
Player p2 = new Player("test2");
|
||||
new Inventor(1,1).insert(p2);
|
||||
new Inventor(1,1).insert(p2);
|
||||
p2.addFood(1);
|
||||
Building4 b4b = new Building4(1,1);
|
||||
b4b.buy(p2);
|
||||
b4b.applyEffect(p2);
|
||||
assertEquals(0, p2.getFoodValue());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void applyEffectException() {
|
||||
Player p = new Player("test");
|
||||
Building4 b4 = new Building4(1,1);
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> b4.applyEffect(p));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user