예제 #1
0
        public void DoAction_Spectetor_leave_good_contains()
        {
            int roomid  = new Random().Next();
            int userId  = new Random().Next();
            int userId2 = new Random().Next();

            RegisterUser(userId);
            RegisterUser(userId2);
            IUser user  = _systemControl.GetUserWithId(userId);
            IUser user2 = _systemControl.GetUserWithId(userId2);

            _gameCenter.CreateNewRoomWithRoomId(roomid, user, 50, true, GameMode.Limit, 2, 8, 10, 10);
            _gameCenter.DoAction(user2, CommunicationMessage.ActionType.Spectate, 200, roomid);
            _gameCenter.DoAction(user2, CommunicationMessage.ActionType.SpectatorLeave, -1, roomid);
            IGame            game         = _gameCenter.GetRoomById(roomid);
            List <Spectetor> allspectetor = game.GetSpectetorInRoom();
            bool             contains     = false;

            foreach (Spectetor spectetor in allspectetor)
            {
                if (spectetor.user.Id() == userId2)
                {
                    contains = true;
                }
            }
            Assert.AreEqual(contains, false);
            _userDataProxy.DeleteSpectetorGameOfUSer(userId2, roomid, game.GameNumber);

            _userDataProxy.DeleteUserById(userId2);
            DeleteSysLog(roomid);
            Cleanup(game.GameNumber, roomid, userId);
        }
예제 #2
0
        public void RemoveRoomFromSpectetorGameListTest_good()
        {
            int roomid  = new Random().Next();
            int gameNum = new Random().Next();
            int userId  = new Random().Next();
            int userId2 = new Random().Next();

            RegisterUser(userId2);
            GameRoom toAddg = CreateRoomWithId(gameNum, roomid, userId);

            toAddg.SetIsActive(true);
            _gameDataProxy.InsertNewGameRoom(toAddg);
            IUser user2 = _userDataProxy.GetUserById(userId2);

            user2.AddRoomToSpectetorGameList(toAddg);
            Assert.IsTrue(user2.RemoveRoomFromSpectetorGameList(toAddg));
            _userDataProxy.DeleteSpectetorGameOfUSer(userId, roomid, gameNum);
            _userDataProxy.DeleteUserById(userId2);
            Cleanup(gameNum, roomid, userId);
        }
예제 #3
0
파일: User.cs 프로젝트: shoferb/OYAOB
 public bool RemoveRoomFromSpectetorGameList(IGame game)
 {
     lock (padlock)
     {
         try
         {
             if (game != null)
             {
                 bool exist = HasThisSpectetorGame(game);
                 if (exist)
                 {
                     userDataProxy.DeleteSpectetorGameOfUSer(this.id, game.Id, game.GameNumber);
                     return(true);
                 }
             }
             return(false);
         }
         catch
         {
             return(false);
         }
     }
 }