RetrieveTaggedPosts() public method

Retrieves posts matching the given hashtag. NOTE: Unless changed by the postStreamGeneralParameters, only the latest 20 posts will be returned.
public RetrieveTaggedPosts ( string hashtag, PostStreamGeneralParameters postStreamGeneralParameters = null ) : ResponseEnvelope>
hashtag string The hashtag to search without the # character.
postStreamGeneralParameters PostStreamGeneralParameters
return ResponseEnvelope>
Esempio n. 1
0
        public void PostsServiceCanRetrievePostsWithAGivenHashtagFilteredByPostStreamGeneralParameters()
        {
            //Setup
            const string hashtag = "Test";
            var postStreamGeneralParameters = new PostStreamGeneralParameters { IncludeUser = 1 };
            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
                                     {
                                         Text = "#" + hashtag
                                         , Entities = new Entities
                                                        {
                                                            Hashtags = new List<Hashtag>
                                                                           {
                                                                               new Hashtag
                                                                                   {
                                                                                       Name = hashtag
                                                                                       , Pos = 0
                                                                                   }
                                                                           }
                                                        }
                                            , User = new User()
                                     }
                             }
                });

            //Execute
            var posts = postsService.RetrieveTaggedPosts(hashtag, postStreamGeneralParameters);

            //Verify
            posts.ShouldNotBeNull();

            foreach (var post in posts.Data)
            {
                post.Text.ShouldContain(hashtag);
                post.Entities.ShouldNotBeNull();
                post.Entities.Hashtags.ShouldNotBeNull();
                post.Entities.Hashtags[0].Name.ShouldEqual(hashtag);
                post.User.ShouldNotBeNull();
            }

            //Teardown
        }
Esempio n. 2
0
        public void PostsServiceCanRetrievePostsWithAGivenHashtag()
        {
            //Setup
            const string hashtag = "Test";
            var apiCaller = A.Fake<IApiCaller>();
            var postsService = new PostsService(apiCaller);
            A.CallTo(() => apiCaller.ApiGet<List<Post>>(PostsService.POSTS_ENDPOINT + PostsService.TAG_ENDPOINT + hashtag + "/", null))
                .Returns(new ResponseEnvelope<List<Post>>
                {
                    Data = new List<Post>
                             {
                                 new Post
                                     {
                                         Text = "#" + hashtag
                                         , Entities = new Entities
                                                        {
                                                            Hashtags = new List<Hashtag>
                                                                           {
                                                                               new Hashtag
                                                                                   {
                                                                                       Name = hashtag
                                                                                       , Pos = 0
                                                                                   }
                                                                           }
                                                        }
                                     }
                             }
                });

            //Execute
            var posts = postsService.RetrieveTaggedPosts(hashtag);

            //Verify
            posts.ShouldNotBeNull();

            foreach (var post in posts.Data)
            {
                post.Text.ShouldContain(hashtag);
                post.Entities.ShouldNotBeNull();
                post.Entities.Hashtags.ShouldNotBeNull();
                post.Entities.Hashtags[0].Name.ShouldEqual(hashtag);
            }

            //Teardown
        }