public void PostWithCommentTest() { m.Post post = new m.Post(); post.Key = "PostWithCommentTest"; post.Title = "Post With Comment Test"; post.Content = "This is a post that will have comments."; post.Save(); post.Comments = new List<Model.Comment>(); m.Comment comment = null; for (int pass = 1; pass < 4; pass++) { comment = new m.Comment(); comment.PostID = post.ID; comment.Number = pass; comment.Content = string.Format("this is comment number {0}.", pass); comment.Save(); post.Comments.Add(comment); AssertGoodRead(comment, comment.ID); } Assert.IsTrue(post.Comments.Count == 3, "Wrong number of comments in post"); m.Post readPost = m.Post.Get(post.Key); Assert.IsTrue(readPost.Comments.Count == 3, "Wrong number of comments in readPost"); for (int pass = 1; pass < 4; pass++) { AssertAreEqual(post.Comments[pass - 1], readPost.Comments[pass - 1]); } }
protected void btnSayIt_Click(object sender, EventArgs e) { if (commentContent.Text.Length > 0) { Comment comment = new Comment(); comment.PostID = Convert.ToInt32(commentPostId.Value); comment.Number = Convert.ToInt32(commentNumber.Value); comment.Content = commentContent.Text; comment.Save(); Response.Redirect(string.Format("view.aspx?id={0}", comment.PostID)); } }
public void CreateAndGetTest() { m.Comment comment = new m.Comment(); comment.PostID = 1; comment.Number = 1; comment.Content = "this is a comment for the CreateAndGetTest."; comment.Save(); Assert.IsFalse(comment.ID == -1, "Comment ID should not be -1 after insert."); AssertGoodRead(comment, comment.ID); }
private void SaveComment() { int postId = Convert.ToInt32(Request["comment.post_id"]); if (string.IsNullOrEmpty(Request["comment.content"])) Response.Redirect(string.Format("view.aspx?id={0}", postId)); Comment comment = new Comment(); comment.PostID = postId; comment.Number = Convert.ToInt32(Request["comment.number"]); comment.Content = Request["comment.content"]; comment.Save(); Response.Redirect(string.Format("view.aspx?id={0}", postId)); }
public void UpdateTest() { m.Comment comment = new m.Comment(); comment.PostID = 1; comment.Number = 2; comment.Content = "this is a comment for the UpdateTest."; comment.Save(); Assert.IsFalse(comment.ID == -1, "Comment ID should not be -1 after insert."); AssertGoodRead(comment, comment.ID); comment.Content = "Change the content for the update test document"; comment.Save(); AssertGoodRead(comment, comment.ID); }