Fix: ShamanicRitualTest
This commit is contained in:
+90
-7
@@ -1,5 +1,9 @@
|
||||
package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.Building.Effects.Building1;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -12,6 +16,17 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class SustenanceTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("Testing constructor")
|
||||
void testConstructor() {
|
||||
int era = 1;
|
||||
int prestigeDebt = 5;
|
||||
// Gli attributi di Sustenance era e EventType vengono testati in EventCardTest.
|
||||
|
||||
Sustenance s = new Sustenance(era, prestigeDebt);
|
||||
assertEquals(prestigeDebt, s.getPrestigeDebt());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Exception Test Null List")
|
||||
void test_null() {
|
||||
@@ -22,18 +37,86 @@ class SustenanceTest {
|
||||
});
|
||||
}
|
||||
|
||||
// TODO
|
||||
// Mancano i metodi di play, il player non ha carte e non può giocare al momento
|
||||
@Test
|
||||
@DisplayName("No edge case")
|
||||
void activateEvent() {
|
||||
Player p1 = new Player("p1");
|
||||
Player p2 = new Player("p2");
|
||||
Player p1 = new Player("marco");
|
||||
Player p2 = new Player("giacomo");
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1,p2));
|
||||
Sustenance s = new Sustenance(1,1);
|
||||
|
||||
p1.addFood(4);
|
||||
p1.inventors.add(new Inventor(1, 1));
|
||||
p1.shamans.add(new Shaman(1, 5));
|
||||
p1.builders.add(new Builder(1, 5, 5));
|
||||
p1.artists.add(new Artist(1));
|
||||
p1.hunters.add(new Hunter(1, true));
|
||||
p1.gatherers.add(new Gatherer(1));
|
||||
|
||||
p2.addFood(1);
|
||||
p2.artists.add(new Artist(1));
|
||||
p2.hunters.add(new Hunter(1, true));
|
||||
|
||||
|
||||
Sustenance s = new Sustenance(1,2);
|
||||
s.activateEvent(players);
|
||||
assertEquals(0, p1.getFoodValue());
|
||||
assertEquals(1, p1.getFoodValue());
|
||||
assertEquals(0, p2.getFoodValue());
|
||||
assertEquals(0, p1.getPrestigeValue());
|
||||
assertEquals(-2, p2.getPrestigeValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Building 1 testing")
|
||||
void activateEvent2() {
|
||||
Player p1 = new Player("marco");
|
||||
Player p2 = new Player("giacomo");
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1,p2));
|
||||
|
||||
p1.addFood(5);
|
||||
p1.inventors.add(new Inventor(1, 1));
|
||||
p1.shamans.add(new Shaman(1, 5));
|
||||
p1.builders.add(new Builder(1, 5, 5));
|
||||
p1.artists.add(new Artist(1));
|
||||
p1.hunters.add(new Hunter(1, true));
|
||||
p1.gatherers.add(new Gatherer(1));
|
||||
|
||||
p2.addFood(2);
|
||||
p2.artists.add(new Artist(1));
|
||||
p2.artists.add(new Artist(1));
|
||||
p2.artists.add(new Artist(1));
|
||||
|
||||
|
||||
Building1 bd1 = new Building1(1, 1, 1, CharacterType.SHAMAN);
|
||||
Building1 bd2 = new Building1(1, 1, 1, CharacterType.ARTIST);
|
||||
|
||||
bd1.buy(p1);
|
||||
bd2.buy(p2);
|
||||
|
||||
Sustenance s = new Sustenance(1,2);
|
||||
s.activateEvent(players);
|
||||
assertEquals(2, p1.getFoodValue());
|
||||
assertEquals(1, p2.getFoodValue());
|
||||
assertEquals(0, p1.getPrestigeValue());
|
||||
assertEquals(0, p2.getPrestigeValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Clone testing")
|
||||
void cloneTest() {
|
||||
int era = 1;
|
||||
int prestigeDebt = 5;
|
||||
|
||||
|
||||
Sustenance s1 = new Sustenance(era, prestigeDebt);
|
||||
Sustenance s2 = (Sustenance) s1.clone();
|
||||
|
||||
assertEquals(era, s2.getEra());
|
||||
assertEquals(EventType.SUSTENANCE, s2.getType());
|
||||
assertEquals(prestigeDebt, s2.getPrestigeDebt());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user