Skip to content

Commit

Permalink
Merge branch 'main' of github.com:utastudents/cse3310_sp24_group_28
Browse files Browse the repository at this point in the history
  • Loading branch information
Doan04 committed May 2, 2024
2 parents faa15ae + 10297bb commit fb191b6
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/uta/cse3310/Matrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ public class Matrix {
//testing
public ArrayList<Character> fillerCharactersUsed = new ArrayList<Character>();
<<<<<<< HEAD
<<<<<<< HEAD
=======

>>>>>>> eee088b031a139329acbace8750ae733f277fea4
=======

=======
>>>>>>> ea35d09 (Update)
>>>>>>> 415fabb (Update)

//non-default constructor
Matrix(String filename){
Expand Down
59 changes: 59 additions & 0 deletions src/test/java/uta/cse3310/GameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,69 @@
import junit.framework.TestCase;
import org.mockito.Mockito;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Random;

public class GameTest extends TestCase {
private Game game;


public void testPlayersCannotJoinOnceGameHasBegun() {
// Add some players to the game
ArrayList<Player> players = new ArrayList<>();
players.add(new Player("Player1", null));
players.add(new Player("Player2", null));
game = new Game(players, 1); // Assuming game number is 1

// Now, let's simulate the game has begun
// Set the isOpen flag to false
game.isOpen = false;

// Try to add a new player
Player newPlayer = new Player("NewPlayer", null);
game.addEntries(newPlayer);

// Verify that the new player has not been added
assertTrue("New player should not be able to join once the game has begun", game.verifyPlayer(newPlayer));
}

public void setUp() {
// Initialize the game object before each test
game = new Game();
}


public void testScoreboardIsUpdatedAfterGame() {
setUp();
// Add players to the game
Player player1 = new Player("Player1", null);
Player player2 = new Player("Player2", null);

ArrayList<Player> players = new ArrayList<>();
players.add(player1);
players.add(player2);
game = new Game(players, 1); // Assuming game number is 1

// Simulate the game
// For simplicity, let's just manually update the scores
player1.score = 10;
player2.score = 20;

// End the game
game.gameFinished();

// Check if the scoreboard is updated
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
game.printScoreBoard();

String expectedOutput = "--------- Scoreboard ----------\n" +
"Player1 : 10\n" +
"Player2 : 20\n";
assertEquals(expectedOutput, outContent.toString(), "Scoreboard should display updated scores");
}

public void testGameInitialization() {
Game game = new Game();
Expand Down
34 changes: 34 additions & 0 deletions src/test/java/uta/cse3310/LobbyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void testUpdateGamesAvailable() {
assertEquals(2, lobby.gamesAvailable); // Only two games are open
}

<<<<<<< HEAD
public void testlobbylist(){
int anyplayer = 0;
ArrayList<Player> players = new ArrayList<>();
Expand All @@ -88,6 +89,39 @@ public void testlobbylist(){
}
}
assertEquals(3, anyplayer);
=======
private Lobby lobby;
private Player player1;
private Player player2;
private Game game;

@Before
public void setUp() {
// Initialize the lobby object before each test
lobby = new Lobby(new ArrayList<>());
// Initialize some players
player1 = new Player("Player1", null);
player2 = new Player("Player2", null);
// Initialize a game
game = new Game();
}

public void testPlayerStatusChangesInLobbyAfterJoiningGame() {
// Add players to the lobby
lobby.playerNames.add(player1.name);
lobby.playerStatuses.add(player1.isReady);
lobby.numPlayers++;

// Verify player status in lobby before joining game
assertTrue("Player should be ready in the lobby before joining a game", lobby.playerStatuses.get(0));

// Simulate player joining a game
game.addEntries(player1);

// Verify player status in lobby after joining game
lobby.updateLobby(game.players);
assertFalse("Player should not be ready in the lobby after joining a game", lobby.playerStatuses.get(0));
>>>>>>> 557afd4 (Update)
}

}

0 comments on commit fb191b6

Please sign in to comment.