예제 #1
0
        public void CannotLikeIt_PostNotFound()
        {
            var controller = new PostLikeController(
                _userRepository.Object,
                _postRepository.Object,
                _postLikeRepository.Object)
            {
                ControllerContext = FakeController.GetContextWithIdentity("test1", "User")
            };

            var result = controller.PostLike(0) as ObjectResult;

            Assert.NotNull(result);
            Assert.IsType <NotFoundObjectResult>(result);
            Assert.Equal(404, result.StatusCode);
            Assert.NotNull(result.Value);
            Assert.Equal("Post not found", result.Value);
        }
예제 #2
0
        public void CanUnLikePost()
        {
            var controller = new PostLikeController(
                _userRepository.Object,
                _postRepository.Object,
                _postLikeRepository.Object)
            {
                ControllerContext = FakeController.GetContextWithIdentity("test1", "User")
            };

            var result = controller.PostLike(1) as ObjectResult;

            Assert.NotNull(result);
            Assert.IsType <OkObjectResult>(result);
            Assert.Equal(200, result.StatusCode);
            Assert.NotNull(result.Value);
            _postLikeRepository.Verify(m =>
                                       m.DeletePostLike(It.IsAny <PostLike>()), Times.Once);

            var post = result.Value as ItemViewData <Post>;

            Assert.NotNull(post);
        }