コード例 #1
0
        public void EditCommentPost_CommentTextRequired()
        {
            int            postId = -2;
            int            postCommentOrLikeId = -1;
            PostController controller          = new PostController(_postsRepoMock.Object, _loginUser);
            JsonResult     result = controller.EditCommentPost("", postCommentOrLikeId, postId);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Data);
            Assert.IsTrue(result.Data is JsonResponseVM);
            Assert.IsTrue((result.Data as JsonResponseVM).Result == "ERROR");
        }
コード例 #2
0
        public void EditCommentPost()
        {
            int    postId              = 2;
            string comment             = "Hello";
            int    postCommentOrLikeId = 1;

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

            JsonResult result = controller.EditCommentPost(comment, postCommentOrLikeId, 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);
        }
コード例 #3
0
        public void EditCommentPost_DatabaseSaveFailed()
        {
            int    postId = 2;
            int    postCommentOrLikeId = 1;
            string comment             = "Hello";

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

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

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