コード例 #1
0
        public void DeleteBookFromMovieConnShouldDeleteConnAndReturnMovieView()
        {
            Movie movie = TestUtil.generateMovie();

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

            Book book = TestUtil.generateBook();

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

            MediaController mediaController = new MediaController();

            RedirectToRouteResult result = mediaController.DeleteBookFromMovieConn(movie.Id) as RedirectToRouteResult;

            Assert.IsNull(movie.Book);
            Assert.IsNull(book.Movie);
            Assert.IsNotNull(result);
            object movieId;

            Assert.IsTrue(result.RouteValues.TryGetValue("id", out movieId));
            Assert.AreEqual(movie.Id, (int)movieId);
        }
コード例 #2
0
        public void DeleteBookFromMovieConnWithNoMovieShouldReturnNotFoundView()
        {
            MediaController mediaController = new MediaController();

            ViewResult result = mediaController.DeleteBookFromMovieConn(-1) as ViewResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("NotFound", result.ViewName);
        }