Ejemplo n.º 1
0
        public void FindBooksByTitleShouldReturnNotFoundView()
        {
            MediaController mediaController = new MediaController();
            FormCollection  collection      = new FormCollection();

            collection["SearchBookBar"] = "Book";

            ViewResult result = mediaController.FindBooksByTitle(collection, -1) as ViewResult;

            Assert.IsNotNull(result);

            Assert.AreEqual("NotFound", result.ViewName);
        }
Ejemplo n.º 2
0
        public void FindBooksByTitleWithBookMatchesShouldReturnAddBookForMovieView()
        {
            Movie movie = TestUtil.generateMovie();

            movie.Title         = "Jurassic Park";
            movie.OriginalTitle = "Jurassic Park";
            AddMedia(movie);

            Book book1 = TestUtil.generateBook();

            book1.Title         = "Nothing";
            book1.OriginalTitle = "Nothing";
            AddMedia(book1);
            Book book2 = TestUtil.generateBook();

            book2.Title         = "Your Book";
            book2.OriginalTitle = "Your Book";
            AddMedia(book2);
            Book book3 = TestUtil.generateBook();

            book3.Title         = "My Book";
            book3.OriginalTitle = "My Book";
            AddMedia(book3);

            MediaController mediaController = new MediaController();

            FormCollection collection = new FormCollection();

            collection["SearchBookBar"] = "Book";

            ViewResult result = mediaController.FindBooksByTitle(collection, 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>("Your Book"));
            Assert.IsTrue(bookTitles.Contains <String>("My Book"));
        }