Exemplo n.º 1
0
        private IEnumerable <string> GetFollowers(string entryBy, NewsfeedWallModel targetWall)
        {
            var configProvider = new ApplicationConfigurationRepository();
            var parameters     = configProvider.FetchConfiguration();

            bool displayOnOwnFeed = true;
            bool displayOnlyOnPrivateGroupFollowers = true;
            bool displayOnPrivateGroupFollowersFeed = true;
            bool displayOnPublicGroupFollowersFeed  = true;
            bool displayOnUserFollowers             = true;
            bool displayOnWallOwnerFollowersFeed    = true;

            IEnumerable <string> followers = new List <string>();

            if (displayOnOwnFeed)
            {
                followers = followers.Union(new List <string> {
                    entryBy
                });
            }

            if (targetWall.WallOwnerType == WallType.group && !targetWall.IsPublic && displayOnlyOnPrivateGroupFollowers)
            {
                var privateGroupFollowers = followerProvider.GetGroupFollowersCached(targetWall.OwnerId);
                followers = followers.Union(privateGroupFollowers);
            }
            else
            {
                if (targetWall.WallOwnerType == WallType.group &&
                    ((!targetWall.IsPublic && displayOnPrivateGroupFollowersFeed) ||
                     (targetWall.IsPublic && displayOnPublicGroupFollowersFeed)))
                {
                    var groupFollowers = followerProvider.GetGroupFollowersCached(targetWall.OwnerId);
                    followers = followers.Union(groupFollowers);
                }
                else if (displayOnWallOwnerFollowersFeed)
                {
                    var targetUserFollowers = followerProvider.GetUserFollowersCached(targetWall.OwnerId);
                    followers = followers.Union(targetUserFollowers);
                }
                if (displayOnUserFollowers)
                {
                    var userFollowers = followerProvider.GetUserFollowersCached(entryBy);
                    followers = followers.Union(userFollowers);
                }
            }
            return(followers.Distinct());
        }
Exemplo n.º 2
0
        public void Should_Return_Equal()
        {
            var targetUser  = GetRandomUserName();
            var targetGroup = GetRandomGroupName();

            foreach (var user in RandomUserNames)
            {
                followerProvider.FollowUser(user, targetUser);
                followerProvider.FollowGroup(user, targetGroup);
            }

            var groupFollowersCount       = followerProvider.GetGroupFollowers(targetGroup).Count();
            var userFollowersCount        = followerProvider.GetUserFollowers(targetUser).Count();
            var cachedGroupFollowersCount = followerProvider.GetGroupFollowersCached(targetGroup).Count();
            var cachedUserFollowersCount  = followerProvider.GetUserFollowersCached(targetUser).Count();
            var userFollowerPagedCount    = followerProvider.GetUserFollowersPaged(targetUser, 20, 20).TotalCount;
            var groupFollowerPagedCount   = followerProvider.GetGroupFollowersPaged(targetGroup, 20, 20).TotalCount;

            var shouldGroupFollowerCountBeEqual = groupFollowersCount == cachedGroupFollowersCount;
            var shouldUserFollowerCountBeEqual  = userFollowersCount == cachedUserFollowersCount;


            Assert.IsTrue(shouldGroupFollowerCountBeEqual && shouldUserFollowerCountBeEqual);

            shouldGroupFollowerCountBeEqual = groupFollowersCount == groupFollowerPagedCount;
            shouldGroupFollowerCountBeEqual = userFollowersCount == userFollowerPagedCount;

            Assert.IsTrue(shouldGroupFollowerCountBeEqual && shouldUserFollowerCountBeEqual);
        }