public void RedistributesThePlayersAmongTheLeaguesGood() { int[] ids = new int[6]; Random rand = new Random(); for (int i = 0; i < 6; i++) { ids[i] = rand.Next(); RegisterUser(ids[i], _user2Name + ids[i], _user2Pw, _user2EmailGood); } var users = new List <IUser>(); for (int i = 0; i < 6; i++) { IUser user = UserBridge.getUserById(ids[i]); user.SetNumGamesPlayed(11); users.Add(user); } users[1].EditUserPoints(100); users[0].EditUserPoints(10000); UserBridge.DividLeage(); Assert.True(users[0].GetLeague() == LeagueName.E); Assert.True(users[1].GetLeague() == LeagueName.E); for (int i = 0; i < 6; i++) { UserBridge.DeleteUser(ids[i]); } }
public void UserLogoutTestGood() { int id = SetupUser1(); Assert.True(UserBridge.LogoutUser(id)); UserBridge.DeleteUser(id); }
private void CreateRoomLoop1() { string pass = "******"; string email = "*****@*****.**"; string name = "99999" + Thread.CurrentThread.ManagedThreadId.ToString(); int id = UserBridge.RegisterUser(name, pass, email); Assert.True(id != -1); Assert.True(UserBridge.LoginUser(name, pass)); int RoomID; List <int> roomIDS = new List <int>(); for (int i = 8850000; i < 8850100; i++) { RoomID = GameBridge.CreateGameRoom(id, 100); roomIDS.Add(RoomID); } for (int i = 0; i < roomIDS.Count; i++) { GameBridge.DoAction(id, CommunicationMessage.ActionType.Leave, 0, roomIDS[i]); } Assert.True(UserBridge.LogoutUser(id)); UserBridge.DeleteUser(name, pass); }
//tear down: (called from case) protected override void SubClassDispose() { if (_userId2 != -1) { List <int> user2Games = UserBridge.GetUsersGameRooms(_userId2); foreach (int roomId in user2Games) { //UserBridge.RemoveUserFromRoom(_userId2, roomId); CleanUp(roomId); } UserBridge.DeleteUser(_userId2); } _userId2 = -1; if (UserId != -1) { List <int> user1Games = UserBridge.GetUsersGameRooms(UserId); foreach (int roomId in user1Games) { //UserBridge.RemoveUserFromRoom(_userId2, roomId); CleanUp(roomId); } UserBridge.DeleteUser(UserId); } UserId = -1; }
public void UserEditAvatarTestGood() { int id = SetupUser1(); Assert.True(UserBridge.EditAvatar(id, "yarden")); Assert.AreEqual(UserBridge.GetUserAvatar(id), "yarden"); UserBridge.DeleteUser(id); }
public void UknownUserTestGood() { UserId = SetupUser1(); IUser user1 = UserBridge.getUserById(UserId); Assert.True(user1.IsUnKnow()); UserBridge.DeleteUser(UserId); }
public void UserEditNameTest_Good() { UserId = SetupUser1(); UserBridge.EditName(UserId, "newName" + UserId); Assert.AreEqual(UserBridge.GetUserName(UserId), "newName" + UserId); Assert.IsTrue(UserBridge.DeleteUser(UserId)); }
public void AverageCashTestGood() { UserId = SetupUser1(); UserBridge.ChangeUserTotalProfit(UserId, 1000); UserBridge.ChangeUserNumOfGames(UserId, 10); Assert.AreEqual(100, UserBridge.GetUserAvgCashGain(UserId)); UserBridge.DeleteUser(UserId); }
public void UserRegisterTestGood() { UserId = new Random().Next(); User1Name = "orelie" + UserId; User1Pw = "goodPw1234"; UserEmailGood1 = "*****@*****.**"; Assert.True(UserBridge.RegisterUser(User1Name, User1Pw, UserEmailGood1) != -1); UserBridge.DeleteUser(User1Name, User1Pw); }
public void UserAddToRoomAsSpectatorGood() { int roomId = CreateGameWith3Users(); int id = new Random().Next(); RegisterUser(id, _user2Name + id, _user2Pw, _user2EmailGood); Assert.IsFalse(UserBridge.AddUserToGameRoomAsSpectator(id, roomId)); CleanUp(roomId); UserBridge.DeleteUser(id); }
public void UserRemoveFromRoomSpectatorTestGood() { UserId = SetupUser1(); int roomId = new Random().Next(); CreateGame(roomId, UserId, 100, true, GameMode.NoLimit, 2, 8, 0, 10); Assert.IsTrue(UserBridge.RemoveUserFromRoom(UserId, roomId)); CleanUp(roomId); UserBridge.DeleteUser(UserId); }
public void UserLoginTestGood() { UserId = new Random().Next(); User1Name = "orelie" + UserId; User1Pw = "goodPw1234"; UserEmailGood1 = "*****@*****.**"; RegisterUser1(); Assert.True(UserBridge.LoginUser(User1Name, User1Pw)); UserBridge.DeleteUser(UserId); }
public void UserEditEmailTestGood() { UserId = new Random().Next(); User1Name = "orelie" + UserId; User1Pw = "goodPw1234"; UserEmailGood1 = "*****@*****.**"; RegisterUser1(); Assert.True(UserBridge.EditEmail(UserId, _user2EmailGood)); Assert.AreEqual(UserBridge.GetUserEmail(UserId), _user2EmailGood); UserBridge.DeleteUser(UserId); }
public void UserEditNameTest_Sad_samename() { UserId = new Random().Next(); User1Name = "orelie" + UserId; User1Pw = "goodPw1234"; UserEmailGood1 = "*****@*****.**"; RegisterUser1(); Assert.False(UserBridge.EditName(UserId, User1Name)); Assert.AreEqual(UserBridge.GetUserName(UserId), User1Name); UserBridge.DeleteUser(UserId); }
public void UserRegisterTest_Bad_PwBad() { UserId = new Random().Next(); User1Name = "orelie" + UserId; User1Pw = "goodPw1234"; UserEmailGood1 = "*****@*****.**"; _userPwBad = "5"; // RegisterUser1(); Assert.True(UserBridge.RegisterUser(User1Name, _userPwBad, UserEmailGood1) == -1); UserBridge.DeleteUser(User1Name, _userPwBad); }
public void UserAddUserMoneyTestBad() { ////RestartSystem(); UserId = SetupUser1(); const int amountToChange = -10000; int prevAmount = UserBridge.GetUserMoney(UserId); Assert.False(UserBridge.AddUserMoney(UserId, amountToChange)); Assert.True(prevAmount == UserBridge.GetUserMoney(UserId)); UserBridge.DeleteUser(UserId); }
public void UserAddUserMoneyTestGood() { UserId = SetupUser1(); const int amountToChange = 100; int prevAmount = UserBridge.GetUserMoney(UserId); Assert.True(UserBridge.AddUserMoney(UserId, amountToChange)); Assert.True(prevAmount == UserBridge.GetUserMoney(UserId) - amountToChange); UserBridge.DeleteUser(UserId); }
public void UserAddToRoomAsSpectatorNonExsistantRoomTestSad() { int id = new Random().Next(); RegisterUser(id, _user2Name + id, _user2Pw, _user2EmailGood); int nonExsistanRoom = new Random().Next(); Assert.IsFalse(UserBridge.AddUserToGameRoomAsSpectator(id, nonExsistanRoom)); CleanUp(nonExsistanRoom); UserBridge.DeleteUser(id); }
private void RegisterLoop() { string pass = "******"; string email = "*****@*****.**"; string name = Thread.CurrentThread.ManagedThreadId.ToString(); for (int i = 5850000; i < 5850100; i++) { Assert.True(UserBridge.RegisterUser(i + name, pass, email) != -1); UserBridge.DeleteUser(i + name, User1Pw); } }
public void UserRegisterTest_Sad_username_taken() { UserId = new Random().Next(); User1Name = "orelie" + UserId; User1Pw = "goodPw1234"; UserEmailGood1 = "*****@*****.**"; //user name already exists in system UserBridge.RegisterUser(User1Name, User1Pw, UserEmailGood1); Assert.True(UserBridge.RegisterUser(User1Name, User1Pw, UserEmailGood1) == -1); UserBridge.DeleteUser(User1Name, User1Pw); }
public void UserEditPwTest_Bad_invalid_passwords() { UserId = new Random().Next(); User1Name = "orelie" + UserId; User1Pw = "goodPw1234"; UserEmailGood1 = "*****@*****.**"; _userPwBad = "bad"; RegisterUser1(); Assert.False(UserBridge.EditPw(UserId, _userPwBad)); Assert.AreEqual(UserBridge.GetUserPw(UserId), User1Pw); UserBridge.DeleteUser(UserId); }
public void AverageGrossTest_Good() { UserId = new Random().Next(); User1Name = "orelie" + UserId; User1Pw = "goodPw1234"; UserEmailGood1 = "*****@*****.**"; RegisterUser1(); IUser user1 = UserBridge.getUserById(UserId); IncWinAndPoints(user1, 100, 1100, 1); Assert.IsTrue(user1.GetAvgProfit() == 100.0); UserBridge.DeleteUser(UserId); }
protected void RestartSystem_register_load() { //delete all users: List <int> allUsers = UserBridge.GetAllUsers(); Users.ForEach(u => { if (!allUsers.Contains(u)) { UserBridge.DeleteUser(u); } }); }
public void LeaderBoardByHighestCashTestSad() { int[] userIds = CreateUsersWithCashGain(1); //only 1 user List <IUser> users = UserBridge.GetUsersByHighestCash(); Assert.GreaterOrEqual(users.Count, 1); Assert.IsTrue(users[0].Id() == userIds[0]); foreach (int t in userIds) { UserBridge.DeleteUser(t); } }
public void AverageGrossTestBad() { UserId = new Random().Next(); User1Name = "orelie" + UserId; User1Pw = "goodPw1234"; UserEmailGood1 = "*****@*****.**"; RegisterUser1(); IUser user1 = UserBridge.getUserById(UserId); IUser user2 = UserBridge.getUserById(_userId2); Assert.IsTrue(user1.GetAvgProfit() == 0); UserBridge.DeleteUser(UserId); }
public void AverageCashTest_Bad_noGmesPlayed() { UserId = new Random().Next(); User1Name = "orelie" + UserId; User1Pw = "goodPw1234"; UserEmailGood1 = "*****@*****.**"; RegisterUser1(); IUser user1 = UserBridge.getUserById(UserId); // Assert.AreNotEqual(user1,null); Assert.IsTrue(user1.GetAvgCashGainPerGame() == 0.0); UserBridge.DeleteUser(UserId); }
public void UserEditEmailTestBad() { UserId = new Random().Next(); User1Name = "Oded" + UserId; User1Pw = "goodPw1234"; UserEmailGood1 = "*****@*****.**"; RegisterUser1(); Assert.False(UserBridge.EditEmail(UserId, _userEmailBad)); Assert.AreEqual(UserBridge.GetUserEmail(UserId), UserEmailGood1); Assert.False(UserBridge.EditEmail(UserId, _userEmailBad)); Assert.AreEqual(UserBridge.GetUserEmail(UserId), UserEmailGood1); UserBridge.DeleteUser(UserId); }
private bool DeleteUser(int id) { if (id != -1) { List <int> user2Games = UserBridge.GetUsersGameRooms(id); foreach (var roomId in user2Games) { UserBridge.RemoveUserFromRoom(id, roomId); } UserBridge.DeleteUser(id); return(true); } return(false); }
private void RegisterAndLoginLoop() { string pass = "******"; string email = "*****@*****.**"; string name = Thread.CurrentThread.ManagedThreadId.ToString(); int id; for (int i = 6850000; i < 6850100; i++) { id = UserBridge.RegisterUser(i + name, pass, email); Assert.True(id != -1); Assert.True(UserBridge.LoginUser(i + name, pass)); Assert.True(UserBridge.LogoutUser(id)); UserBridge.DeleteUser(i + name, pass); } }
public void LeaderBoardByTotalProfitTestGood() { int[] userIds = CreateUsersWithTotalProfit(25); List <IUser> users = UserBridge.GetUsersByTotalProfit(); Assert.AreEqual(20, users.Count); for (int i = 0; i < users.Count; i++) { int currId = users[i].Id(); Assert.AreEqual(currId, userIds[i]); } for (int i = 0; i < userIds.Length; i++) { UserBridge.DeleteUser(userIds[i]); } }