Exemplo n.º 1
0
        private FollowersSample ManageFollowers()
        {
            var result = new FollowersSample();

            //Define sample user
            result.WallOwner = GetRandomUserWallOwner(true);
            var wallOwner = result.WallOwner.OwnerId;

            Trace.WriteLine(string.Concat("WallOwner: ", wallOwner));

            result.Follower = GetRandomUserName();
            Trace.WriteLine(string.Concat("Follower: ", result.Follower));

            result.Publisher = GetRandomUserName();
            Trace.WriteLine(string.Concat("Publisher: ", result.Publisher));

            result.PublisherFollower = GetRandomUserName();
            Trace.WriteLine(string.Concat("PublisherFollower: ", result.PublisherFollower));

            followerProvider.FollowUser(result.Follower, wallOwner);
            followerProvider.FollowUser(result.PublisherFollower, result.Publisher);

            Trace.WriteLine(string.Format("{0} follows {1}, {2} follows {3}", result.Follower, wallOwner, result.PublisherFollower, result.Publisher));

            return(result);
        }
Exemplo n.º 2
0
        public void Should_Follow_User_Once()
        {
            var follower   = GetRandomUserName();
            var targetUser = GetRandomUserName();

            followerProvider.FollowUser(follower, targetUser);
            followerProvider.FollowUser(follower, targetUser);

            var followers       = followerProvider.GetUserFollowers(targetUser);
            var followerRecords = followers.Where(f => f == follower);

            var shouldExist     = followerRecords.Any();
            var shouldExistOnce = followerRecords.Count() == 1;

            Assert.IsTrue(shouldExist && shouldExistOnce);
        }
Exemplo n.º 3
0
        public void Newsfeed_Should_Insert_NewWallPost_To_UserFeed_And_Check_Duplicate()
        {
            var sampleUserWall = GetRandomUserWallOwner(true);
            var sampleUser     = sampleUserWall.OwnerId;

            foreach (var user in RandomUserNames)
            {
                followerProvider.FollowUser(user, sampleUser);
            }

            var request      = GetSampleWallCreateRequest(sampleUser, sampleUserWall);
            var samplePostId = userWallPostProvider.AddPost(request);

            var newsFeedEntry = new NewsfeedItem
            {
                By = request.PostedBy,
                ReferencePostId = samplePostId,
                FeedType        = NewsfeedActionType.wallpost,
                WallOwner       = new Core.Models.Wall.NewsfeedWallModel {
                    IsPublic = true, OwnerId = sampleUserWall.OwnerId, WallOwnerType = sampleUserWall.WallOwnerType
                }
            };

            userNewsfeedProvider.AddNewsfeedItem(newsFeedEntry);
            userNewsfeedProvider.AddNewsfeedItem(newsFeedEntry);

            newsFeedEntry = new NewsfeedItem
            {
                By = request.PostedBy,
                ReferencePostId = samplePostId,
                FeedType        = NewsfeedActionType.like,
                WallOwner       = new Core.Models.Wall.NewsfeedWallModel {
                    IsPublic = true, OwnerId = sampleUserWall.OwnerId, WallOwnerType = sampleUserWall.WallOwnerType
                }
            };
            userNewsfeedProvider.AddNewsfeedItem(newsFeedEntry);

            var feeds = new List <IEnumerable <NewsfeedResponseModel> >();

            foreach (var user in RandomUserNames)
            {
                feeds.Add(userNewsfeedProvider.GetUserNewsfeed(user, 0, 30));
            }
            userNewsfeedProvider.RemovePost(newsFeedEntry);
        }
Exemplo n.º 4
0
 public void FollowUser(string activeUserId, string userIdToFollow)
 {
     userFollowerProvider.FollowUser(activeUserId, userIdToFollow);
 }