GetCustomGalleryAsync() public method

View images for current user's custom gallery. OAuth authentication required.
/// 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 GetCustomGalleryAsync ( CustomGallerySortOrder sort = CustomGallerySortOrder.Viral, TimeWindow window = TimeWindow.Week, int page = null ) : Task
sort CustomGallerySortOrder The order that the gallery should be sorted by. Default: Viral
window TimeWindow The time period that should be used in filtering requests. Default: Week
page int Set the page number so you don't have to retrieve all the data at once. Default: null
return Task
コード例 #1
0
        public async Task GetCustomGalleryAsync_WithOAuth2TokenNull_ThrowsArgumentNullException()
        {
            var mockUrl = "https://api.imgur.com/3/g/custom/top/month/1";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockCustomGalleryEndpointResponses.GetCustomGallery)
            };

            var client = new ImgurClient("123", "1234");
            var endpoint = new CustomGalleryEndpoint(client,
                new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));

            var exception =
                await
                    Record.ExceptionAsync(
                        async () =>
                            await
                                endpoint.GetCustomGalleryAsync(CustomGallerySortOrder.Top, TimeWindow.Month, 1)
                                    .ConfigureAwait(false))
                        .ConfigureAwait(false);
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);
        }
コード例 #2
0
        public async Task GetCustomGalleryAsync_TopMonth1_NotNull()
        {
            var mockUrl = "https://api.imgur.com/3/g/custom/top/month/1";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockCustomGalleryEndpointResponses.GetCustomGallery)
            };

            var client = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new CustomGalleryEndpoint(client,
                new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var gallery =
                await
                    endpoint.GetCustomGalleryAsync(CustomGallerySortOrder.Top, TimeWindow.Month, 1)
                        .ConfigureAwait(false);

            Assert.NotNull(gallery);
            Assert.Equal("imgurapidotnet", gallery.AccountUrl);
            Assert.Equal(60, gallery.ItemCount);
            Assert.Equal(60, gallery.Items.Count());
            Assert.Equal("http://imgur.com/custom", gallery.Link);
            Assert.Equal(2, gallery.Tags.Count());
        }