Browse Source

remove AddOpponents + Tests

main
fdai7920 11 months ago
parent
commit
b3e8d49aec
  1. 7
      src/main/java/de/hsfulda/onses/services/PlayerService.java
  2. 66
      src/test/java/de/hsfulda/onses/PlayerServiceTest.java

7
src/main/java/de/hsfulda/onses/services/PlayerService.java

@ -18,13 +18,6 @@ public class PlayerService {
totalTurns++;
}
// button on gui activates it
public void addOpponents(int amount) {
for (int i=0; i<amount; i++)
{
addPlayerToList(new Player());
}
}
// decides which Player is currently at their turn -> 0 = main Player (skip -> 2x nextTurn())
// possible: at start of game random int generator from 0-max to decide who starts first

66
src/test/java/de/hsfulda/onses/PlayerServiceTest.java

@ -43,70 +43,4 @@ public class PlayerServiceTest {
assertEquals(expected1, answer1);
assertEquals(expected2, answer2);
}
@Test
@DisplayName("addAmountOfOpponents")
void addAmountOfOpponents() {
//arrange
int input = 3;
int expected = 3;
// act
PlayerService playerservice = new PlayerService();
int before = playerservice.getPlayerList().size();
playerservice.addOpponents(input);
int after = playerservice.getPlayerList().size();
int answer = after - before;
// assert
assertEquals(expected, answer);
}
@Test
@DisplayName("TotalTurnsEqualsAmountPlayers")
void totalTurnsEqualsAmountPlayers() {
// act
PlayerService playerservice = new PlayerService();
playerservice.addPlayerToList(new Player());
playerservice.addOpponents(3);
int expected = playerservice.getPlayerList().size();
int answer = playerservice.getTotalTurns();
// assert
assertEquals(expected, answer);
}
@Test
@DisplayName("currentTurnsSwitching")
void currentTurnsSwitching4Players() {
// arrange
int expected = 2;
// act
PlayerService playerservice = new PlayerService();
playerservice.addPlayerToList(new Player());
playerservice.addOpponents(3);
for (int i=0; i < expected; i++){ playerservice.nextTurn(); }
int answer = playerservice.getCurrentTurn();
// assert
assertEquals(expected, answer);
}
@Test
@DisplayName("currentTurnsResettingAfterAfterTotalTurns")
void currentTurnsResettingAfterTotalTurns() {
// arrange
int expected = 0;
// act
PlayerService playerservice = new PlayerService();
playerservice.addPlayerToList(new Player());
playerservice.addOpponents(3);
int totalTurns = playerservice.getTotalTurns();
for (int i=0; i < totalTurns; i++){ playerservice.nextTurn(); }
int answer = playerservice.getCurrentTurn();
// assert
assertEquals(expected, answer);
}
}
Loading…
Cancel
Save