public async Task TestGooglePlusPost() { var service = new GooglePlusService(new SafeHttpClient(), new Configuration.GooglePlusConfiguration { ApiKey = _apiKey }); var personId = await service.GetPersonIdAsync(name); Assert.IsNotNull(personId); var post = await service.GetActivityWithVideoAsync(personId, videoId); Assert.IsNotNull(post); Assert.IsFalse(string.IsNullOrWhiteSpace(post.Title)); TestContext.WriteLine($"Post: {post.Title}"); }
public async Task GetActivityWithVideoAsyncNotFoundTest() { // Mock var httpMock = new Mock <ISafeHttpClient>(MockBehavior.Strict); httpMock.Setup(x => x.GetAsync <GooglePlus.ActivityResponse>(It.Is <string>(s => checkApiCall(s, "people/Person1/activities/public", null)))) .ReturnsAsync(null as GooglePlus.ActivityResponse); // Run var service = new GooglePlusService(httpMock.Object, config); var activity = await service.GetActivityWithVideoAsync("Person1", "Video1"); // Assert Assert.IsNull(activity); // Verify httpMock.VerifyAll(); }
public async Task GetActivityWithVideoAsyncTest() { // Mock var httpMock = new Mock <ISafeHttpClient>(MockBehavior.Strict); httpMock.Setup(x => x.GetAsync <GooglePlus.ActivityResponse>(It.Is <string>(s => checkApiCall(s, "people/Person1/activities/public", null)))) .ReturnsAsync(_mockActivityResponse); // Run var service = new GooglePlusService(httpMock.Object, config); var activity = await service.GetActivityWithVideoAsync("Person1", "Video1"); // Assert Assert.AreEqual(_mockActivityResponse.Items.First(i => i.Object.Attachments.Any(a => a.ObjectType.Equals("video") && a.Url.Contains("Video1"))).Id, activity.Id); // Verify httpMock.VerifyAll(); }