Example #1
0
 public async Task DeleteTest()
 {
     var fakeRepository = Mock.Of <ILikeRepository>();
     var likeService    = new LikeService(fakeRepository);
     int likeId         = 1;
     await likeService.Delete(likeId);
 }
Example #2
0
        // GET: Product/Delete/5
        public ActionResult Delete(int id)
        {
            Like p;

            p = Cs.GetById(id);
            Cs.Delete(p);
            Cs.Commit();
            return(RedirectToAction("Index"));
        }
        public void TestDeleteCaseComment()
        {
            Like like = new Like()
            {
                ObjectId   = "5d027ea59b358d247cd21a55",
                ObjectType = "comment",
                UserId     = "5d027ea59b358d247cd21a54",
                Date       = DateTime.Now
            };

            mockPostRepository.Setup(x => x.DecreaseCommentCount(It.IsAny <string>())).Returns(true);
            mockLikeRepository.Setup(x => x.Delete(It.IsAny <string>(), It.IsAny <string>())).Returns(true);
            var  testService = new LikeService(mockLikeRepository.Object, mockPostRepository.Object, mockCommentRepository.Object);
            bool checkDelete = testService.Delete(like);

            Assert.IsTrue(checkDelete);
        }
Example #4
0
        public ActionResult Like(int?id)
        {
            int  userId = userDb.GetByName(HttpContext.User.Identity.Name).ID;
            Like like   = new Like();

            if (!likeDb.Any(x => x.AppUserId == userId && x.ArticleID == id))
            {
                like.ArticleID = (int)id;
                like.AppUserId = userId;
                like.LikerName = userDb.GetById(userId).Nick;
                likeDb.Add(like);
            }
            else
            {
                like = likeDb.GetByExpSingle(x => x.ArticleID == id && x.AppUserId == userId);
                likeDb.Delete(like);
            }

            return(Json(likeDb.GetByExp(x => x.ArticleID == id).Count, JsonRequestBehavior.AllowGet));
        }