Skip to content

Commit

Permalink
Fixed errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerc22 committed Jul 29, 2024
1 parent f7b58f2 commit 240007f
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/test/java/uta/cse3310/GameSessionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
import java.util.HashMap;
import java.util.Map;

import junit.framework.Test;

//import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
//import junit.framework.TestSuite;
import org.java_websocket.WebSocket;
import org.java_websocket.handshake.ClientHandshake;
import org.java_websocket.server.WebSocketServer;
import org.junit.jupiter.api.BeforeEach;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

import static org.mockito.Mockito.*;

Expand All @@ -20,6 +26,7 @@ public class GameSessionTest extends TestCase {
private Player mockPlayer1;
private Player mockPlayer2;

@BeforeEach
@Override
protected void setUp() throws Exception {
super.setUp();
Expand All @@ -39,6 +46,7 @@ protected void setUp() throws Exception {
gameSession.playerConnections.put(mockSocket2, mockPlayer2);
}

@Test
public void testAssignPlayerToSession() {
gameSession.assignPlayerToSession(mockSocket1);

Expand All @@ -48,6 +56,7 @@ public void testAssignPlayerToSession() {
assertTrue(session.hasPlayer(mockPlayer1));
}

@Test
public void testRemovePlayerFromSession() {
GameSession.Session session = gameSession.getAvailableSession();
session.addPlayer(mockPlayer1);
Expand All @@ -57,6 +66,7 @@ public void testRemovePlayerFromSession() {
assertFalse(session.hasPlayer(mockPlayer1));
}

@Test
public void testHandleNextRound() {
GameSession.Session session = gameSession.getAvailableSession();
session.addPlayer(mockPlayer1);
Expand All @@ -69,6 +79,7 @@ public void testHandleNextRound() {
verify(mockSocket2).send("{\"type\": \"next_round\", \"round\": 2}");
}

@Test
public void testStartGame() {
GameSession.Session session = gameSession.getAvailableSession();
session.addPlayer(mockPlayer1);
Expand All @@ -81,6 +92,7 @@ public void testStartGame() {
verify(mockSocket2).send("{\"type\": \"start_game\"}");
}

@Test
public void testHandleMessage() {
String message = "{\"type\": \"start_game_button\"}";
gameSession.handleMessage(mockSocket1, message);
Expand All @@ -89,8 +101,9 @@ public void testHandleMessage() {
verify(mockSocket1).send("{\"type\": \"start_game\"}");
}

public static Test suite() {
TestSuite suite = new TestSuite(GameSessionTest.class);
return suite;
}
}
// @Test
// public static Test suite() {
// TestSuite suite = new TestSuite(GameSessionTest.class);
// return suite;
// }
}

0 comments on commit 240007f

Please sign in to comment.