public void RemoveAlbumImagesRequest_WithIdsNull_ThrowsArgumentNullException()
        {
            var client         = new ImgurClient("123", "1234");
            var requestBuilder = new AlbumRequestBuilder();
            var url            = $"{client.EndpointUrl}album/AbcdeF/remove_images";

            requestBuilder.RemoveAlbumImagesRequest(url, null);
        }
        public void RemoveAlbumImagesRequest_WithUrlNull_ThrowsArgumentNullException()
        {
            var requestBuilder = new AlbumRequestBuilder();

            var exception = Record.Exception(() => AlbumRequestBuilder.RemoveAlbumImagesRequest(null, new List <string>()));

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);

            var argNullException = (ArgumentNullException)exception;

            Assert.Equal(argNullException.ParamName, "url");
        }
        public void RemoveAlbumImagesRequest_WithIdsNull_ThrowsArgumentNullException()
        {
            var client         = new ImgurClient("123", "1234");
            var requestBuilder = new AlbumRequestBuilder();
            var mockUrl        = $"{client.EndpointUrl}album/AbcdeF/remove_images";

            var exception = Record.Exception(() => AlbumRequestBuilder.RemoveAlbumImagesRequest(mockUrl, null));

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);

            var argNullException = (ArgumentNullException)exception;

            Assert.Equal(argNullException.ParamName, "imageIds");
        }
        public void RemoveAlbumImagesRequest_Equal()
        {
            var client         = new ImgurClient("123", "1234");
            var requestBuilder = new AlbumRequestBuilder();

            var mockUrl = $"{client.EndpointUrl}album/AbcdeF/remove_images";
            var ids     = new List <string> {
                "Abc", "DEF", "XyZ"
            };

            var request  = AlbumRequestBuilder.RemoveAlbumImagesRequest(mockUrl, ids);
            var expected = "https://api.imgur.com/3/album/AbcdeF/remove_images?ids=Abc%2CDEF%2CXyZ";

            Assert.NotNull(request);
            Assert.Equal(expected, request.RequestUri.ToString());
            Assert.Equal(HttpMethod.Delete, request.Method);
        }
Exemple #5
0
        /// <summary>
        ///     Takes a list of imageIds and removes from the album. For anonymous albums, {albumId} should be the
        ///     deletehash that is returned at creation.
        /// </summary>
        /// <param name="albumId">The id or deletehash of the album.</param>
        /// <param name="imageIds">The imageIds that you want to be removed from the album.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when a null reference is passed to a method that does not accept it as a
        ///     valid argument.
        /// </exception>
        /// <exception cref="ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception>
        /// <exception cref="MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception>
        /// <returns></returns>
        public async Task <bool> RemoveAlbumImagesAsync(string albumId, IEnumerable <string> imageIds)
        {
            if (string.IsNullOrWhiteSpace(albumId))
            {
                throw new ArgumentNullException(nameof(albumId));
            }

            if (imageIds == null)
            {
                throw new ArgumentNullException(nameof(imageIds));
            }

            var url = $"album/{albumId}/remove_images";

            using (var request = AlbumRequestBuilder.RemoveAlbumImagesRequest(url, imageIds))
            {
                var removed = await SendRequestAsync <bool>(request).ConfigureAwait(false);

                return(removed);
            }
        }
Exemple #6
0
        /// <summary>
        ///     Takes a list of imageIds and removes from the album. For anonymous albums, {albumId} should be the
        ///     deletehash that is returned at creation.
        /// </summary>
        /// <param name="albumId">The id or deletehash of the album.</param>
        /// <param name="imageIds">The imageIds that you want to be removed from the album.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when a null reference is passed to a method that does not accept it as a
        ///     valid argument.
        /// </exception>
        /// <exception cref="ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception>
        /// <exception cref="MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception>
        /// <returns></returns>
        public Basic <bool> RemoveAlbumImages(string albumId, IEnumerable <string> imageIds)
        {
            if (string.IsNullOrWhiteSpace(albumId))
            {
                throw new ArgumentNullException(nameof(albumId));
            }

            if (imageIds == null)
            {
                throw new ArgumentNullException(nameof(imageIds));
            }

            var url = $"album/{albumId}/remove_images";

            using (var request = AlbumRequestBuilder.RemoveAlbumImagesRequest(url, imageIds))
            {
                var httpResponse = HttpClient.SendAsync(request).Result;
                var jsonString   = httpResponse.Content.ReadAsStringAsync().Result;
                var output       = Newtonsoft.Json.JsonConvert.DeserializeObject <Basic <bool> >(httpResponse.Content.ReadAsStringAsync().Result.ToString());
                return(output);
            }
        }
        public void RemoveAlbumImagesRequest_WithUrlNull_ThrowsArgumentNullException()
        {
            var requestBuilder = new AlbumRequestBuilder();

            requestBuilder.RemoveAlbumImagesRequest(null, null);
        }