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 GetPersonIdAsyncNullTest() { // Mock var httpMock = new Mock <ISafeHttpClient>(MockBehavior.Strict); httpMock.Setup(x => x.GetAsync <GooglePlus.PeopleResponse>(It.Is <string>(s => checkApiCall(s, "people", null)))) .ReturnsAsync(null as GooglePlus.PeopleResponse); // Run var service = new GooglePlusService(httpMock.Object, config); var personId = await service.GetPersonIdAsync("PersonName1"); // Assert Assert.IsNull(personId); // Verify httpMock.VerifyAll(); }
public async Task GetPersonIdAsyncTest() { // Mock var httpMock = new Mock <ISafeHttpClient>(MockBehavior.Strict); httpMock.Setup(x => x.GetAsync <GooglePlus.PeopleResponse>(It.Is <string>(s => checkApiCall(s, "people", null)))) .ReturnsAsync(_mockPeopleResponse); // Run var service = new GooglePlusService(httpMock.Object, config); var personId = await service.GetPersonIdAsync("PersonName2"); // Assert Assert.AreEqual(_mockPeopleResponse.Items.First(i => i.DisplayName.Equals("PersonName2")).Id, personId); // Verify httpMock.VerifyAll(); }