Esempio n. 1
0
        public void RemoveCustomGalleryTagsRequest_WithUrlNull_ThrowsArgumentNullException()
        {
            var requestBuilder = new CustomGalleryRequestBuilder();

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

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

            var argNullException = (ArgumentNullException)exception;

            Assert.Equal(argNullException.ParamName, "url");
        }
Esempio n. 2
0
        public void RemoveCustomGalleryTagsRequest_WithTagsNull_ThrowsArgumentNullException()
        {
            var client         = new ImgurClient("123", "1234");
            var requestBuilder = new CustomGalleryRequestBuilder();
            var mockUrl        = $"{client.EndpointUrl}g/custom/remove_tags";

            var exception = Record.Exception(() => CustomGalleryRequestBuilder.RemoveCustomGalleryTagsRequest(mockUrl, null));

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

            var argNullException = (ArgumentNullException)exception;

            Assert.Equal(argNullException.ParamName, "tags");
        }
Esempio n. 3
0
        public void RemoveCustomGalleryTagsRequest_Equal()
        {
            var client         = new ImgurClient("123", "1234");
            var requestBuilder = new CustomGalleryRequestBuilder();

            var mockUrl = $"{client.EndpointUrl}g/custom/remove_tags";
            var tags    = new List <string> {
                "Cats", "Dogs", "Seals"
            };

            var request  = CustomGalleryRequestBuilder.RemoveCustomGalleryTagsRequest(mockUrl, tags);
            var expected = "https://api.imgur.com/3/g/custom/remove_tags?tags=Cats%2CDogs%2CSeals";

            Assert.NotNull(request);
            Assert.Equal(expected, request.RequestUri.ToString());
            Assert.Equal(HttpMethod.Delete, request.Method);
        }
Esempio n. 4
0
        /// <summary>
        ///     Remove tags from a custom gallery.
        ///     OAuth authentication required.
        /// </summary>
        /// <param name="tags">The tags that should be removed.</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> RemoveCustomGalleryTagsAsync(IEnumerable <string> tags)
        {
            if (tags == null)
            {
                throw new ArgumentNullException(nameof(tags));
            }

            if (ApiClient.OAuth2Token == null)
            {
                throw new ArgumentNullException(nameof(ApiClient.OAuth2Token), OAuth2RequiredExceptionMessage);
            }

            var url = "g/custom/remove_tags";

            using (var request = CustomGalleryRequestBuilder.RemoveCustomGalleryTagsRequest(url, tags))
            {
                var removed = await SendRequestAsync <bool?>(request).ConfigureAwait(false);

                return(removed ?? true);
            }
        }