Пример #1
0
        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]);
            }
        }
Пример #2
0
        public void UknownUserTestGood()
        {
            UserId = SetupUser1();
            IUser user1 = UserBridge.getUserById(UserId);

            Assert.True(user1.IsUnKnow());
            UserBridge.DeleteUser(UserId);
        }
Пример #3
0
        public void CreateGameWithPrefTestBad()
        {
            RoomId = -1;
            SetupUser1();
            Assert.True(RoomId == -1);
            Assert.False(UserBridge.getUserById(UserId) == null);

            RoomId = GameBridge.CreateGameRoomWithPref(UserId, 10, false, GameMode.PotLimit, 0, 0, -1, 0);
            Assert.True(RoomId == -1);
            Assert.False(GameBridge.DoesRoomExist(RoomId));
            CleanUp(RoomId);
        }
Пример #4
0
        public void UserAddToRoomAsPlayerAllreadySpectatorInRoomTestBad()
        {
            UserId = SetupUser1();
            IUser user1 = UserBridge.getUserById(UserId);

            user1.AddMoney(100000000);
            int roomId = new Random().Next();

            CreateGame(roomId, UserId, 100, true, GameMode.NoLimit, 2, 8, 0, 10);
            Assert.IsFalse(UserBridge.AddUserToGameRoomAsSpectator(UserId, roomId));
            CleanUp(roomId);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        public void CreateGameTestGood()
        {
            ////RestartSystem();
            RoomId = -1;
            //SetupUser1();
            UserId = new Random().Next();
            RegisterUserToDB(UserId);

            Assert.False(UserBridge.getUserById(UserId) == null);
            RoomId = GameBridge.CreateGameRoom(UserId, 100);
            Assert.True(RoomId != -1);
            Assert.True(GameBridge.DoesRoomExist(RoomId));
            Assert.AreEqual(1, GameBridge.GetPlayersInRoom(RoomId).Count);
            Assert.AreEqual(UserId, GameBridge.GetPlayersInRoom(RoomId).First().user.Id());
            CleanUp(RoomId);
        }
Пример #9
0
        public void ViewReplayTestGood()
        {
            //create a game to be replayd
            //RestartSystem();
            SetupUser1();
            CreateGameWithUser1();
            RegisterUser(_userId2, _user2Name, _user2Pw, _user2EmailGood);
            IUser user2 = UserBridge.getUserById(_userId2);

            user2.AddMoney(1000);
            Assert.True(UserBridge.AddUserToGameRoomAsPlayer(_userId2, RoomId, user2.Money()));
            GameBridge.StartGame(UserId, RoomId);
            //   UserBridge.RemoveUserFromRoom(UserId, RoomId);

            var replays = ReplayBridge.ViewReplay(RoomId, 0, UserId);

            Assert.GreaterOrEqual(6, replays.Count); //join, 2 call, leave, lose, win
        }
Пример #10
0
        public void UserAddToRoomAsPlayerNoMoneyTestGood()
        {
            UserId = SetupUser1();
            IUser user1 = UserBridge.getUserById(UserId);

            user1.AddMoney(100000000);
            int roomId = new Random().Next();

            CreateGame(roomId, UserId, 100, true, GameMode.NoLimit, 2, 8, 0, 10);
            _userId2 = new Random().Next();
            RegisterUser(_userId2, _user2Name + _userId2, _user2Pw, _user2EmailGood);
            IUser user2 = UserBridge.getUserById(_userId2);
            int   money = user2.Money();

            user2.ReduceMoneyIfPossible(money); //so now he is broke
            Assert.IsFalse(UserBridge.AddUserToGameRoomAsPlayer(_userId2, roomId, 10));
            CleanUp(roomId);
            UserBridge.DeleteUser(_userId2);
        }
Пример #11
0
        public void DoActionLoadTest1()
        {
            //RestartSystem();
            SetupUser1();
            CreateGameWithUser1();
            RegisterUser(_userId2, _user2Name, _user2Pw, _user2EmailGood);
            IUser user2 = UserBridge.getUserById(_userId2);

            user2.AddMoney(1000);
            Assert.True(UserBridge.AddUserToGameRoomAsPlayer(_userId2, RoomId, user2.Money()));
            RegisterUser(_userId3, _user3Name, _user3Pw, _user3EmailGood);
            IUser user3 = UserBridge.getUserById(_userId3);

            user3.AddMoney(1000);
            Assert.True(UserBridge.AddUserToGameRoomAsPlayer(_userId3, RoomId, user3.Money()));
            GameBridge.StartGame(UserId, RoomId);
            IUser  user1   = UserBridge.getUserById(UserId);
            Player player1 = GetInGamePlayerFromUser(user1, RoomId);
            Player player2 = GetInGamePlayerFromUser(user2, RoomId);
            Player player3 = GetInGamePlayerFromUser(user3, RoomId);

            //bomb the game
            Thread thread1 = new Thread(new ThreadStart(doAction1));
            Thread thread2 = new Thread(new ThreadStart(doAction2));
            Thread thread3 = new Thread(new ThreadStart(doAction3));

            thread1.Start();
            thread2.Start();
            thread3.Start();

            Thread.Sleep(3); //let the threads work
                             //wait for threads
            thread1.Join();
            thread2.Join();
            thread3.Join();


            Assert.True(GameBridge.GetPlayersInRoom(RoomId).Contains(player1));
            Assert.True(GameBridge.GetPlayersInRoom(RoomId).Contains(player2));
            Assert.True(GameBridge.GetPlayersInRoom(RoomId).Contains(player3));
            Assert.True(player2.isPlayerActive);
            Assert.True(player3.isPlayerActive);
        }
Пример #12
0
        public void GetReplayableGamesTestGood()
        {
            //create a game to be replayd
            //RestartSystem();
            SetupUser1();
            CreateGameWithUser1();
            RegisterUser(_userId2, _user2Name, _user2Pw, _user2EmailGood);
            IUser user2 = UserBridge.getUserById(_userId2);

            user2.AddMoney(1000);
            Assert.True(UserBridge.AddUserToGameRoomAsPlayer(_userId2, RoomId, user2.Money()));
            RegisterUser(_userId3, _user3Name, _user3Pw, _user3EmailGood);
            IUser user3 = UserBridge.getUserById(_userId3);

            user3.AddMoney(1000);
            Assert.True(UserBridge.AddUserToGameRoomAsPlayer(_userId3, RoomId, user3.Money()));
            GameBridge.StartGame(UserId, RoomId);
            System.Threading.Thread.Sleep(5000);
            UserBridge.RemoveUserFromRoom(UserId, RoomId);
            UserBridge.RemoveUserFromRoom(_userId2, RoomId);
            UserBridge.RemoveUserFromRoom(_userId3, RoomId);
            Assert.True(ReplayBridge.GetReplayableGames(RoomId, 0, _userId3)._actions.Count >= 1);
        }
Пример #13
0
        private int CreateGameWith3Users()
        {
            UserId = SetupUser1();
            IUser user1 = UserBridge.getUserById(UserId);

            user1.AddMoney(100000000);
            int roomId = new Random().Next();

            CreateGame(roomId, UserId, 100, true, GameMode.NoLimit, 2, 8, 0, 10);
            _userId2 = new Random().Next();
            RegisterUser(_userId2, _user2Name + _userId2, _user2Pw, _user2EmailGood);
            IUser user2 = UserBridge.getUserById(_userId2);

            user2.AddMoney(1000);
            Assert.True(UserBridge.AddUserToGameRoomAsPlayer(_userId2, roomId, user2.Money()));
            _userId3 = new Random().Next();
            RegisterUser(_userId3, _user3Name + _userId3, _user3Pw, _user3EmailGood);
            IUser user3 = UserBridge.getUserById(_userId3);

            user3.AddMoney(1000);
            Assert.True(UserBridge.AddUserToGameRoomAsPlayer(_userId3, roomId, user3.Money()));
            GameBridge.StartGame(UserId, roomId);
            return(roomId);
        }