public void AddImageLike_DuplicateLike_ThrowEx()
        {
            var init = new InitializeMockContext();
            var mock = init.mock;

            var controller = new LikesService(mock.Object);

            Assert.Throws <NegotiatedContentResultException>(() =>
                                                             controller.AddImageLike(new PostLikes {
                UserId = 2, PostId = 1
            })
                                                             );
        }
        public void AddImageLike_ValidLike_Test()
        {
            var init = new InitializeMockContext();
            var mock = init.mock;

            var controller = new LikesService(mock.Object);

            controller.AddImageLike(new PostLikes {
                UserId = 2, PostId = 3
            });
            init.mockSetPostLikes.Verify(m => m.Add(It.IsAny <PostLikes>()), Times.Once());
            mock.Verify(m => m.SaveChanges(), Times.Once());
        }
        public void AddImageLike_Counting_Test()
        {
            var init    = new InitializeMockContext();
            var mock    = init.mock;
            var imageId = 2;
            var expectedLikeCountInt = mock.Object.Posts.Where(x => x.Id == imageId).First().LikeCount;

            var controller = new LikesService(mock.Object);

            controller.AddImageLike(new PostLikes {
                UserId = 2, PostId = imageId
            });
            mock.Verify(m => m.SaveChanges(), Times.Once());

            Assert.AreEqual(expectedLikeCountInt + 1, mock.Object.Posts.Where(x => x.Id == imageId).First().LikeCount);
        }