Example #1
0
        public async Task DeleteAsyncWorkCorrectly()
        {
            var comment = new Comment()
            {
                Text           = "test",
                UserId         = "a",
                AnnouncementId = "1",
            };
            var obj = await this.dbContext.Comments.AddAsync(comment);

            var commentId = obj.Entity.Id;

            await this.dbContext.SaveChangesAsync();

            var service = new CommentsService(this.commentRepository);
            var result  = service.GetCommentByUserId <CommentInputModel>("a");

            Assert.Equal(1, result?.Count());
            await service.DeleteAsync(commentId);

            result = service.GetCommentByUserId <CommentInputModel>("a");
            Assert.Equal(0, result?.Count());
        }