public LoginData GetAdvancedPostWithoutSessionkey()
        {
            // Arrange
            LoginData loginData = CreatePost();

            PostController        postController        = new PostController();
            CommentController     commentController     = new CommentController();
            VoteCommentController voteCommentController = new VoteCommentController();

            commentController.Post(loginData.sessionkey, Mocks.comment1);
            commentController.Post(loginData.sessionkey, Mocks.comment2);
            commentController.Post(loginData.sessionkey, Mocks.subComment);
            voteCommentController.Post(loginData.sessionkey, Mocks.voteOnCommentPositive);
            voteCommentController.Post(loginData.sessionkey, Mocks.voteOnCommentNegative2);
            postController.Get(loginData.sessionkey, 1);

            // Act
            var actionResult = postController.Get(null, 1).Result;
            var actual       = (actionResult as OkObjectResult).Value as ComplexAnswer;
            var data         = actual.data as Post;

            // Assert
            Assert.IsType <OkObjectResult>(actionResult);
            Assert.Equal(TestSetup.NormalAnswer.code, actual.code);
            Assert.Equal(TestSetup.NormalAnswer.message, actual.message);
            Assert.Equal(TestSetup.NormalAnswer.success, actual.success);

            Assert.Equal(Mocks.post.title, data.title);
            Assert.Equal(Mocks.post.description, data.description);
            Assert.Equal(Mocks.post.path, data.path);

            Assert.Equal(Mocks.comment1.text, data.comment[0].text);
            Assert.Equal(1, data.comment[0].upvotes);
            Assert.Equal(0, data.comment[0].downvotes);
            Assert.Equal(0, data.comment[0].yourvote);

            Assert.Equal(Mocks.comment2.text, data.comment[1].text);
            Assert.Equal(0, data.comment[1].upvotes);
            Assert.Equal(1, data.comment[1].downvotes);
            Assert.Equal(0, data.comment[1].yourvote);

            Assert.Equal(Mocks.subComment.text, data.comment[0].comment[0].text);
            Assert.Equal(0, data.comment[0].comment[0].downvotes);
            Assert.Equal(0, data.comment[0].comment[0].upvotes);
            Assert.Equal(0, data.comment[0].comment[0].yourvote);

            return(loginData);
        }
示例#2
0
        public void UpdateVoteComment()
        {
            // Arrange
            LoginData loginData = CreateComment();

            VoteCommentController voteCommentController = new VoteCommentController();

            voteCommentController.Post(loginData.sessionkey, Mocks.voteOnCommentNegative);

            // Act
            var actionResult = voteCommentController.Post(loginData.sessionkey, Mocks.voteOnCommentPositive).Result;
            var actual       = ((actionResult as OkObjectResult).Value as ComplexAnswer);
            var data         = actual.data as Comment;

            // Assert
            Assert.IsType <OkObjectResult>(actionResult);
            Assert.Equal(TestSetup.NormalAnswer.code, actual.code);
            Assert.Equal(TestSetup.NormalAnswer.message, actual.message);
            Assert.Equal(TestSetup.NormalAnswer.success, actual.success);
            Assert.Equal(1, data.yourvote);
        }