public void DeletePost() { var UoW = new Mock <UnitOfWork>(); UoW.Object.DeleteDB(); var PostLogic = new PostLogic(UoW.Object); var UserLogic = new UserLogic(UoW.Object); UserLogic.AddUser(new UserDTO("Liza", UserType.Manager, "Bril", "Login", "Password")); UserLogic.Login("Login", "Password"); PostLogic.Add(new PostDTO("Title", "Content", "Tag", "CategoryName")); Assert.AreEqual(PostLogic.GetAll().Count(), 1); Assert.AreEqual(PostLogic.GetAll().ToList()[0].Title, "Title"); Assert.AreEqual(PostLogic.GetAll().ToList()[0].Content, "Content"); Assert.AreEqual(PostLogic.GetAll().ToList()[0].Tags, "Tag"); Assert.AreEqual(PostLogic.GetAll().ToList()[0].CategoryName, "CategoryName"); PostLogic.DeletePost(1); Assert.IsTrue(PostLogic.GetAll().Count() == 0); Assert.IsTrue(UoW.Object.Post.GetAll().Count == 0); }
public IActionResult DeletePost(int id) { postLogic.DeletePost(id); return(RedirectToAction("Index")); }