Skip to content

Commit

Permalink
UserTests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristal6113 committed Apr 30, 2024
1 parent a3c6e03 commit bdb1d64
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/test/java/com/cse3310/UserTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.cse3310;
import java.util.ArrayList;

import org.java_websocket.WebSocket;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class UserTest {
public WebSocket conn;
User user1 = new User(" ",conn);
User user2 = new User(" ",conn);
ArrayList<User> users = new ArrayList<>();

/**
* no duplicate usernames
*/
public boolean usernamesAreNotEqual(ArrayList<User> users, String username1, String username2)
{
user1.setName(username1);
user2.setName(username2);
if(user1.getName().equals(user2.getName()))
{
return false;
}
return true;
}

@Test
public void testForDuplicateUsernames()
{
assertTrue(usernamesAreNotEqual(users, "user", "player"));
}

@Test
/**
* if a player wins 4 games the user's gamesWon variable stores the 4
*/
public void addFourToScoreAndWins()
{
user1.gamesWon+=4;
assertEquals(4, user1.gamesWon);

}
}

0 comments on commit bdb1d64

Please sign in to comment.