Imgur.API.RequestBuilders.CustomGalleryRequestBuilder.AddFilteredOutGalleryTagRequest C# (CSharp) Méthode

AddFilteredOutGalleryTagRequest() private méthode

/// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. ///
private AddFilteredOutGalleryTagRequest ( string url, string tag ) : HttpRequestMessage
url string
tag string
Résultat System.Net.Http.HttpRequestMessage
        internal HttpRequestMessage AddFilteredOutGalleryTagRequest(string url, string tag)
        {
            if (string.IsNullOrWhiteSpace(url))
                throw new ArgumentNullException(nameof(url));

            if (string.IsNullOrWhiteSpace(tag))
                throw new ArgumentNullException(nameof(tag));

            var parameters = new Dictionary<string, string>
            {
                {nameof(tag), tag}
            };

            var request = new HttpRequestMessage(HttpMethod.Post, url)
            {
                Content = new FormUrlEncodedContent(parameters.ToArray())
            };

            return request;
        }

Usage Example

        public void AddFilteredOutGalleryTagRequest_WithTagNull_ThrowsArgumentNullException()
        {
            var client = new ImgurClient("123", "1234");
            var requestBuilder = new CustomGalleryRequestBuilder();
            var mockUrl = $"{client.EndpointUrl}g/block_tag";

            var exception = Record.Exception(() => requestBuilder.AddFilteredOutGalleryTagRequest(mockUrl, null));
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);

            var argNullException = (ArgumentNullException) exception;
            Assert.Equal(argNullException.ParamName, "tag");
        }
All Usage Examples Of Imgur.API.RequestBuilders.CustomGalleryRequestBuilder::AddFilteredOutGalleryTagRequest