public async Task TestCommentsFaceBookService() { var service = new FaceBookService(new SafeHttpClient(), new FaceBookConfiguration { AppId = _appId, AppSecret = _appSecret }); var pageIds = await service.GetPagesAsync("WorldsBestOfTheBest"); Assert.IsNotNull(pageIds); Assert.IsNotEmpty(pageIds); var postIds = await service.GetPostsAsync(pageIds.FirstOrDefault().Id); Assert.IsNotNull(postIds); Assert.IsNotEmpty(postIds); var comments = await service.GetCommentsAsync(postIds.FirstOrDefault().Id); Assert.IsNotNull(comments); Assert.IsNotEmpty(comments); TestContext.WriteLine($"Comments: {comments.Count}"); foreach (var comment in comments.Take(100)) { Assert.IsNotNull(comment.Content); Assert.IsNotNull(comment.Author); Assert.AreEqual("Facebook", comment.Source); } }
public async Task GetPagesAsyncNoPagingTest() { // Model Setup _mockPagesResponse.Paging = new Facebook.Paging { Next = $"https://graph.facebook.com/v2.10/search?access_token={_mockAccessTokenResponse.AccessToken}" }; // Mock var httpMock = new Mock <ISafeHttpClient>(MockBehavior.Strict); httpMock.SetupSequence(x => x.GetAsync <Facebook.PagesResponse>(It.Is <string>(s => checkApiCall(s, "/v2.10/search", null)))) .ReturnsAsync(_mockPagesResponse); httpMock.Setup(x => x.GetAsync <Facebook.AccessTokenResponse>(It.Is <string>(s => s.Contains("https://graph.facebook.com/oauth/access_token")))) .ReturnsAsync(_mockAccessTokenResponse); // Run var service = new FaceBookService(httpMock.Object, config); var pages = await service.GetPagesAsync("PageName1"); // Assert Assert.IsNotNull(pages); Assert.AreEqual(3, pages.Count); // Verify httpMock.VerifyAll(); }