Exemplo n.º 1
0
        public void Should_Get_UserWall_Detailed()
        {
            var sampleUser     = GetRandomUserName();
            var sampleUserWall = GetRandomUserWallOwner(true);
            var keep           = GetSampleWallCreateRequest(sampleUser, sampleUserWall);
            var delete         = GetSampleWallCreateRequest(sampleUser, sampleUserWall);

            var keepId   = wallPostProvider.AddPost(keep);
            var deleteId = wallPostProvider.AddPost(delete);

            wallPostProvider.DeletePost(deleteId);

            var posts = wallPostProvider.GetUserWallDetailed(sampleUserWall.OwnerId, DateTime.Now, 100);

            bool shouldExist    = posts.Any(p => p.Id == keepId);
            bool shouldNotExist = posts.Any(p => p.Id == deleteId);

            Assert.IsTrue(shouldExist && !shouldNotExist);
        }
Exemplo n.º 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));
        }