Example #1
0
        public void CommentPost_CommentTextRequired()
        {
            int            postId     = 2;
            PostController controller = new PostController(_postsRepoMock.Object, _loginUser);
            JsonResult     result     = controller.CommentPost("", postId);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Data);
            Assert.IsTrue(result.Data is JsonResponseVM);
            Assert.IsTrue((result.Data as JsonResponseVM).Result == "ERROR");
        }
Example #2
0
        public void CommentPost()
        {
            int    postId  = 2;
            string comment = "Hello";

            _postsRepoMock.Setup(m => m.CreateCommentOrLike(It.IsAny <PostCommentOrLike>())).Returns(true);
            PostController controller = new PostController(_postsRepoMock.Object, _loginUser);

            JsonResult result = controller.CommentPost(comment, postId);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Data);
            Assert.IsTrue(result.Data is JsonResponseVM);
            Assert.IsTrue((result.Data as JsonResponseVM).Result == "OK");
            Assert.IsTrue((result.Data as JsonResponseVM).PostId == postId);
        }
Example #3
0
        public void CommentPost_DatabaseSaveFailed()
        {
            int    postId  = 2;
            string comment = "Hello";

            PostCommentOrLike postComment = new PostCommentOrLike {
                IdPost = postId, Comment = comment, IdUser = _loginUser.UserId
            };

            _postsRepoMock.Setup(m => m.CreateCommentOrLike(postComment)).Returns(false);
            PostController controller = new PostController(_postsRepoMock.Object, _loginUser);
            JsonResult     result     = controller.CommentPost(comment, postId);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Data);
            Assert.IsTrue(result.Data is JsonResponseVM);
            Assert.IsTrue((result.Data as JsonResponseVM).Result == "ERROR");
        }