Beispiel #1
0
        public async Task GetImageCountAsync_Any()
        {
            var client   = new MashapeClient(ClientId, ClientSecret, MashapeKey, OAuth2Token);
            var endpoint = new AccountEndpoint(client);

            var imageCount = await endpoint.GetImageCountAsync();

            Assert.IsTrue(imageCount > 1);
        }
        public async Task GetImageCountAsync_WithValidReponse_AreEqual()
        {
            var client   = new MashapeClient(ClientId, ClientSecret, MashapeKey, await GetOAuth2Token());
            var endpoint = new AccountEndpoint(client);

            var imageCount = await endpoint.GetImageCountAsync();

            Assert.IsTrue(imageCount > 1);
        }
Beispiel #3
0
        public async Task GetImageCountAsync_WithUsernameNull_ThrowsArgumentNullException()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new AccountEndpoint(client);

            var exception =
                await
                Record.ExceptionAsync(
                    async() => await endpoint.GetImageCountAsync(null).ConfigureAwait(false))
                .ConfigureAwait(false);

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);
        }
Beispiel #4
0
        public async Task GetImageCountAsync_NotNull()
        {
            var mockUrl      = "https://api.imgur.com/3/account/sarah/images/count";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAccountEndpointResponses.GetImageCount)
            };

            var client   = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new AccountEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var count    = await endpoint.GetImageCountAsync("sarah").ConfigureAwait(false);

            Assert.Equal(count, 2);
        }
        public async Task GetImageCountAsync_IsNotNull()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.GetImageCountResponse)
            };

            fakeHttpMessageHandler.AddFakeResponse(new Uri("https://api.imgur.com/3/account/sarah/images/count"),
                                                   fakeResponse);

            var tokenHandler = new FakeOAuth2TokenHandler();
            var client       = new ImgurClient("123", "1234", tokenHandler.GetOAuth2TokenCodeResponse());
            var endpoint     = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var count        = await endpoint.GetImageCountAsync("sarah");

            Assert.AreEqual(count, 2);
        }
 public async Task GetImageCountAsync_WithUsernameNull_ThrowsArgumentNullException()
 {
     var client   = new ImgurClient("123", "1234");
     var endpoint = new AccountEndpoint(client);
     await endpoint.GetImageCountAsync(null);
 }