public async Task TestGooglePlusComments() { var service = new GooglePlusService(new SafeHttpClient(), new Configuration.GooglePlusConfiguration { ApiKey = _apiKey }); var comments = await service.GetCommentsAsync(postId); 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("Google+", comment.Source); } }
public async Task GetCommentsAsyncNullTest() { // Mock var httpMock = new Mock <ISafeHttpClient>(MockBehavior.Strict); httpMock.Setup(x => x.GetAsync <GooglePlus.CommentsResponse>(It.Is <string>(s => checkApiCall(s, "activities/Activity1/comments", null)))) .ReturnsAsync(null as GooglePlus.CommentsResponse); // Run var service = new GooglePlusService(httpMock.Object, config); var comments = await service.GetCommentsAsync("Activity1"); // Assert Assert.IsNotNull(comments); Assert.IsEmpty(comments); // Verify httpMock.VerifyAll(); }
public async Task GetCommentsAsyncPAgingTest() { // Set Up Model _mockCommentsResponse.NextPageToken = "SOME PAGE TOKEN"; // Mock var httpMock = new Mock <ISafeHttpClient>(MockBehavior.Strict); httpMock.SetupSequence(x => x.GetAsync <GooglePlus.CommentsResponse>(It.Is <string>(s => checkApiCall(s, "activities/Activity1/comments", null)))) .ReturnsAsync(_mockCommentsResponse) .ReturnsAsync(_mockCommentsResponseSecondPage); // Run var service = new GooglePlusService(httpMock.Object, config); var comments = await service.GetCommentsAsync("Activity1"); // Assert Assert.IsNotNull(comments); Assert.AreEqual(4, comments.Count); // Verify httpMock.VerifyAll(); }