Ejemplo n.º 1
0
        public async Task GetLastThreeAsync_WithValidData_ShouldReturnLast3Likes()
        {
            // Arrange
            this.InitilaizeMapper();
            var context         = InMemoryDbContext.Initiliaze();
            var likesRepository = new EfRepository <Like>(context);
            var usersRepository = new EfRepository <ApplicationUser>(context);
            var postsRepository = new EfRepository <Post>(context);
            var service         = new LikesService(likesRepository, usersRepository, postsRepository);

            await this.SeedUserAndPost(context);

            await this.SeedLikes(context);

            // Act
            var likes = await service.GetLastThreeAsync(52);

            bool firstLikeRetrieved  = likes.Any(x => x.Id == 26); // Should return false, since we require only the latest 3 likes.
            bool fourthLikeRetrieved = likes.Any(x => x.Id == 29); // Should return true.

            // Assert
            Assert.False(firstLikeRetrieved);
            Assert.True(fourthLikeRetrieved);
        }