Example #1
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);
        }
Example #2
0
        private void ManageWallPost(FollowersSample users, Stopwatch stopWatch)
        {
            Trace.WriteLine("");
            stopWatch.Restart();
            var randomNumber = new Random().Next(10);

            for (int i = 0; i < randomNumber; i++)
            {
                var sampleRequest = GetSampleWallCreateRequest(users.Publisher, users.WallOwner);
                var samplePostId  = wallPostProvider.AddPost(sampleRequest);

                Trace.WriteLine(string.Format("CreatedPost - {0}, {1}", samplePostId, JsonConvert.SerializeObject(sampleRequest)));
                var newsFeedEntry = new NewsfeedItem
                {
                    By = sampleRequest.PostedBy,
                    ReferencePostId = samplePostId,
                    FeedType        = NewsfeedActionType.wallpost,
                    WallOwner       = new NewsfeedWallModel {
                        IsPublic = true, OwnerId = users.WallOwner.OwnerId, WallOwnerType = WallType.user
                    }
                };
                newsFeedProvider.AddNewsfeedItem(newsFeedEntry);
            }
            Trace.WriteLine(string.Format("{0} posts {1}'s wall, NumberOfPosts : {2}", users.Publisher, users.WallOwner.OwnerId, randomNumber));
            stopWatch.Stop();
            Trace.WriteLine(string.Format("Posted (Db & Cache) {0} items : {1} ms", randomNumber, stopWatch.ElapsedMilliseconds));
            Trace.WriteLine("");


            stopWatch.Restart();
            var feedResult = newsFeedProvider.GetUserNewsfeed(users.Follower, 0, 100);

            Trace.WriteLine(string.Format("Feed of {0} contains {1} items", users.Follower, feedResult.Count()));
            stopWatch.Stop();
            Trace.WriteLine(string.Format("GetFeed : {0} ms", stopWatch.ElapsedMilliseconds));

            stopWatch.Restart();
            feedResult = newsFeedProvider.GetUserNewsfeed(users.PublisherFollower, 0, 100);
            Trace.WriteLine(string.Format("Feed of {0} contains {1} items", users.PublisherFollower, feedResult.Count()));
            stopWatch.Stop();
            Trace.WriteLine(string.Format("GetFeed : {0} ms", stopWatch.ElapsedMilliseconds));

            stopWatch.Restart();
            feedResult = newsFeedProvider.GetUserNewsfeed(users.Publisher, 0, 100);
            Trace.WriteLine(string.Format("Feed of {0} contains {1} items", users.Publisher, feedResult.Count()));
            stopWatch.Stop();
            Trace.WriteLine(string.Format("GetFeed : {0} ms", stopWatch.ElapsedMilliseconds));

            stopWatch.Restart();
            feedResult = newsFeedProvider.GetUserNewsfeed(users.WallOwner.OwnerId, 0, 100);
            Trace.WriteLine(string.Format("Feed of {0} contains {1} items", users.WallOwner.OwnerId, feedResult.Count()));
            stopWatch.Stop();
            Trace.WriteLine(string.Format("GetFeed : {0} ms", stopWatch.ElapsedMilliseconds));
            Trace.WriteLine("");


            feedResult = newsFeedProvider.GetUserNewsfeed(users.Follower, 0, 100);
            Trace.WriteLine(string.Format("Feed of {0}", users.Follower));
            foreach (var post in feedResult)
            {
                Trace.WriteLine(JsonConvert.SerializeObject(post));
            }
            Trace.WriteLine("");

            stopWatch.Restart();
            var wallPostResult = wallPostProvider.GetUserWall(users.WallOwner.OwnerId, DateTime.Now, 100);


            foreach (var post in wallPostResult)
            {
                Trace.WriteLine(JsonConvert.SerializeObject(post));
            }
            Trace.WriteLine(string.Format("Fetched {0} items from Wall of {1} : {2} ms", wallPostResult.Count(), users.Follower, stopWatch.ElapsedMilliseconds));
            Trace.WriteLine("");
            stopWatch.Stop();

            stopWatch.Restart();
            var wallPostDetailedResult = wallPostProvider.GetUserWallDetailed(users.WallOwner.OwnerId, DateTime.Now, 100);

            foreach (var post in wallPostResult)
            {
                Trace.WriteLine(JsonConvert.SerializeObject(post));
            }
            stopWatch.Stop();
            Trace.WriteLine(string.Format("Fetched {0} items from Wall of {1} : {2} ms", wallPostDetailedResult.Count(), users.Follower, stopWatch.ElapsedMilliseconds));
        }