コード例 #1
0
        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}");
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }