/// <summary>
        /// Search for a movie's posters based on an IMDb movie URL.
        /// </summary>
        /// <param name="imdbMovieUrl">The IMDb movie URL.</param>
        /// <param name="imageWidth">The poster image's width to return.</param>
        /// <returns>The API result containing the movie's information and posters.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="imdbMovieUrl"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="imdbMovieUrl"/> is not a valid IMDb movie url.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="imageWidth"/> is not within the [30-300] range.</exception>
        public MoviePosterDbResult Search(Uri imdbMovieUrl, int imageWidth)
        {
            Check.NotNull(imdbMovieUrl, "imdbMovieUrl");
            Check.That(imdbMovieUrl.IsImdbMovieUrl(), "imdbMovieUrl", InvalidImdbMovieUrlMessage);
            Check.InRange(imageWidth, MinimumImageWidth, MaximumImageWidth, "imageWidth");

            return RequestAndParseApiUrl(this.GetApiUrl(imdbMovieUrl, imageWidth));
        }
Exemplo n.º 2
0
        public void IsImdbMovieUrlUsingIncompleteImdbMovieUrlReturnsFalse(string incompleteImdbMovieUrl)
        {
            // Arrange
            var url = new Uri(incompleteImdbMovieUrl);

            // Act
            var isImdbMovieUrl = url.IsImdbMovieUrl();

            // Assert
            Assert.False(isImdbMovieUrl);
        }
Exemplo n.º 3
0
        public void IsImdbMovieUrlUsingValidImdbMovieUrlReturnsTrue(string validImdbMovieUrl)
        {
            // Arrange
            var url = new Uri(validImdbMovieUrl);

            // Act
            var isImdbMovieUrl = url.IsImdbMovieUrl();

            // Assert
            Assert.True(isImdbMovieUrl);
        }
        /// <summary>
        /// Calculate the API call secret based on an IMDb movie URL.
        /// </summary>
        /// <param name="imdbMovieUrl">The IMDb movie URL.</param>
        /// <returns>The API secret to be used in the API call.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="imdbMovieUrl"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="imdbMovieUrl"/> is not a valid IMDb movie url.</exception>
        public string CalculateSecret(Uri imdbMovieUrl)
        {
            Check.NotNull(imdbMovieUrl, "imdbMovieUrl");
            Check.That(imdbMovieUrl.IsImdbMovieUrl(), "imdbMovieUrl", InvalidImdbMovieUrlMessage);

            return this.CalculateSecret(imdbMovieUrl.GetImdbMovieId());
        }
        /// <summary>
        /// Get the API url for an IMDb movie URL search.
        /// </summary>
        /// <param name="imdbMovieUrl">The IMDb movie URL.</param>
        /// <param name="imageWidth">The poster image's width to return.</param>
        /// <returns>The API URL to search for the posters for specified IMDb movie ID.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="imdbMovieUrl"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="imdbMovieUrl"/> is not a valid IMDb movie url.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="imageWidth"/> is not within the [30-300] range.</exception>
        public Uri GetApiUrl(Uri imdbMovieUrl, int imageWidth)
        {
            Check.NotNull(imdbMovieUrl, "imdbMovieUrl");
            Check.That(imdbMovieUrl.IsImdbMovieUrl(), "imdbMovieUrl", InvalidImdbMovieUrlMessage);
            Check.InRange(imageWidth, MinimumImageWidth, MaximumImageWidth, "imageWidth");

            return this.GetApiUrl(imdbMovieUrl.GetImdbMovieId(), imageWidth);
        }