RetrievePostsCreatedByUser() public method

Retrieves a list of posts created by a given userId.
public RetrievePostsCreatedByUser ( string userId, PostStreamGeneralParameters postStreamGeneralParameters = null ) : ResponseEnvelope>
userId string May be a userId, Username, or "me" for the current user.
postStreamGeneralParameters PostStreamGeneralParameters
return ResponseEnvelope>
示例#1
0
        public void PostsServiceCanRetrievePostsCreatedByASpecificUserFilteredByPostStreamGeneralParameters()
        {
            //Setup
            const string userId = "1";
            var postStreamGeneralParameters = new PostStreamGeneralParameters { BeforeId = "10" };
            var apiCaller = A.Fake<IApiCaller>();
            var postsService = new PostsService(apiCaller);
            A.CallTo(apiCaller).WithReturnType<ResponseEnvelope<List<Post>>>().Returns(new ResponseEnvelope<List<Post>>
                                                                                           {
                                                                                               Data = new List<Post> { new Post { Id = "5", User = new User { Id = userId } } }
                                                                                           });

            //Execute
            var posts = postsService.RetrievePostsCreatedByUser(userId, postStreamGeneralParameters);

            //Verify
            posts.ShouldNotBeNull();

            foreach (var post in posts.Data)
            {
                post.User.ShouldNotBeNull();
                post.User.Id.ShouldNotBeNull();
                post.User.Id.ShouldEqual(userId);
                int.Parse(post.Id).ShouldBeLessThan(int.Parse(postStreamGeneralParameters.BeforeId));
            }

            //Teardown
        }
示例#2
0
        public void PostsServiceCanRetrievePostsCreatedByASpecficUser()
        {
            //Setup
            const string userId = "1";
            var apiCaller = A.Fake<IApiCaller>();
            var postsService = new PostsService(apiCaller);
            A.CallTo(() => apiCaller.ApiGet<List<Post>>(UsersService.USERS_ENDPOINT + userId + "/" + PostsService.POSTS_ENDPOINT, null)).Returns(new ResponseEnvelope<List<Post>>
                                                                                                                                                     {
                                                                                                                                                         Data = new List<Post>
                                                                                                                                                                    {
                                                                                                                                                                        new Post
                                                                                                                                                                            {
                                                                                                                                                                                User = new User { Id = userId }
                                                                                                                                                                            }
                                                                                                                                                                    }
                                                                                                                                                     });

            //Execute
            var posts = postsService.RetrievePostsCreatedByUser(userId);

            //Verify
            posts.ShouldNotBeNull();

            foreach (var post in posts.Data)
            {
                post.User.ShouldNotBeNull();
                post.User.Id.ShouldNotBeNull();
                post.User.Id.ShouldEqual(userId);
            }

            //Teardown
        }