Add: CurrentStateTest.java; FIx: Added round Init In CurrentState's Constructor
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
package it.polimi.ingsw.gc14.Model.GamePackage;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import it.polimi.ingsw.gc14.Model.Slot;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class CurrentStateTest {
|
||||
|
||||
@Test
|
||||
void getCurrentPlayer() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('A');
|
||||
CurrentState curr = new CurrentState();
|
||||
curr.PlayerUpdate(p, s);
|
||||
assertEquals(p, curr.getCurrentPlayer());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSlot() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('A');
|
||||
CurrentState curr = new CurrentState();
|
||||
curr.PlayerUpdate(p, s);
|
||||
assertEquals(s, curr.getSlot());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getEra() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('A');
|
||||
CurrentState curr = new CurrentState();
|
||||
curr.PlayerUpdate(p, s);
|
||||
curr.EraUpdate();
|
||||
assertEquals(2, curr.getEra());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getRound() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('A');
|
||||
CurrentState curr = new CurrentState();
|
||||
curr.PlayerUpdate(p, s);
|
||||
curr.RoundUpdate();
|
||||
assertEquals(1, curr.getRound());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNUpper() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('A');
|
||||
CurrentState curr = new CurrentState();
|
||||
curr.PlayerUpdate(p, s);
|
||||
curr.UpperDrawn();
|
||||
assertEquals(-1, curr.getNUpper());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNLower() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('A');
|
||||
CurrentState curr = new CurrentState();
|
||||
curr.PlayerUpdate(p, s);
|
||||
curr.LowerDrawn();
|
||||
assertEquals(-1, curr.getNLower());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getGameStage() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('A');
|
||||
GameStages g = GameStages.RESOLVING_ACTIONS;
|
||||
CurrentState curr = new CurrentState();
|
||||
curr.PlayerUpdate(p, s);
|
||||
curr.GameStageUpdate(g);
|
||||
assertEquals(g, curr.getGameStage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void eraUpdate() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('A');
|
||||
CurrentState curr = new CurrentState();
|
||||
curr.PlayerUpdate(p, s);
|
||||
curr.EraUpdate();
|
||||
assertEquals(2, curr.getEra());
|
||||
}
|
||||
|
||||
@Test
|
||||
void roundUpdate() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('A');
|
||||
CurrentState curr = new CurrentState();
|
||||
curr.PlayerUpdate(p, s);
|
||||
curr.RoundUpdate();
|
||||
assertEquals(1, curr.getRound());
|
||||
}
|
||||
|
||||
@Test
|
||||
void upperDrawn() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('A');
|
||||
CurrentState curr = new CurrentState();
|
||||
curr.PlayerUpdate(p, s);
|
||||
curr.UpperDrawn();
|
||||
assertEquals(-1, curr.getNUpper());
|
||||
}
|
||||
|
||||
@Test
|
||||
void lowerDrawn() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('A');
|
||||
CurrentState curr = new CurrentState();
|
||||
curr.PlayerUpdate(p, s);
|
||||
curr.LowerDrawn();
|
||||
curr.LowerDrawn();
|
||||
assertEquals(-2, curr.getNLower());
|
||||
}
|
||||
|
||||
@Test
|
||||
void gameStageUpdate() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('A');
|
||||
GameStages g = GameStages.RESOLVING_ACTIONS;
|
||||
CurrentState curr = new CurrentState();
|
||||
assertEquals(GameStages.WAITING, curr.getGameStage());
|
||||
curr.PlayerUpdate(p, s);
|
||||
curr.GameStageUpdate(g);
|
||||
assertEquals(GameStages.RESOLVING_ACTIONS, curr.getGameStage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void playerUpdate() {
|
||||
Player p = new Player("test");
|
||||
Slot s = new Slot('C');
|
||||
CurrentState curr = new CurrentState();
|
||||
curr.PlayerUpdate(p, s);
|
||||
assertEquals(p, curr.getCurrentPlayer());
|
||||
assertEquals(s, curr.getSlot());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user