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

AddCustomGalleryTagsRequest() private méthode

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

            if (tags == null)
                throw new ArgumentNullException(nameof(tags));

            var parameters = new Dictionary<string, string>
            {
                {nameof(tags), string.Join(",", tags)}
            };

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

            return request;
        }

Usage Example

        public void AddCustomGalleryTagsRequest_WithUrlNull_ThrowsArgumentNullException()
        {
            var requestBuilder = new CustomGalleryRequestBuilder();

            var exception = Record.Exception(() => requestBuilder.AddCustomGalleryTagsRequest(null, new List<string>()));
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);

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