예제 #1
0
        public async Task AddCommentShouldIncreaseCommentCount()
        {
            // Arrange
            var db   = this.GetDatabase();
            var user = new User {
                Id = "admin", Email = "*****@*****.**"
            };
            var firstArticle = new Article {
                Id = 1, Title = "First article", Content = new String('p', 255)
            };
            var articleComment = new ArticleComment {
                ArticleId = 1, Content = "Asd", Author = user, AuthorId = "admin"
            };

            await db.Articles.AddAsync(firstArticle);

            await db.Comments.AddAsync(articleComment);

            await db.SaveChangesAsync();

            var articleService = new ArticleService(db);

            // Act
            var result = articleService.AddCommentAsync(firstArticle.Id, articleComment.Content, user.Id);

            // Assert
            firstArticle
            .Comments
            .Count
            .Should()
            .Be(2);
        }