public void DeleteMovieShouldReturnRedirectToResult()
        {
            Expect.Call(userMediaService.GetMovieById(userMovie.Id)).Return(userMovie);
            Expect.Call(delegate { userMediaService.DeleteMovie(userMovie); });
            mocks.ReplayAll();

            MediathekController mediathekController = new MediathekController(userMediaService);

            RedirectToRouteResult result = mediathekController.DeleteMovie(userMovie.Id, fakeUser) as RedirectToRouteResult;

            Assert.IsNotNull(result);
            object movieId;

            Assert.IsTrue(result.RouteValues.TryGetValue("id", out movieId));
            Assert.AreEqual(userMovie.Movie.Id, (int)movieId);
        }
示例#2
0
        public ActionResult DeleteMovie(int id, IPrincipal user)
        {
            UserMovie userMovie = userMediaService.GetMovieById(id);

            if (userMovie == null)
            {
                return(View("NotFound"));
            }

            Movie movie = userMovie.Movie;

            if (userMovie.User.Username != user.Identity.Name)
            {
                return(View("NotAuthorized"));
            }

            userMediaService.DeleteMovie(userMovie);

            return(RedirectToAction("Movie", "Media", new { id = movie.Id }));
        }