Exemplo n.º 1
0
        public async Task GetAsync_WithValidData_ShouldReturnPost()
        {
            // Arrange
            var context        = InMemoryDbContext.Initiliaze();
            var postRepository = new EfDeletableEntityRepository <Post>(context);
            var postService    = new PostsService(postRepository);
            await postRepository.AddAsync(new Post { Id = 52, Description = "Post Description" });

            await postRepository.SaveChangesAsync();

            // Act
            var post = await postService.GetAsync(52);

            var expectedDescription = postRepository.All().FirstOrDefault().Description;
            var actualDescription   = post.Description;

            // Assert
            Assert.Equal(expectedDescription, actualDescription);
        }
 public async Task <IActionResult> Index()
 {
     return(View(await _postsService.GetAsync()));
 }