Esempio n. 1
0
        public void RemoveCommentLike_ValidLikeId_Test()
        {
            var init = new InitializeMockContext();
            var mock = init.mock;

            var controller = new LikesService(mock.Object);

            controller.RemoveCommentLike(2, 1);
            mock.Verify(m => m.SaveChanges(), Times.Once());
        }
Esempio n. 2
0
        public void RemoveCommentLike_Counting_Test()
        {
            var init                 = new InitializeMockContext();
            var mock                 = init.mock;
            var commentId            = 1;
            var expectedLikeCountInt = mock.Object.PostComments.Where(x => x.Id == commentId).First().LikeCount;

            var controller = new LikesService(mock.Object);

            controller.RemoveCommentLike(2, 1);
            mock.Verify(m => m.SaveChanges(), Times.Once());

            Assert.AreEqual(expectedLikeCountInt - 1, mock.Object.PostComments.Where(x => x.Id == commentId).First().LikeCount);
        }