public async Task CheckSettingOfArticleCommentProperties() { this.SeedDatabase(); var model = new CreateArticleCommentInputModel { ArticleId = this.firstArticle.Id, Content = "What's your opinion for the article?", }; await this.articleCommentsService.CreateAsync(model.ArticleId, this.firstCookingHubUser.Id, model.Content); var articleComment = await this.articleCommentsRepository.All().FirstOrDefaultAsync(); Assert.Equal(model.ArticleId, articleComment.ArticleId); Assert.Equal("What's your opinion for the article?", articleComment.Content); }
public async Task CheckIfCreateAsyncWorksCorrectly() { this.SeedDatabase(); var articleComment = new CreateArticleCommentInputModel { ArticleId = this.firstArticle.Id, Content = "I like this article.", }; await this.articleCommentsService.CreateAsync( articleComment.ArticleId, this.firstCookingHubUser.Id, articleComment.Content); var count = await this.articleCommentsRepository.All().CountAsync(); Assert.Equal(1, count); }
public async Task CheckIfAddingArticleCommentThrowsArgumentException() { this.SeedDatabase(); await this.SeedArticleComments(); var articleComment = new CreateArticleCommentInputModel { ArticleId = this.firstArticle.Id, Content = this.firstArticleComment.Content, }; var exception = await Assert .ThrowsAsync <ArgumentException>(async() => await this.articleCommentsService .CreateAsync(articleComment.ArticleId, this.firstCookingHubUser.Id, articleComment.Content)); Assert.Equal( string.Format( ExceptionMessages.ArticleCommentAlreadyExists, articleComment.ArticleId, articleComment.Content), exception.Message); }