public void Add_ModelValid_ShouldReturnNotNullResultAndCallMethod() { var result = _commentController.Add(GetAddCommentViewModel, new Validators.AddCommentValidator()); Assert.IsNotNull(result); _commentService.Verify(x => x.Add(It.Is <Comment>( y => y.AuthorName == GetAddCommentViewModel.AuthorName && y.Text == GetAddCommentViewModel.Text)), Times.Once); }
public void AddCommentPost_ReturnsIActionResultWhenRequest() { // Act var result = _commentController.Add(new CommentViewModel(), "csgo") as IActionResult; // Assert Assert.NotNull(result); }
public ActionResult CommentAdd(Comment comment) { comments.Add(comment); TempData["alert"] = "<script>alert('Yorumunuz Kaydedilmiştir')</script>"; return(RedirectToAction("News_Details", new { newsId = comment.HaberId })); }