public ViewResult Index(IndexViewModel model) { if (ModelState.IsValid) { var cinematerialService = new CinematerialService(model.ApiKey, model.ApiSecret); if (model.ImdbMovieId.HasValue) { model.CinematerialResult = cinematerialService.Search(model.ImdbMovieId.Value, model.ImageWidth); } else { model.CinematerialResult = cinematerialService.Search(new Uri(model.ImdbMovieUrl), model.ImageWidth); } } return(View(model)); }
public void SearchUsingImdbMovieUrlAndImageWidthWithInvalidImdbMovieUrlThrowsArgumentException(string invalidImdbMovieUrl) { // Arrange var cinematerialService = new CinematerialService(ApiKey, ApiSecret); // Act // Assert Assert.Throws <ArgumentException>(() => cinematerialService.Search(new Uri(invalidImdbMovieUrl), ImageWidth)); }
public void SearchUsingImdbMovieIdAndImageWidthWithImdbMovieIdOutOfRangeThrowsArgumentOutOfRangeException(int invalidImdbMovieId) { // Arrange var cinematerialService = new CinematerialService(ApiKey, ApiSecret); // Act // Assert Assert.Throws <ArgumentOutOfRangeException>(() => cinematerialService.Search(invalidImdbMovieId, ImageWidth)); }
public void SearchUsingImdbMovieUrlWithIncompleteImdbMovieUrlThrowsArgumentException(string incompleteImdbMovieUrl) { // Arrange var cinematerialService = new CinematerialService(ApiKey, ApiSecret); // Act // Assert Assert.Throws <ArgumentException>(() => cinematerialService.Search(new Uri(incompleteImdbMovieUrl))); }
public void SearchUsingImdbMovieUrlForMovieWithPosterWillReturnCorrectcinematerialResult(string imdbMovieUrl) { // Arrange var cinematerialService = new CinematerialService(ApiKey, ApiSecret); // Act var cinematerialResult = cinematerialService.Search(new Uri(imdbMovieUrl)); // Assert Assert.Equal("Inception", cinematerialResult.Title); Assert.Equal("2010", cinematerialResult.Year); Assert.Equal("1375666", cinematerialResult.ImdbMovieId); Assert.Equal(@"https://api.cinematerial.com/cache/normal/66/tt1375666/447241_300.jpg", cinematerialResult.Posters[0].Url); Assert.Equal(1, cinematerialResult.Posters.Length); }
public void SearchUsingImdbMovieIdAndImageWidthForMovieWithoutPosterReturnsNullForProperties() { // Arrange var cinematerialService = new CinematerialService(ApiKey, ApiSecret); // Act var cinematerialResult = cinematerialService.Search(ImdbMovieIdWithoutPoster, ImageWidth); // Assert Assert.Null(cinematerialResult.Title); Assert.Null(cinematerialResult.Year); Assert.Null(cinematerialResult.ImdbMovieId); Assert.Null(cinematerialResult.Page); Assert.Null(cinematerialResult.Posters); }
public void SearchUsingImdbMovieUrlForMovieWithoutPosterReturnsNullForProperties(string imdbMovieUrl) { // Arrange var cinematerialService = new CinematerialService(ApiKey, ApiSecret); // Act var cinematerialResult = cinematerialService.Search(new Uri(imdbMovieUrl)); // Assert Assert.Null(cinematerialResult.Title); Assert.Null(cinematerialResult.Year); Assert.Null(cinematerialResult.ImdbMovieId); Assert.Null(cinematerialResult.Page); Assert.Null(cinematerialResult.Posters); }