コード例 #1
0
        public void SearchUsingImdbMovieUrlWithInvalidImdbMovieUrlThrowsArgumentException(string invalidImdbMovieUrl)
        {
            // Arrange
            var moviePosterDbService = new MoviePosterDbService(ApiKey, ApiSecret);

            // Act

            // Assert
            Assert.Throws<ArgumentException>(() => moviePosterDbService.Search(new Uri(invalidImdbMovieUrl)));
        }
コード例 #2
0
        public void SearchUsingImdbMovieIdAndImageWidthForMovieWithoutPosterReturnsNullForProperties()
        {
            // Arrange
            var moviePosterDbService = new MoviePosterDbService(ApiKey, ApiSecret);

            // Act
            var moviePosterDbResult = moviePosterDbService.Search(ImdbMovieIdWithoutPoster, ImageWidth);

            // Assert
            Assert.Null(moviePosterDbResult.Title);
            Assert.Null(moviePosterDbResult.Year);
            Assert.Null(moviePosterDbResult.ImdbMovieId);
            Assert.Null(moviePosterDbResult.Page);
            Assert.Null(moviePosterDbResult.Posters);
        }
コード例 #3
0
        public void SearchUsingImdbMovieIdAndImageWidthForMovieWithPosterWillReturnCorrectMoviePosterDbResult()
        {
            // Arrange
            var moviePosterDbService = new MoviePosterDbService(ApiKey, ApiSecret);

            // Act
            var moviePosterDbResult = moviePosterDbService.Search(ImdbMovieIdWithPoster, ImageWidth);

            // Assert
            Assert.Equal("Inception", moviePosterDbResult.Title);
            Assert.Equal("2010", moviePosterDbResult.Year);
            Assert.Equal("1375666", moviePosterDbResult.ImdbMovieId);
            Assert.Equal(@"http://api.movieposterdb.com/cache/normal/66/1375666/1375666_100.jpg", moviePosterDbResult.Posters[0].Url);
            Assert.Equal(1, moviePosterDbResult.Posters.Count());
        }
コード例 #4
0
        public void SearchUsingImdbMovieUrlForMovieWithoutPosterReturnsNullForProperties(string imdbMovieUrl)
        {
            // Arrange
            var moviePosterDbService = new MoviePosterDbService(ApiKey, ApiSecret);

            // Act
            var moviePosterDbResult = moviePosterDbService.Search(new Uri(imdbMovieUrl));

            // Assert
            Assert.Null(moviePosterDbResult.Title);
            Assert.Null(moviePosterDbResult.Year);
            Assert.Null(moviePosterDbResult.ImdbMovieId);
            Assert.Null(moviePosterDbResult.Page);
            Assert.Null(moviePosterDbResult.Posters);
        }
コード例 #5
0
        public void CalculateSecretUsingImdbMovieIdOutOfRangeThrowsArgumentOutOfRangeException(int invalidImdbMovieId)
        {
            // Arrange
            var moviePosterDbService = new MoviePosterDbService(ApiKey, ApiSecret);

            // Act

            // Assert
            Assert.Throws<ArgumentOutOfRangeException>(() => moviePosterDbService.CalculateSecret(invalidImdbMovieId));
        }
コード例 #6
0
        public void CalculateSecretUsingImdbMovieUrlReturnsCorrectSecret(string imdbMovieUrl)
        {
            // Arrange
            var moviePosterDbService = new MoviePosterDbService(ApiKey, ApiSecret);

            // Act
            var calculateSecret = moviePosterDbService.CalculateSecret(new Uri(imdbMovieUrl));

            // Assert
            Assert.Equal("8435ce4c53ff", calculateSecret);
        }
コード例 #7
0
        public void CalculateSecretUsingNullImdbMovieUrlThrowsArgumentNullException()
        {
            // Arrange
            Uri nullImdbMovieUrl = null;
            var moviePosterDbService = new MoviePosterDbService(ApiKey, ApiSecret);

            // Act

            // Assert
            Assert.Throws<ArgumentNullException>(() => moviePosterDbService.CalculateSecret(nullImdbMovieUrl));
        }
コード例 #8
0
        public void GetApiUrlUsingImdbMovieIdOutOfRangeThrowsArgumentOutOfRangeException(int invalidImdbMovieId)
        {
            // Arrange
            var moviePosterDbService = new MoviePosterDbService(ApiKey, ApiSecret);

            // Act

            // Assert
            Assert.Throws<ArgumentOutOfRangeException>(() => moviePosterDbService.GetApiUrl(invalidImdbMovieId, ImageWidth));
        }
コード例 #9
0
        public void GetApiUrlUsingInvalidImdbMovieUrlThrowsArgumentException(string invalidImdbMovieUrl)
        {
            // Arrange
            var moviePosterDbService = new MoviePosterDbService(ApiKey, ApiSecret);

            // Act

            // Assert
            Assert.Throws<ArgumentException>(() => moviePosterDbService.GetApiUrl(new Uri(invalidImdbMovieUrl), ImageWidth));
        }
コード例 #10
0
        public void GetApiUrlUsingNullImdbMovieUrlThrowsArgumentNullException()
        {
            // Arrange
            Uri nullImdbMovieUrl = null;
            var moviePosterDbService = new MoviePosterDbService(ApiKey, ApiSecret);

            // Act

            // Assert
            Assert.Throws<ArgumentNullException>(() => moviePosterDbService.GetApiUrl(nullImdbMovieUrl, ImageWidth));
        }
コード例 #11
0
        public void GetApiUrlUsingImdbMovieUrlReturnsCorrectApiUrl(string imdbMovieUrl)
        {
            // Arrange
            var moviePosterDbService = new MoviePosterDbService(ApiKey, ApiSecret);

            // Act
            var apiUrl = moviePosterDbService.GetApiUrl(new Uri(imdbMovieUrl), ImageWidth);

            // Assert
            Assert.Equal("http://api.movieposterdb.com/json?imdb_code=2304771&api_key=test-api-key&secret=8435ce4c53ff&width=300", apiUrl.ToString());
        }
コード例 #12
0
        public void SearchUsingImdbMovieUrlAndImageWidthOutOfRangeThrowsArgumentOutOfRangeException(int invalidImageWidth)
        {
            // Arrange
            var moviePosterDbService = new MoviePosterDbService(ApiKey, ApiSecret);

            // Act

            // Assert
            Assert.Throws<ArgumentOutOfRangeException>(() => moviePosterDbService.Search(new Uri(ImdbMovieUrl), invalidImageWidth));
        }