public void CreatePostAndComment() { using (var client = CreateDefaultClient()) { var post = new Post { PostType = "post", // "post" or "page" Title = "Test CreatePostAndComment", Content = "Testing CreatePostAndComment", Status = "draft" // "draft" or "publish" }; var postId = Convert.ToInt32(client.NewPost(post)); //test id Assert.IsTrue(postId > 0); var comment = new Comment { PostId = postId.ToString(), Author = "WordPressSharpTestPilot", Content = "Hello world!" }; var commentId = client.NewComment(comment); //test comment id Assert.IsTrue(commentId > 0); //clean up client.DeletePost(Convert.ToInt32(postId)); } }
/// <summary> /// Creates a new comment. /// </summary> /// <param name="comment">The comment.</param> /// <returns>The id of the newly created comment.</returns> public int NewComment(Comment comment) { var comment_put = new Comment_Put(); CopyPropertyValues(comment, comment_put); return WordPressService.NewComment(WordPressSiteConfig.BlogId, WordPressSiteConfig.Username, WordPressSiteConfig.Password, Convert.ToInt32(comment.PostId), comment_put); }