-
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.
Merge branch 'LogInTest' of https://github.com/CSC207-UofT/course-pro…
…ject-bugwatcher_group036 into york5 � Conflicts: � src/main/java/LogIn/LogInEntity/UserList.java
- Loading branch information
Showing
6 changed files
with
188 additions
and
12 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 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,29 @@ | ||
package LogIn.Entity; | ||
|
||
import LogIn.LogInEntity.User; | ||
import LogIn.LogInEntity.UserList; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.util.HashMap; | ||
|
||
public class UserListTest { | ||
UserList userList = new UserList(); | ||
User user = new User("Allen", "1007224576"); | ||
|
||
@Test | ||
public void testAdd() { | ||
userList.add(user); | ||
User user0 = userList.getUser("Allen"); | ||
assertEquals(user0.getUsername(), "Allen"); | ||
} | ||
|
||
@Test | ||
public void testGetUser() { | ||
userList.add(user); | ||
User user0 = new User("Jame", "123456"); | ||
User user1 = userList.getUser("Jame"); | ||
assertEquals(user0.getUsername(), "Jame"); | ||
} | ||
} |
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,4 @@ | ||
package LogIn.Entity; | ||
|
||
public class UserReadWriterTest { | ||
} |
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,99 @@ | ||
package LogIn.Entity; | ||
|
||
import LogIn.LogInEntity.UserStatistics; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.net.PortUnreachableException; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
|
||
public class UserStaticsTest { | ||
UserStatistics statistics = new UserStatistics("Allen"); | ||
|
||
@Test | ||
public void testInitialization() { | ||
assertEquals(statistics.getPlayerId(), "Allen"); | ||
|
||
} | ||
|
||
@Test | ||
public void testGetStats() { | ||
int[] stats = statistics.getStats(); | ||
assertEquals(stats[0], 0); | ||
assertEquals(stats.length, 7); | ||
} | ||
|
||
@Test | ||
public void testPVPWin() { | ||
statistics.PVPWin(); | ||
int[] stats = statistics.getStats(); | ||
assertEquals(stats[0], 1); | ||
assertEquals(stats[1], 0); | ||
assertEquals(stats[5], 100); | ||
assertEquals(stats.length, 7); | ||
|
||
} | ||
|
||
@Test | ||
public void testPVEWin() { | ||
statistics.PVEWin(); | ||
int[] stats = statistics.getStats(); | ||
assertEquals(stats[0], 0); | ||
assertEquals(stats[1], 1); | ||
assertEquals(stats[5], 70); | ||
assertEquals(stats.length, 7); | ||
|
||
} | ||
|
||
@Test | ||
public void testDrawCard() { | ||
statistics.drawCard(10); | ||
int[] stats = statistics.getStats(); | ||
assertEquals(stats[0], 0); | ||
assertEquals(stats[0], 0); | ||
assertEquals(stats[5], 10); | ||
assertEquals(stats.length, 7); | ||
} | ||
|
||
@Test | ||
public void testPlayCard() { | ||
int[] stats = statistics.getStats(); | ||
assertEquals(stats[6], 0); | ||
statistics.playCard("red 5"); | ||
assertEquals(stats[2], 1); | ||
assertEquals(stats[3], 0); | ||
assertEquals(stats[5], 2); | ||
assertEquals(stats[6], 1); | ||
assertEquals(stats.length, 7); | ||
statistics.playCard("red +2"); | ||
assertEquals(stats[2], 2); | ||
assertEquals(stats[3], 1); | ||
assertEquals(stats[5], 7); | ||
assertEquals(stats[6], 1); | ||
assertEquals(stats.length, 7); | ||
|
||
} | ||
|
||
@Test | ||
public void testCheckExp() { | ||
statistics.checkExp(); | ||
int[] stats = statistics.getStats(); | ||
assertEquals(stats[0], 0); | ||
assertEquals(stats[6], 1); | ||
assertEquals(stats.length, 7); | ||
} | ||
|
||
@Test | ||
public void testGetPlayerId() { | ||
String id = statistics.getPlayerId(); | ||
assertEquals(id, "Allen"); | ||
} | ||
|
||
@Test | ||
public void testToString() { | ||
String s = statistics.toString(); | ||
assertEquals(s, "PVP win count: 0\nPVE win count: 0\ntotal card played: 0\n" + | ||
"total function card played: 0\ntotal card drawn: 0\nexp: 0\nplayer level: 0\n"); | ||
} | ||
} |
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,52 @@ | ||
package LogIn.Entity; | ||
|
||
import LogIn.LogInEntity.User; | ||
import LogIn.LogInEntity.UserStatistics; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class UserTest { | ||
User user = new User("Allen", "123456"); | ||
User user0 = new User("Jack", "010814"); | ||
|
||
@Test | ||
public void testInitialization() { | ||
String username = user.getUsername(); | ||
assertEquals(username, "Allen"); | ||
} | ||
|
||
@Test | ||
public void testPasswordMatches() { | ||
assertFalse(user.passwordMatches("010814")); | ||
assertTrue(user.passwordMatches("123456")); | ||
} | ||
|
||
@Test | ||
public void testGetUsername() { | ||
assertEquals(user.getUsername(), "Allen"); | ||
assertEquals(user0.getUsername(), "Jack"); | ||
} | ||
|
||
@Test | ||
public void testToString() { | ||
String s = user.toString(); | ||
assertEquals(s, "Username: Allen, Password: 123456"); | ||
} | ||
|
||
@Test | ||
public void testGetUserStatics() { | ||
UserStatistics userStat = user.getUserStatistics(); | ||
int[] stat = userStat.getStats(); | ||
assertEquals(stat.length, 7); | ||
|
||
} | ||
|
||
@Test | ||
public void testSetUserStatics() { | ||
UserStatistics userStat = new UserStatistics("Allen"); | ||
user.setUserStatistics(userStat); | ||
assertEquals(user.getUserStatistics(), userStat); | ||
|
||
} | ||
} |
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,4 @@ | ||
package LogIn.UseCase; | ||
|
||
public class LogInUseCaseTest { | ||
} |