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

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

            mockRepo.Setup(x => x.All()).Returns(() => list.AsQueryable());
            mockRepo.Setup(x => x.AddAsync(It.IsAny <Comment>())).Callback((Comment comment) => list.Add(comment));
            var service = new CommentService(mockRepo.Object);

            await service.CreateForTrip(1, "ааа", "1");

            await service.CreateForTrip(1, "ббб", "1");

            Assert.Equal(2, list.Count());
        }