public void DenyPost() { int postId = 2; _postsRepoMock.Setup(m => m.DeletePost(postId, _loginUser)).Returns(true); PostController controller = new PostController(_postsRepoMock.Object, _loginUser); JsonResult result = controller.DenyPost(postId); Assert.IsNotNull(result); Assert.IsNotNull(result.Data); Assert.IsTrue(result.Data is JsonResponseVM); Assert.IsTrue((result.Data as JsonResponseVM).Result == "OK"); }
public void DenyPost_DatabaseSaveFailed() { int postId = 2; _postsRepoMock.Setup(m => m.DeletePost(postId, _loginUser)).Returns(false); PostController controller = new PostController(_postsRepoMock.Object, _loginUser); JsonResult result = controller.DenyPost(postId); Assert.IsNotNull(result); Assert.IsNotNull(result.Data); Assert.IsTrue(result.Data is JsonResponseVM); Assert.IsTrue((result.Data as JsonResponseVM).Result == "ERROR"); Assert.IsTrue(!String.IsNullOrEmpty((result.Data as JsonResponseVM).Msg)); }