Esempio n. 1
0
        public async Task GetGalleryProfileAsync_IsNotNull()
        {
            var client   = new ImgurClient(ClientId, ClientSecret, OAuth2Token);
            var endpoint = new AccountEndpoint(client);

            var profile = await endpoint.GetGalleryProfileAsync();

            Assert.IsNotNull(profile);
        }
Esempio n. 2
0
        public async Task GetGalleryProfileAsync_AnyTrophies_IsTrue()
        {
            var client   = new MashapeClient(ClientId, ClientSecret, MashapeKey);
            var endpoint = new AccountEndpoint(client);

            var profile = await endpoint.GetGalleryProfileAsync("sarah");

            Assert.IsTrue(profile.Trophies.Any());
        }
        public async Task GetGalleryProfileAsync_WithDefaultUsername_AnyTrophies_IsFalse()
        {
            var client   = new MashapeClient(ClientId, ClientSecret, MashapeKey, await GetOAuth2Token());
            var endpoint = new AccountEndpoint(client);

            var profile = await endpoint.GetGalleryProfileAsync();

            Assert.IsFalse(profile.Trophies.Any());
        }
Esempio n. 4
0
        public async Task WithDefaultUsernameAndOAuth2Null_ThrowsArgumentNullException_GetGalleryProfileAsync()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new AccountEndpoint(client);

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

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);
        }
Esempio n. 5
0
        public async Task NotNull_GetGalleryProfileAsync()
        {
            const string mockUrl      = "https://api.imgur.com/3/account/me/gallery_profile";
            var          mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAccountEndpointResponses.GetGalleryProfile)
            };

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

            Assert.NotNull(profile);
        }
        public async Task GetGalleryProfileAsync_IsNotNull()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.GetGalleryProfileResponse)
            };

            fakeHttpMessageHandler.AddFakeResponse(new Uri("https://api.imgur.com/3/account/me/gallery_profile"),
                                                   fakeResponse);

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var profile           = await endpoint.GetGalleryProfileAsync();

            Assert.IsNotNull(profile);
        }
 public async Task GetGalleryProfileAsync_WithUsernameNull_ThrowsArgumentNullException()
 {
     var client   = new ImgurClient("123", "1234");
     var endpoint = new AccountEndpoint(client);
     await endpoint.GetGalleryProfileAsync(null);
 }