Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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());
        }