Exemple #1
0
        public void UserAddToRoomAsPlayerNegUserTestBad()
        {
            UserId = SetupUser1();
            int roomId = new Random().Next();

            CreateGame(roomId, UserId, 100, true, GameMode.NoLimit, 2, 8, 0, 10);
            Assert.IsFalse(UserBridge.AddUserToGameRoomAsPlayer(-1, roomId, 10));
            CleanUp(roomId);
        }
Exemple #2
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
        }
Exemple #3
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);
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
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);
        }