GetGalleryAsync() public method

Returns the images 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 GetGalleryAsync ( GallerySection section = GallerySection.Hot, GallerySortOrder sort = GallerySortOrder.Viral, TimeWindow window = TimeWindow.Day, int page = null, bool showViral = true ) : Task>
section GallerySection The gallery section. Default: Hot
sort GallerySortOrder The order that the gallery should be sorted by. Default: Viral
window TimeWindow The time period that should be used in filtering requests. Default: Day
page int The data paging number. Default: null
showViral bool Show or hide viral images from the 'user' section. Default: true
return Task>
コード例 #1
0
        public async Task GetGalleryAsync_DefaultParameters_Any()
        {
            var mockUrl = "https://api.imgur.com/3/gallery/hot/viral/day/?showViral=true";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockGalleryEndpointResponses.GetGallery)
            };

            var client = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new GalleryEndpoint(client,
                new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var gallery = await endpoint.GetGalleryAsync().ConfigureAwait(false);

            Assert.True(gallery.Any());
        }
コード例 #2
0
        public async Task GetGalleryAsync_WithUserRisingMonth2ShowViralFalse_Any()
        {
            var mockUrl = "https://api.imgur.com/3/gallery/user/rising/month/2?showViral=false";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockGalleryEndpointResponses.GetGallery)
            };

            var client = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new GalleryEndpoint(client,
                new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var gallery = await endpoint.GetGalleryAsync(GallerySection.User,
                GallerySortOrder.Rising,
                TimeWindow.Month, 2, false).ConfigureAwait(false);

            Assert.True(gallery.Any());
        }