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

Loading…
Cancel
Save