FavoriteAlbumAsync() public method

Favorite an album with a given Id. 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 FavoriteAlbumAsync ( string albumId ) : Task
albumId string The album id.
return Task
Exemplo n.º 1
0
        public async Task FavoriteAlbumAsync_WithMashapeClient_True()
        {
            var mockUrl = "https://imgur-apiv3.p.mashape.com/3/album/zVpyzhW/favorite";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAlbumEndpointResponses.Imgur.FavoriteAlbumTrue)
            };

            var client = new MashapeClient("123", "1234", "xyz", MockOAuth2Token);
            var endpoint = new AlbumEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var favorited = await endpoint.FavoriteAlbumAsync("zVpyzhW").ConfigureAwait(false);

            Assert.True(favorited);
        }
Exemplo n.º 2
0
        public async Task FavoriteAlbumAsync_WithIdNull_ThrowsArgumentNullException()
        {
            var client = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new AlbumEndpoint(client);

            var exception =
                await
                    Record.ExceptionAsync(
                        async () => await endpoint.FavoriteAlbumAsync(null).ConfigureAwait(false))
                        .ConfigureAwait(false);
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);
        }