Skip to content

Commit

Permalink
Unit test for Scoreboard
Browse files Browse the repository at this point in the history
  • Loading branch information
rakshyab02 committed Aug 1, 2024
1 parent 8d0d414 commit 5a1b2ce
Showing 1 changed file with 23 additions and 29 deletions.
52 changes: 23 additions & 29 deletions src/test/java/uta/cse3310/ScoreboardTest.java
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
package uta.cse3310;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import static org.junit.jupiter.api.Assertions.*;
import java.util.List;

class ScoreboardTest {

private Scoreboard scoreboard;

@BeforeEach
void setUp() {
scoreboard = new Scoreboard();
}
@Test
void testUpdateScoreboard() {
Scoreboard scoreboard = new Scoreboard();
Player player1 = new Player("1", "Player1");
player1.updateScore(100);
scoreboard.updateScoreboard(player1);

@Test
void testUpdateScoreboard() {
Player player1 = new Player("1", "Player1");
player1.updateScore(100);
scoreboard.updateScoreboard(player1);
List<Player> topPlayers = scoreboard.getTopPlayers();
assertEquals(1, topPlayers.size());
assertEquals("Player1", topPlayers.get(0).getName());
assertEquals(100, topPlayers.get(0).getScore());
}

List<Player> topPlayers = scoreboard.getTopPlayers();
assertEquals(1, topPlayers.size());
assertEquals("Player1", topPlayers.get(0).getName());
assertEquals(100, topPlayers.get(0).getScore());
@Test
void testTopPlayersLimit() {
Scoreboard scoreboard = new Scoreboard();
for (int i = 0; i < 15; i++) {
Player player = new Player(String.valueOf(i), "Player" + i);
player.updateScore(i * 100);
scoreboard.updateScoreboard(player);
}

@Test
void testTopPlayersLimit() {
for (int i = 0; i < 15; i++) {
Player player = new Player(String.valueOf(i), "Player" + i);
player.updateScore(i * 100);
scoreboard.updateScoreboard(player);
}

List<Player> topPlayers = scoreboard.getTopPlayers();
assertEquals(10, topPlayers.size());
assertEquals(1400, topPlayers.get(0).getScore());
}
}
List<Player> topPlayers = scoreboard.getTopPlayers();
assertEquals(10, topPlayers.size());
assertEquals(1400, topPlayers.get(0).getScore());
}
}

0 comments on commit 5a1b2ce

Please sign in to comment.