Exemple #1
0
        public async Task IsPostLikedByUserAsync_WithInvalidUserId_ShouldReturnFalse()
        {
            // Arrange
            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
            bool isLiked = await service.IsPostLikedByUserAsync("InvalidUserId", 52); // UserId is non-existent

            // Assert
            Assert.False(isLiked);
        }