Exemplo n.º 1
0
        public void AddSystemLogTest_good_id()
        {
            int roomid  = new Random().Next();
            int gameNum = new Random().Next();
            int userId  = new Random().Next();
            int logId   = new Random().Next();

            Logic.Game.GameRoom toAddg = CreateRoomWithId(gameNum, roomid, userId);
            proxy.InsertNewGameRoom(toAddg);
            Database.LinqToSql.SystemLog toAdd = new Database.LinqToSql.SystemLog();
            Database.LinqToSql.Log       logs  = new Database.LinqToSql.Log
            {
                LogId       = logId,
                LogPriority = 1
            };
            toAdd.Log     = logs;
            toAdd.logId   = logId;
            toAdd.msg     = "test AddSystemLogTest_good_id()";
            toAdd.roomId  = roomid;
            toAdd.game_Id = gameNum;
            _logDataControler.AddSystemLog(toAdd);

            Assert.AreEqual(_logsOnlyForTest.GetSystemLogById(logId).logId, logId);
            _logsOnlyForTest.DeleteSystemLog(logId);
            _logsOnlyForTest.DeleteLog(logId);
            Cleanup(gameNum, roomid, userId);
        }
Exemplo n.º 2
0
        public void RemoveRoomFromActiveGameListTest_good()
        {
            int      roomid  = new Random().Next();
            int      gameNum = new Random().Next();
            int      userId  = new Random().Next();
            GameRoom toAddg  = CreateRoomWithId(gameNum, roomid, userId);

            toAddg.SetIsActive(true);
            _gameDataProxy.InsertNewGameRoom(toAddg);
            IUser user = _userDataProxy.GetUserById(userId);

            user.AddRoomToActiveGameList(toAddg);
            Assert.IsTrue(user.RemoveRoomFromActiveGameList(toAddg));
            _userDataProxy.DeleteActiveGameOfUser(userId, roomid, gameNum);
            Cleanup(gameNum, roomid, userId);
        }
Exemplo n.º 3
0
        public void AddSysLogTest_good_id_match()
        {
            int      roomid  = new Random().Next();
            int      gameNum = new Random().Next();
            int      userId  = new Random().Next();
            GameRoom toAdd   = CreateRoomWithId(gameNum, roomid, userId);

            proxy.InsertNewGameRoom(toAdd);
            var systemLog = new SystemLog(roomid, "AddSysLogTest_good_id_match", gameNum);

            _logDataProxy.AddSysLog(systemLog);
            var logId = systemLog.LogId;

            Assert.AreEqual(_logsOnlyForTest.GetSystemLogById(logId).logId, logId);
            _logsOnlyForTest.DeleteSystemLog(logId);
            _logsOnlyForTest.DeleteLog(logId);
            Cleanup(gameNum, roomid, userId);
        }
Exemplo n.º 4
0
 //Add new room the games list
 public bool AddRoom(GameRoom roomToAdd)
 {
     lock (padlock)
     {
         bool toReturn = false;
         if (roomToAdd == null)
         {
             return(toReturn);
         }
         try
         {
             //  this.games.Add(roomToAdd);
             toReturn = proxyDB.InsertNewGameRoom(roomToAdd);
         }
         catch (Exception e)
         {
             ErrorLog log = new ErrorLog("Error while trying to add new room to game center");
             logControl.AddErrorLog(log);
             toReturn = false;
         }
         return(toReturn);
     }
 }
Exemplo n.º 5
0
        public void UpdateGameRoomPotSizeTest()
        {
            int      roomId  = new Random().Next();
            int      gameId  = new Random().Next();
            int      userId1 = 1;
            int      userId2 = 2;
            int      userId3 = 3;
            GameRoom toAdd   = CreateRoomWithId(gameId, roomId, userId1, userId2, userId3);

            proxy.InsertNewGameRoom(toAdd);
            bool ans = controller.UpdateGameRoomPotSize(777, roomId);

            Assert.IsTrue(ans);
            Cleanup(gameId, roomId, userId1, userId2, userId3);
        }
Exemplo n.º 6
0
        public void GetAllActiveGameRoomsTest()
        {
            int roomId  = new Random().Next();
            int gameId  = new Random().Next();
            int userId1 = new Random().Next();

            int room2Id  = new Random().Next();
            int game2Id  = new Random().Next();
            int user2Id1 = new Random().Next();

            GameRoom toAdd  = CreateRoomWithId(gameId, roomId, userId1);
            GameRoom toAdd2 = CreateRoomWithId(game2Id, room2Id, user2Id1);

            toAdd.SetIsActive(true);
            proxy.InsertNewGameRoom(toAdd);
            proxy.InsertNewGameRoom(toAdd2);
            proxy.UpdateGameRoom(toAdd);
            List <IGame> g  = proxy.GetAllActiveGameRooms();
            bool         g1 = false;
            bool         g2 = false;

            foreach (var game in g)
            {
                if (game.Id == roomId)
                {
                    g1 = true;
                }
                else if (game.Id == room2Id)
                {
                    g2 = true;
                }
            }
            Assert.AreEqual(g1, true);
            Assert.AreEqual(g2, false);
            Cleanup(gameId, roomId, userId1);
            Cleanup(game2Id, room2Id, user2Id1);
        }