Ejemplo n.º 1
0
        public IEnumerator <ActionResultInfo> AddSpectatorToRoom(IUser user, int roomId)
        {
            IEnumerator <ActionResultInfo> inumerator = new List <ActionResultInfo>().GetEnumerator();
            IGame gameRoom = GetRoomById(roomId);

            if (gameRoom != null)
            {
                inumerator = gameRoom.AddSpectetorToRoom(user);
                proxyDB.UpdateGameRoom((GameRoom)gameRoom);
                proxyDB.UpdateGameRoomPotSize(gameRoom.GetPotSize(), gameRoom.Id);
            }
            return(inumerator);
        }
Ejemplo n.º 2
0
        public void getAllGamesTest()
        {
            int      roomId   = new Random().Next();
            int      gameId   = new Random().Next();
            int      userId1  = new Random().Next();
            int      userId2  = new Random().Next();
            int      userId3  = new Random().Next();
            int      room2Id  = new Random().Next();
            int      game2Id  = new Random().Next();
            int      user2Id1 = new Random().Next();
            int      user2Id2 = new Random().Next();
            int      user2Id3 = new Random().Next();
            GameRoom toAdd    = CreateRoomWithId(gameId, roomId, userId1, userId2, userId3);
            GameRoom toAdd2   = CreateRoomWithId(game2Id, room2Id, user2Id1, user2Id2, user2Id3);

            proxy.InsertNewGameRoom(toAdd);
            proxy.InsertNewGameRoom(toAdd2);
            proxy.UpdateGameRoom(toAdd);
            List <LinqToSql.GameRoom> g = controller.getAllGames();
            bool g1 = false;
            bool g2 = false;

            foreach (var game in g)
            {
                if (game.RoomId == roomId)
                {
                    g1 = true;
                }
                if (game.RoomId == room2Id)
                {
                    g2 = true;
                }
            }
            Assert.AreEqual(g1, true);
            Assert.AreEqual(g2, true);
            Cleanup(gameId, roomId, userId1, userId2, userId3);
            Cleanup(game2Id, room2Id, user2Id1, user2Id2, userId3);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public IEnumerator <ActionResultInfo> AddSpectatorToRoom(int userId, int roomId)
        {
            //IEnumerator<ActionResultInfo> inumerator = new List<ActionResultInfo>().GetEnumerator();

            //IUser user = _systemControl.GetUserWithId(userId);
            //if ( user != null)
            //{
            //    inumerator = _gameCenter.AddSpectatorToRoom(user, roomId);
            //}
            //return inumerator;
            //todo - new call below remove above

            IEnumerator <ActionResultInfo> inumerator = new List <ActionResultInfo>().GetEnumerator();
            IGame gameRoom = _gameCenter.GetRoomById(roomId);
            IUser user     = _systemControl.GetUserWithId(userId);

            if (gameRoom != null && user != null)
            {
                inumerator = gameRoom.AddSpectetorToRoom(user);
                _proxyDb.UpdateGameRoom((GameRoom)gameRoom);
                _proxyDb.UpdateGameRoomPotSize(gameRoom.GetPotSize(), gameRoom.Id);
            }
            return(inumerator);
        }
        public void UpdateGameRoomPotSizeTest_good()
        {
            proxy.InsertNewGameRoom(gameRoom);
            gameRoom.SetPotSize(777);
            bool  ans = proxy.UpdateGameRoom(gameRoom);
            IGame g   = proxy.GetGameRoombyId(gameRoom.Id);

            Assert.IsTrue(ans);
            Assert.IsTrue(g.IsPotSizeEqual(777));
            proxy.DeleteGameRoomPref(gameRoom.Id);
            proxy.DeleteGameRoom(gameRoom.Id, gameRoom.GetGameNum());
        }