-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from qwrwtdycuvjbk/patch-7
Create LobbyTest.java
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |