Skip to content

Commit

Permalink
Merge pull request #8 from qwrwtdycuvjbk/patch-7
Browse files Browse the repository at this point in the history
Create LobbyTest.java
  • Loading branch information
qwrwtdycuvjbk authored Apr 29, 2024
2 parents 68c2ec3 + f40aaa2 commit 86e2ff0
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/test/java/wordsearch/LobbyTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

public class LobbyTest {

private Lobby lobby;
private Player player1;
private Player player2;
private ChatMessages chatMessage;


public void setUp() {

lobby = new Lobby("lobbyUUID");

player1 = new Player("uuid1", null);
player2 = new Player("uuid2", null);

lobby.addPlayer(player1);
lobby.addPlayer(player2);

chatMessage = new ChatMessages("lobbyUUID", "uuid1", "Hello, world!");
}

@Test
public void testAddPlayer() {

assertEquals(2, lobby.getPlayerCount());
lobby.addPlayer(player1);
assertEquals(2, lobby.getPlayerCount());
}

@Test
public void testAddChatMessage() {

lobby.addChatMessage(chatMessage);
assertEquals(1, lobby.getChatMessages().size());
}

@Test
public void testGetPlayerByUUID() {

assertEquals(player1, lobby.getPlayerByUUID("uuid1"));

assertNull(lobby.getPlayerByUUID("nonExistentUUID"));
}

@Test
public void testDisplayChatMessage() {

String expectedChatLog = "Player1: Hello, world!";
assertEquals(expectedChatLog, lobby.displayChatMessage(chatMessage));
}

@Test
public void testCheckGameModeFull() {
player1.setGameMode(GameMode.DUOS);
lobby.addPlayer(player1);

assertEquals(1, lobby.getPlayerCount());
}
}

0 comments on commit 86e2ff0

Please sign in to comment.