Add: CurrentStateTest.java; FIx: Added round Init In CurrentState's Constructor

This commit is contained in:
GabrieleRadice
2026-03-27 19:08:56 +01:00
parent 197713800e
commit 535f8d73ff
2 changed files with 144 additions and 0 deletions
@@ -66,10 +66,12 @@ public class CurrentState {
// endregion setters
// region Constructors
// TODO controllare valori di NUpper, NLower, Round
public CurrentState(){
this.player = null;
this.slot = null;
this.Era = 1;
this.round = 0;
this.NUpper = 0;
this.NLower = 0;
this.GameStage = GameStages.WAITING;
@@ -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());
}
}