Exemplo n.º 1
0
        public void GetImdbMovieIdUsingValidImdbMovieUrlReturnsImdbMovieIdFromUrl(string validImdbMovieUrl, int expectedImdbMovieId)
        {
            // Arrange
            var url = new Uri(validImdbMovieUrl);

            // Act
            var imdbMovieId = url.GetImdbMovieId();

            // Assert
            Assert.Equal(expectedImdbMovieId, imdbMovieId);
        }
Exemplo n.º 2
0
        public void GetImdbMovieIdUsingNonMovieUrlThrowsArgumentException(string invalidImdbMovieUrl)
        {
            // Arrange
            var url = new Uri(invalidImdbMovieUrl);

            // Act

            // Assert
            Assert.Throws<ArgumentException>(() => url.GetImdbMovieId());
        }
        /// <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);
        }