Ejemplo n.º 1
0
        public List <IGame> GetAllActiveGamesAUserCanJoin(IUser user)
        {
            List <IGame> toReturn = new List <IGame>();

            lock (padlock)
            {
                int          userMoney  = user.Money();
                int          userPoints = user.Points();
                bool         isUnKnow   = user.IsUnKnow();
                List <IGame> games      = proxyDB.GetAllGames();
                foreach (IGame room in games)
                {
                    if (room.CanJoin(user))
                    {
                        toReturn.Add(room);
                    }
                }
            }
            return(toReturn);
        }
        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 <IGame> g  = proxy.GetAllGames();
            bool         g1 = false;
            bool         g2 = false;

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