public void DeleteTest002() { var editViewModel = new EditViewModel() { Id = "16777216", Title = string.Empty, Content = string.Empty }; var controller = new EditController(mockService.Object); controller.TempData = tempData; controller.ControllerContext.HttpContext = new DefaultHttpContext(); controller.ControllerContext.HttpContext.Request.Headers["test"] = "test"; var result = controller.Delete(editViewModel); var model = Assert.IsType <ViewResult>(result); Assert.Equal("Views/Shared/Error.cshtml", model.ViewName); controller.Dispose(); }
public void DeleteTest003() { var editViewModel = new EditViewModel() { Id = "2", Title = "たいとる更新(テスト)", Content = "ほんぶん更新(てすと)" }; mockService.Setup(x => x.DeleteDiary(2)).Returns(false); var controller = new EditController(mockService.Object); controller.TempData = tempData; var result = controller.Delete(editViewModel); var model = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Index", model.ActionName); Assert.Equal("Menu", model.ControllerName); Assert.Equal("すでに削除されています。", controller.TempData["notification"]); controller.Dispose(); }