-
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.
- Loading branch information
1 parent
018c898
commit e2f0820
Showing
28 changed files
with
227 additions
and
173 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -58,4 +58,6 @@ public void start() { | |
|
||
} | ||
|
||
|
||
|
||
} |
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
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,5 @@ | ||
package uta.cse3310; | ||
|
||
public @interface Before { | ||
|
||
} |
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
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,67 @@ | ||
package uta.cse3310; | ||
import junit.framework.TestCase; | ||
import java.util.ArrayList; | ||
import org.java_websocket.WebSocket; | ||
import org.mockito.Mockito; | ||
|
||
public class LobbyTest extends TestCase { | ||
|
||
public void testLobbyInitialization() { | ||
ArrayList<Player> players = new ArrayList<>(); | ||
WebSocket socket1 = Mockito.mock(WebSocket.class); | ||
WebSocket socket2 = Mockito.mock(WebSocket.class); | ||
Player player1 = new Player("Alice", socket1); | ||
Player player2 = new Player("Bob", socket2); | ||
players.add(player1); | ||
players.add(player2); | ||
|
||
Lobby lobby = new Lobby(players); | ||
|
||
assertEquals(2, lobby.numPlayers); | ||
assertEquals(0, lobby.numReady); | ||
assertEquals(0, lobby.gamesAvailable); | ||
assertTrue(lobby.playerNames.contains("Alice")); | ||
assertTrue(lobby.playerNames.contains("Bob")); | ||
assertFalse(lobby.playerStatuses.get(0)); // Alice's status | ||
assertFalse(lobby.playerStatuses.get(1)); // Bob's status | ||
} | ||
|
||
public void testUpdateLobby() { | ||
ArrayList<Player> players = new ArrayList<>(); | ||
WebSocket socket1 = Mockito.mock(WebSocket.class); | ||
WebSocket socket2 = Mockito.mock(WebSocket.class); | ||
Player player1 = new Player("Alice", socket1); | ||
Player player2 = new Player("Bob", socket2); | ||
players.add(player1); | ||
players.add(player2); | ||
|
||
Lobby lobby = new Lobby(players); | ||
|
||
// Update players' readiness | ||
player1.isReady = true; | ||
player2.isReady = false; | ||
|
||
lobby.updateLobby(players); | ||
|
||
assertEquals(2, lobby.numPlayers); | ||
assertEquals(1, lobby.numReady); | ||
assertEquals(0, lobby.gamesAvailable); | ||
assertTrue(lobby.playerNames.contains("Alice")); | ||
assertTrue(lobby.playerNames.contains("Bob")); | ||
assertTrue(lobby.playerStatuses.get(0)); // Alice's status | ||
assertFalse(lobby.playerStatuses.get(1)); // Bob's status | ||
} | ||
|
||
public void testUpdateGamesAvailable() { | ||
Game[] games = new Game[3]; | ||
games[0] = new Game(); // Assume isOpen is true for the first game | ||
games[1] = new Game(); // Assume isOpen is false for the second game | ||
games[2] = new Game(); // Assume isOpen is true for the third game | ||
|
||
Lobby lobby = new Lobby(new ArrayList<>()); | ||
lobby.updateGamesAvailable(games); | ||
|
||
assertEquals(2, lobby.gamesAvailable); // Only two games are open | ||
} | ||
|
||
} |
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,35 @@ | ||
package uta.cse3310; | ||
import org.java_websocket.WebSocket; | ||
import org.java_websocket.handshake.ClientHandshake; | ||
import junit.framework.TestCase; | ||
import org.mockito.Mockito; | ||
|
||
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
|
||
import java.util.ArrayList; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MainTest { | ||
|
||
public void testOnCloseRemovesPlayerFromPlayerList() { | ||
// Arrange: Create necessary objects and set up conditions | ||
Main main = new Main(8080); | ||
WebSocket socket1 = Mockito.mock(WebSocket.class); | ||
List<Player> playerList = new ArrayList<>(); | ||
Player player1 = new Player("Alice", socket1); | ||
Player player2 = new Player("Bob", socket1); | ||
playerList.add(player1); | ||
playerList.add(player2); | ||
|
||
// Act: Call the method to be tested | ||
main.onClose(socket1, 1001, "Normal closure", true); | ||
|
||
// Assert: Check if the method behaves as expected | ||
assert !playerList.contains(player1); // Player1 should be removed from the playerList | ||
assert playerList.contains(player2); // Player2 should still be in the playerList | ||
} | ||
|
||
} |
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,32 @@ | ||
package uta.cse3310; | ||
import junit.framework.TestCase; | ||
import java.util.List; | ||
import java.util.ArrayList; | ||
|
||
public class MatrixTest extends TestCase | ||
{ | ||
public void testGridHasWords() { | ||
char[][] grid = new char[50][50]; | ||
List<String> wordBank = new ArrayList<String>(); | ||
wordBank.add("Ant"); | ||
wordBank.add("Zebra"); | ||
wordBank.add("Baboon"); | ||
|
||
boolean result = gridHasWords(grid, wordBank); | ||
|
||
assertFalse(result); // Add your assertions based on the expected behavior | ||
} | ||
|
||
|
||
//Matrix wordSearch = new Matrix(grid); | ||
|
||
//wordSearch.horizontalWordInsert(false,null, grid); | ||
|
||
//assertTrue(gridHasWords(grid, wordBank)); | ||
|
||
|
||
boolean gridHasWords(char[][] grid, List<String> wordBank){ | ||
return false; | ||
} | ||
|
||
} |
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,19 @@ | ||
package uta.cse3310; | ||
|
||
import junit.framework.TestCase; | ||
import org.java_websocket.WebSocket; | ||
import org.mockito.Mockito; | ||
|
||
public class PlayerTest extends TestCase { | ||
|
||
public void testPlayerInitialization() { | ||
WebSocket socket = Mockito.mock(WebSocket.class); | ||
Player player = new Player("Alice", socket); | ||
|
||
assertEquals("Alice", player.name); | ||
assertEquals(0, player.score); | ||
assertEquals(false, player.isReady); | ||
assertEquals(socket, player.playerConn); | ||
} | ||
|
||
} |
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,23 @@ | ||
package uta.cse3310; | ||
import junit.framework.TestCase; | ||
|
||
public class UserMsgTest extends TestCase { | ||
|
||
public void testUserMsgInitialization() { | ||
int[] startCoords = {1, 2}; | ||
int[] endCoords = {3, 4}; | ||
|
||
UserMsg userMsg = new UserMsg(); | ||
userMsg.code = 100; | ||
userMsg.name = "Alice"; | ||
userMsg.message = "Hello!"; | ||
userMsg.startCoords = startCoords; | ||
userMsg.endCoords = endCoords; | ||
userMsg.gameNum = 1; | ||
|
||
assertEquals(100, userMsg.code); | ||
assertEquals("Alice", userMsg.name); | ||
assertEquals("Hello!", userMsg.message); | ||
assertEquals(1, userMsg.gameNum); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
19 changes: 0 additions & 19 deletions
19
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.