示例#1
0
        public async Task DeleteCommentShouldWorkCorrectly()
        {
            var comments = new List <Comment>();

            var mockCommentRepo = new Mock <IDeletableEntityRepository <Comment> >();

            mockCommentRepo.Setup(x => x.All()).Returns(comments.AsQueryable());
            mockCommentRepo.Setup(x => x.AddAsync(It.IsAny <Comment>())).Callback((Comment comm) => comments.Add(comm));

            var service = new AdminsService(null, mockCommentRepo.Object, null, null, null);

            var newComment = new Comment
            {
                Id        = "123",
                Content   = "You are sick",
                PhotoId   = "1",
                IsDeleted = false,
            };

            comments.Add(newComment);
            await service.DeleteComment("123");

            Assert.Equal(true, newComment.IsDeleted);
        }