Browse Source

refactoring: update AddPlayerTest

main
fdai7920 11 months ago
parent
commit
94fcf2b0d9
  1. 24
      src/test/java/de/hsfulda/onses/PlayerServiceTest.java

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

@ -15,11 +15,15 @@ public class PlayerServiceTest {
void addPlayerToPlayerList() {
//arrange
Player input = new Player();
Player expected = input;
boolean expected = true;
boolean answer = false;
// act
PlayerService playerservice = new PlayerService();
playerservice.addPlayerToList(input);
Player answer = playerservice.getPlayerList().getFirst();
for (Player i : playerservice.getPlayerList())
{
if (i == input) {answer = true; break;}
}
// assert
assertEquals(expected, answer);
}
@ -28,20 +32,24 @@ public class PlayerServiceTest {
@DisplayName("addMultiplePlayerToPlayerList")
void addMultiplePlayerToPlayerList() {
//arrange
boolean expected = true;
Player input1 = new Player();
Player expected1 = input1;
boolean answer1 = false;
Player input2 = new Player();
Player expected2 = input2;
boolean answer2 = false;
// act
PlayerService playerservice = new PlayerService();
playerservice.addPlayerToList(input1);
playerservice.addPlayerToList(input2);
Player answer1 = playerservice.getPlayerList().getFirst();
Player answer2 = playerservice.getPlayerList().get(1);
for (Player i : playerservice.getPlayerList())
{
if (i == input1) {answer1 = true;}
if (i == input2) {answer2 = true;}
}
// assert
assertEquals(expected1, answer1);
assertEquals(expected2, answer2);
assertEquals(expected, answer1);
assertEquals(expected, answer2);
}
@Test
@DisplayName("checkCurrentTurnAfterNextTurn")

Loading…
Cancel
Save