public void FindBooksForMovieShouldReturnNotFoundView() { MediaController mediaController = new MediaController(); ViewResult result = mediaController.FindBooksForMovie(-1) as ViewResult; Assert.IsNotNull(result); Assert.AreEqual("NotFound", result.ViewName); }
public void FindBooksForMovieWithBookMatchShouldReturnAddBookForMovieView() { Movie movie = TestUtil.generateMovie(); movie.Title = "Jurassic Park"; movie.OriginalTitle = "Jurassic Park"; AddMedia(movie); Book book1 = TestUtil.generateBook(); book1.Title = "Park"; book1.OriginalTitle = "Park"; AddMedia(book1); Book book2 = TestUtil.generateBook(); book2.Title = "Jurassic"; book2.OriginalTitle = "Jurassic"; AddMedia(book2); Book book3 = TestUtil.generateBook(); book3.Title = "Not Related"; book3.OriginalTitle = "Not Related"; AddMedia(book3); MediaController mediaController = new MediaController(); ViewResult result = mediaController.FindBooksForMovie(movie.Id) as ViewResult; Assert.IsNotNull(result); SelectList selectList = result.ViewData["BooksForMovie"] as SelectList; Assert.IsNotNull(selectList); var bookTitles = from item in selectList select item.Text; Assert.AreEqual(2, selectList.Count <SelectListItem>()); Assert.IsTrue(bookTitles.Contains <String>("Park")); Assert.IsTrue(bookTitles.Contains <String>("Jurassic")); }
public void FindBooksForMovieWithoutBookMatchShouldReturnAddBookForMovieView() { Movie movie = TestUtil.generateMovie(); movie.Title = "Jurassic Park"; movie.OriginalTitle = "Jurassic Park"; AddMedia(movie); Book book1 = TestUtil.generateBook(); book1.Title = "F**k"; book1.OriginalTitle = "F**k"; AddMedia(book1); Book book2 = TestUtil.generateBook(); book2.Title = "ASE"; book2.OriginalTitle = "ASE"; AddMedia(book2); Book book3 = TestUtil.generateBook(); book3.Title = "Not Related"; book3.OriginalTitle = "Not Related"; AddMedia(book3); MediaController mediaController = new MediaController(); ViewResult result = mediaController.FindBooksForMovie(movie.Id) as ViewResult; Assert.IsNotNull(result); SelectList selectList = result.ViewData["BooksForMovie"] as SelectList; Assert.IsNotNull(selectList); Assert.AreEqual(0, selectList.Count <SelectListItem>()); }