Skip to content

Commit

Permalink
corrected test to deal with new code
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Fierro committed Apr 16, 2024
1 parent e40b1e5 commit 4352054
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
41 changes: 34 additions & 7 deletions src/test/java/uta/cse3310/GameLogicTest.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,49 @@
package uta.cse3310;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;

public class GameLogicTest {

private GameLogic gameLogic;
private List<PlayerType> players;
private Broadcast mockBroadcast;


class MockBroadcast implements Broadcast {
List<String> messages = new ArrayList<>();

@Override
public void broadcast(String message) {
messages.add(message);
}
}

@Before
public void setUp() {
PlayerType player = new PlayerType("Player1", "Red", PlayerType.Status.Waiting);
gameLogic = new GameLogic(player);
players = new ArrayList<>();
players.add(new PlayerType("Player1", "Blue", PlayerType.Status.Waiting)); // Assuming PlayerType constructor requires a status
mockBroadcast = new MockBroadcast();
gameLogic = new GameLogic(players, mockBroadcast);
gameLogic.validWords.add("word");
}

@Test
public void testIsValidWord() {
// Assuming isValidWord checks something about the first player
assertTrue(gameLogic.isValidWord("word"));
assertFalse(gameLogic.isValidWord("nonexistent"));
}

@Test
public void testGameStart() {
gameLogic.startGame();
assertTrue(((MockBroadcast) mockBroadcast).messages.contains("Game starts now!"));
}

@Test
Expand Down Expand Up @@ -53,11 +85,6 @@ public void testCalculateFillerPercentage() {
assertTrue(fillerPercentage >= 0 && fillerPercentage <= 100);
}

@Test
public void testIsValidWord() {
assertTrue(gameLogic.isValidWord("RedWord"));
assertFalse(gameLogic.isValidWord("BlueWord"));
}

@Test
public void testCheckColumns() {
Expand Down
5 changes: 4 additions & 1 deletion src/test/java/uta/cse3310/UserInterfaceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ public void testGetReadyUp() {
UserInterface userInterface = new UserInterface(true);

// Verify that getReadyUp returns true
assertTrue(userInterface.getReadyUp());
assertTrue(userInterface.getReadyUp()); // Checks if readyUp is true

userInterface.setReadyUp(false);
assertFalse(userInterface.getReadyUp());
}

@Test
Expand Down

0 comments on commit 4352054

Please sign in to comment.