public async Task CreateLikeShouldReturnTrue() { ApplicationDbContext db = GetDb(); var likesRepository = new EfRepository <Like>(db); var service = new LikesService(likesRepository); await service.LikeAsync(1, "userId"); Assert.Equal(1, db.Likes.Count()); }
public async Task LikeAsyncShouldReturnTrue() { this.likesRepository .Setup(x => x.All()) .Returns(new List <Like>() { new Like { }, }.AsQueryable()); var service = new LikesService(this.likesRepository.Object); var result = await service.LikeAsync(10, "userId"); Assert.True(result); }
public async Task LikeAsyncShouldReturnFalse() { ApplicationDbContext db = GetDb(); this.likesRepository.Setup(x => x.All()) .Returns(new List <Like>() { new Like { CommentId = 10, UserId = "userId", }, }.AsQueryable()); var service = new LikesService(this.likesRepository.Object); var result = await service.LikeAsync(10, "userId"); Assert.False(result); Assert.Equal(0, db.Likes.Count()); }