GetAccountGalleryFavoritesAsync() public method

Return the images the user has favorited in the gallery.
/// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. /// Thrown when an error is found in a response from an Imgur endpoint. Thrown when an error is found in a response from a Mashape endpoint.
public GetAccountGalleryFavoritesAsync ( string username = "me", int page = null, AccountGallerySortOrder sort = AccountGallerySortOrder.Newest ) : Task>
username string The user account. Default: me
page int Set the page number so you don't have to retrieve all the data at once. Default: null
sort AccountGallerySortOrder The order that the account gallery should be sorted by. Default: Newest
return Task>
コード例 #1
0
 public async Task GetAccountGalleryFavoritesAsync_WithDefaultUsernameAndOAuth2Null_ThrowsArgumentNullException
     ()
 {
     var client = new ImgurClient("123", "1234");
     var endpoint = new AccountEndpoint(client);
     await endpoint.GetAccountGalleryFavoritesAsync();
 }
コード例 #2
0
        public async Task GetAccountGalleryFavoritesAsync_Any_IsTrue()
        {
            var client = new ImgurClient(ClientId, ClientSecret);
            var endpoint = new AccountEndpoint(client);

            var favourites = await endpoint.GetAccountGalleryFavoritesAsync("sarah");

            Assert.IsTrue(favourites.Any());
        }
コード例 #3
0
        public async Task GetAccountGalleryFavoritesAsync_WithDefaultUsernameAndOAuth2Null_ThrowsArgumentNullException()
        {
            var client = new ImgurClient("123", "1234");
            var endpoint = new AccountEndpoint(client);

            var exception =
                await
                    Record.ExceptionAsync(
                        async () => await endpoint.GetAccountGalleryFavoritesAsync().ConfigureAwait(false))
                        .ConfigureAwait(false);
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);
        }
コード例 #4
0
        public async Task GetAccountGalleryFavoritesAsync_Any()
        {
            var mockUrl = "https://api.imgur.com/3/account/me/gallery_favorites/2/oldest";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAccountEndpointResponses.GetAccountGalleryFavorites)
            };

            var client = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new AccountEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var favorites =
                await
                    endpoint.GetAccountGalleryFavoritesAsync(page: 2, sort: AccountGallerySortOrder.Oldest)
                        .ConfigureAwait(false);

            Assert.True(favorites.Any());
        }
コード例 #5
0
        public async Task GetAccountGalleryFavoritesAsync_Any()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.GetAccountGalleryFavoritesResponse)
            };

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

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var favorites = await endpoint.GetAccountGalleryFavoritesAsync(page: 2, sort: GallerySortOrder.Oldest);

            Assert.IsTrue(favorites.Any());
        }