public IEnumerable <CommentListModel> GetAll()
 {
     using (var dbContext = dbContextFactory.CreateDbContext())
     {
         return(dbContext.Comments.Select(e => CommentMapper.EntityToListModel(e)));
     }
 }
Ejemplo n.º 2
0
        public void EntityToListModel_ShouldBeEqual()
        {
            var user = new User()
            {
                FirstName = "John",
                LastName  = "Doe"
            };

            var model = new Comment()
            {
                Author = user,
                Id     = Guid.NewGuid(),
                Text   = "This is a comment!"
            };

            var returned = CommentMapper.EntityToListModel(model);

            Assert.Equal(model.Author.FirstName, returned.Author.FirstName);
            Assert.Equal(model.Author.LastName, returned.Author.LastName);
            Assert.Equal(model.Id, returned.Id);
            Assert.Equal(model.Timestamp, returned.Timestamp);

            Assert.IsType <CommentListModel>(returned);
        }