Imgur.API.RequestBuilders.AlbumRequestBuilder.SetAlbumImagesRequest C# (CSharp) Method

SetAlbumImagesRequest() private method

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

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

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

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

            return request;
        }

Usage Example

        public void SetAlbumImagesRequest_WithUrlNull_ThrowsArgumentNullException()
        {
            var requestBuilder = new AlbumRequestBuilder();

            var exception = Record.Exception(() => requestBuilder.SetAlbumImagesRequest(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.AlbumRequestBuilder::SetAlbumImagesRequest