public void ShouldFailAddAndRemoveArticleCommentDifferentUser() { PopulateRepository(); #region Add AddArticleCommentCommand addCommand = new AddArticleCommentCommand { ArticleId = new Guid("4aeabf09-da78-4fcd-bb73-667605871a5e"), Body = "hELLO IN COmMeNtIng hERe!!" }; applicationService.AddComment(addCommand); Article article = applicationService.GetById(new Guid("4aeabf09-da78-4fcd-bb73-667605871a5e")); Assert.AreEqual(1, article.Comments.Count()); #endregion //REFRESH USER ID identityResolver.RefreshId(); //NOW IT'S LIKE A DIFFERENT USER #region Remove RemoveArticleCommentCommand removeCommand = new RemoveArticleCommentCommand { ArticleId = new Guid("4aeabf09-da78-4fcd-bb73-667605871a5e"), CommentId = article.Comments.First().Id }; applicationService.RemoveComment(removeCommand); Assert.AreEqual("Erro na remoção", domainNotificationHandler.GetNotifications().First().Title); #endregion }
public void ShouldAddAndRemoveArticleComment() { PopulateRepository(); #region Add AddArticleCommentCommand addCommand = new AddArticleCommentCommand { ArticleId = new Guid("4aeabf09-da78-4fcd-bb73-667605871a5e"), Body = "hELLO Im COmMeNtIng hERe!!" }; applicationService.AddComment(addCommand); Article article = applicationService.GetById(new Guid("4aeabf09-da78-4fcd-bb73-667605871a5e")); Assert.AreEqual(1, article.Comments.Count()); #endregion #region Remove RemoveArticleCommentCommand removeCommand = new RemoveArticleCommentCommand { ArticleId = new Guid("4aeabf09-da78-4fcd-bb73-667605871a5e"), CommentId = article.Comments.First().Id }; applicationService.RemoveComment(removeCommand); Assert.AreEqual(1, article.Comments.Count()); #endregion }
public IActionResult AddComment(Guid id, [FromBody] AddArticleCommentCommand command) { command.ArticleId = id; _articleAppService.AddComment(command); return(CreateResponse()); }
public void ShouldAddArticleComment() { PopulateRepository(); AddArticleCommentCommand command = new AddArticleCommentCommand { ArticleId = new Guid("4aeabf09-da78-4fcd-bb73-667605871a5e"), Body = "hELLO IN COmMeNtIng hERe!!" }; applicationService.AddComment(command); Article article = applicationService.GetById(new Guid("4aeabf09-da78-4fcd-bb73-667605871a5e")); Assert.AreEqual(1, article.Comments.Count()); }
public void AddComment(AddArticleCommentCommand command) { command.Validate(); if (AddNotifications(command)) { return; } Article article = _articleRepository.GetById(command.ArticleId); LedgerIdentityUser user = _identityResolver.GetUser(); if (NotifyNullArticle(article)) { return; } Comment comment = new Comment(article.Id, user.Id, command.Body); article.AddComment(comment); _articleRepository.Update(article); Commit(); }