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

            var exception = Record.Exception(() => AlbumRequestBuilder.UpdateAlbumRequest(null));

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

            var argNullException = (ArgumentNullException)exception;

            Assert.Equal(argNullException.ParamName, "url");
        }
Exemple #2
0
        /// <summary>
        ///     Update the information of an 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="title">The title of the album.</param>
        /// <param name="description">The description of the album.</param>
        /// <param name="privacy">Sets the privacy level of the album.</param>
        /// <param name="layout">Sets the layout to display the album.</param>
        /// <param name="coverId">The Id of an image that you want to be the cover of the album.</param>
        /// <param name="imageIds">The imageIds that you want to be included in 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> UpdateAlbumAsync(string albumId, string title  = null, string description = null,
                                                  AlbumPrivacy?privacy          = null, AlbumLayout?layout = null, string coverId = null,
                                                  IEnumerable <string> imageIds = null)
        {
            if (string.IsNullOrWhiteSpace(albumId))
            {
                throw new ArgumentNullException(nameof(albumId));
            }

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

            using (var request = AlbumRequestBuilder.UpdateAlbumRequest(url, title, description,
                                                                        privacy, layout, coverId, imageIds))
            {
                var updated = await SendRequestAsync <bool>(request).ConfigureAwait(false);

                return(updated);
            }
        }
Exemple #3
0
        /// <summary>
        ///     Update the information of an 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="title">The title of the album.</param>
        /// <param name="description">The description of the album.</param>
        /// <param name="privacy">Sets the privacy level of the album.</param>
        /// <param name="layout">Sets the layout to display the album.</param>
        /// <param name="coverId">The Id of an image that you want to be the cover of the album.</param>
        /// <param name="imageIds">The imageIds that you want to be included in 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> UpdateAlbum(string albumId, string title  = null, string description = null,
                                        AlbumPrivacy?privacy          = null, AlbumLayout?layout = null, string coverId = null,
                                        IEnumerable <string> imageIds = null)
        {
            if (string.IsNullOrWhiteSpace(albumId))
            {
                throw new ArgumentNullException(nameof(albumId));
            }

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

            using (var request = AlbumRequestBuilder.UpdateAlbumRequest(url, title, description,
                                                                        privacy, layout, coverId, 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 async Task UpdateAlbumRequest_AreEqual()
        {
            var client         = new ImgurClient("123", "1234");
            var requestBuilder = new AlbumRequestBuilder();

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

            var request = requestBuilder.UpdateAlbumRequest(
                url, "TheTitle", "TheDescription",
                AlbumPrivacy.Hidden, AlbumLayout.Horizontal,
                "io9XpoO", ids);

            var expected =
                "privacy=hidden&layout=horizontal&cover=io9XpoO&title=TheTitle&description=TheDescription&ids=Abc%2CDEF%2CXyZ";

            Assert.IsNotNull(request);
            Assert.AreEqual(expected, await request.Content.ReadAsStringAsync());
            Assert.AreEqual("https://api.imgur.com/3/album/AbcdeF", request.RequestUri.ToString());
            Assert.AreEqual(HttpMethod.Post, request.Method);
        }
        public void UpdateAlbumRequest_WithUrlNull_ThrowsArgumentNullException()
        {
            var requestBuilder = new AlbumRequestBuilder();

            requestBuilder.UpdateAlbumRequest(null);
        }