示例#1
0
        public void CanGetById()
        {
            var commentRepository = new Mock<IFlyCommentRepository>();

            commentRepository.Setup(s => s.GetAll())
                             .Returns(new List<FlyComment>
                                 {
                                     new FlyComment {Id = 1, Author = new FlyOwner {Id = 1}, Fly = new Fly {Id = 1}, Comment = "Comment" },
                                     new FlyComment {Id = 2, Author = new FlyOwner {Id = 2}, Fly = new Fly {Id = 1}, Comment = "Comment 2" }
                                 }.AsQueryable());

            var commentService = new FlyCommentService(commentRepository.Object);

            var comment = commentService.GetById(1);

            Assert.AreEqual(comment.Id, 1);
            commentRepository.Verify(v => v.GetAll(), Times.Once());
        }