GetAlbumAsync() public method

Get additional information about an album, this works the same as the Album Endpoint.
/// 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 GetAlbumAsync ( string albumId, string username = "me" ) : Task
albumId string The album id.
username string The user account. Default: me
return Task
Ejemplo n.º 1
0
        public async Task GetAlbumAsync_IsNotNull()
        {
            var client = new ImgurClient(ClientId, ClientSecret);
            var endpoint = new AccountEndpoint(client);

            var album = await endpoint.GetAlbumAsync("SbU9Y", "sarah");

            Assert.IsNotNull(album);
        }
        public async Task GetAlbumAsync_NotNull()
        {
            var mockUrl = "https://api.imgur.com/3/account/sarah/album/yMgB7";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAccountEndpointResponses.GetAlbum)
            };

            var client = new ImgurClient("123", "1234");
            var endpoint = new AccountEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var album = await endpoint.GetAlbumAsync("yMgB7", "sarah").ConfigureAwait(false);

            Assert.NotNull(album);
            Assert.Equal("yMgB7", album.Id);
            Assert.Equal("Day 2 at Camp Imgur", album.Title);
            Assert.Equal(null, album.Description);
            Assert.Equal(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(1439066984), album.DateTime);
            Assert.Equal("BOdd9Qd", album.Cover);
            Assert.Equal(5184, album.CoverWidth);
            Assert.Equal(3456, album.CoverHeight);
            Assert.Equal("sarah", album.AccountUrl);
            Assert.Equal(9571, album.AccountId);
            Assert.Equal(AlbumPrivacy.Public, album.Privacy);
            Assert.Equal(AlbumLayout.Blog, album.Layout);
            Assert.Equal(413310, album.Views);
            Assert.Equal("http://imgur.com/a/yMgB7", album.Link);
            Assert.Equal(false, album.Favorite);
            Assert.Equal(false, album.Nsfw);
            Assert.Equal("pics", album.Section);
            Assert.Equal(6, album.ImagesCount);
        }
        public async Task GetAlbumAsync_WithUsernameNull_ThrowsArgumentNullException()
        {
            var client = new ImgurClient("123", "1234");
            var endpoint = new AccountEndpoint(client);

            var exception =
                await
                    Record.ExceptionAsync(
                        async () => await endpoint.GetAlbumAsync("yMgB7", null).ConfigureAwait(false))
                        .ConfigureAwait(false);
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);
        }
        public async Task GetAlbumAsync_WithValidReponse_AreEqual()
        {
            var client = new ImgurClient(ClientId, ClientSecret, await GetOAuth2Token());
            var endpoint = new AccountEndpoint(client);

            var album = await endpoint.GetAlbumAsync("cuta6");

            Assert.IsNotNull(album);
        }
 public async Task GetAlbumAsync_WithUsernameNull_ThrowsArgumentNullException()
 {
     var client = new ImgurClient("123", "1234");
     var endpoint = new AccountEndpoint(client);
     await endpoint.GetAlbumAsync("yMgB7", null);
 }