コード例 #1
0
        public async Task GetFeedAsync_WithValidData_ShouldReturnFeedPosts()
        {
            // Arrange
            this.InitilaizeMapper();
            var context        = InMemoryDbContext.Initiliaze();
            var postRepository = new EfDeletableEntityRepository <Post>(context);
            var postService    = new PostsService(postRepository);

            await this.SeedUserFollower(context);

            await postRepository.AddAsync(new Post { Creator = context.Users.FirstOrDefault(), Description = "feedDescription" });

            await postRepository.SaveChangesAsync();

            // Act
            var feedPosts = await postService.GetFeedAsync("followerId", 0, 2);

            var expectedPostDescription = postRepository.All().FirstOrDefault().Description;
            var actualPostDescription   = feedPosts.FirstOrDefault().Description;

            // Assert
            Assert.Equal(expectedPostDescription, actualPostDescription);
        }