Esempio n. 1
0
        public async Task CountOfRepliesShouldBeOne()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context = new ApplicationDbContext(options.Options);
            await context.Users.AddAsync(new ApplicationUser()
            {
                Id = "1"
            });

            var repository = new EfDeletableEntityRepository <ReplyOnPostComment>(context);
            var service    = new ReplyService(repository);
            var model      = new AddReplyInputModel()
            {
                UserId      = "1",
                CommentId   = 1,
                Description = "test reply",
                PostId      = "1",
            };

            var replyId = await service.AddReplyToPostCommentAsync(model);

            var actual = await service.GetReplyByIdAsync <ReplyResponseModel>(replyId);

            Assert.IsType <ReplyResponseModel>(actual);
        }