public void DeleteTvShowShouldReturnRedirectToResult() { Expect.Call(userMediaService.GetTvShowById(userTV_Show.Id)).Return(userTV_Show); Expect.Call(delegate { userMediaService.DeleteTvShow(userTV_Show); }); mocks.ReplayAll(); MediathekController mediathekController = new MediathekController(userMediaService); RedirectToRouteResult result = mediathekController.DeleteTvShow(userTV_Show.Id, fakeUser) as RedirectToRouteResult; Assert.IsNotNull(result); object tv_ShowId; Assert.IsTrue(result.RouteValues.TryGetValue("id", out tv_ShowId)); Assert.AreEqual(userTV_Show.Season.TV_Show.Id, (int)tv_ShowId); }
public ActionResult DeleteTvShow(int id, IPrincipal user) { UserTV_Show userTvShow = userMediaService.GetTvShowById(id); if (userTvShow == null) { return(View("NotFound")); } TV_Show tvShow = userTvShow.Season.TV_Show; if (userTvShow.User.Username != user.Identity.Name) { return(View("NotAuthorized")); } userMediaService.DeleteTvShow(userTvShow); return(RedirectToAction("TVShow", "Media", new { id = tvShow.Id })); }