Exemple #1
0
        public List <IGame> GetAllActiveGameRooms()
        {
            List <IGame>    toRet   = new List <IGame>();
            List <XElement> dbGames = _controller.GetAllActiveGameRooms();

            if (dbGames.Capacity == 0)
            {
                return(null);
            }
            foreach (XElement g in dbGames)
            {
                toRet.Add(GameRoomFromXElement(g));
            }
            return(toRet);
        }
        public void GetAllActiveGameRoomsTest()
        {
            int      roomId   = 1212;
            int      gameId   = new Random().Next();
            int      userId1  = new Random().Next();
            int      userId2  = new Random().Next();
            int      userId3  = new Random().Next();
            int      room2Id  = 123;
            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);

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

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