Skip to content

Commit

Permalink
MultiplayerSession Unit Tests - PlayerService(score)
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoDiNu committed Apr 26, 2024
1 parent dfd89ec commit 05e25ee
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/test/java/com/uniovi/Wiq_UnitTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.uniovi.components.generators.geography.ContinentQuestionGeneration;
import com.uniovi.entities.*;
import com.uniovi.services.*;
import jakarta.validation.constraints.AssertTrue;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -1767,6 +1768,42 @@ public void PlayerServiceImpl_getUsersByMultiplayerCode_ReturnsEmpty() {
Assertions.assertTrue(result.isEmpty());
}

@Test
@Order(110)
public void PlayerServiceImpl_setANDgetScoreMultiplayerCode() {
Long playerId = 1L;
Player player = createPlayer();
player.setId(playerId);

player.setMultiplayerCode(123);
playerRepository.save(player);

String score = "100";
playerService.setScoreMultiplayerCode(playerId, score);

String result = playerService.getScoreMultiplayerCode(playerId);

Assertions.assertEquals(score, result);
}

@Test
@Order(111)
public void PlayerServiceImpl_setANDgetScoreMultiplayerCode_EmptyPlayer() {
Long playerId = 5L;

String score = "100";
playerService.setScoreMultiplayerCode(playerId, score);

String result = playerService.getScoreMultiplayerCode(playerId);

Assertions.assertEquals("", result);
}







/**
* Sends an HTTP request to the API
Expand Down

0 comments on commit 05e25ee

Please sign in to comment.