public async Task EditPostViewShouldWorkCorrectly() { var posts = new List <Post>(); var mockPostRepo = new Mock <IDeletableEntityRepository <Post> >(); mockPostRepo.Setup(x => x.All()).Returns(posts.AsQueryable()); mockPostRepo.Setup(x => x.AddAsync(It.IsAny <Post>())).Callback((Post post) => posts.Add(post)); var service = new PostsService(null, mockPostRepo.Object); var post = new Post { Id = "1", UserId = "1", Content = "Test", }; posts.Add(post); var ps = service.EditView <PostsViewModel>("1"); Assert.Equal(post.Content, ps.Content); }