public void can_not_reply_to_post_when_comments_are_disabled() { using (UoW.Create()) { new Post() .DisableComments() .ReplyTo(new UserInfo("Roger", "", "", ""), "This should not work"); } }
protected void Page_Load(object sender, EventArgs e) { using (UoW.Create()) { IList <FlattenedCategoryProjection> categories = CategoryProjections.GetAll(); CategoryRepeater.DataSource = categories; CategoryRepeater.DataBind(); } }
public void can_publish_post() { using (UoW.Create()) { var post = new Post(); Assert.IsNull(post.PublishDate); //unpublished post.Publish(); Assert.IsNotNull(post.PublishDate); //published } }
protected void Page_Load(object sender, EventArgs e) { string userId = Request.UserHostAddress; using (UoW.Create()) { IList <PostProjection> posts = GetPosts(userId); PostRepeater.DataSource = posts; PostRepeater.DataBind(); } }
public void user_can_see_other_users_approved_comments() { using (UoW.Create()) { NewPost() .ReplyTo(new UserInfo("Roger", "", "", "myid"), "this comment should be listed") .Approve(); PostProjectionWithComments presentedPost = PostProjections.GetById(0, "otherid"); //the comment is approved, we should get one Assert.AreEqual(1, presentedPost.Comments.Count()); } }
public void can_reply_to_post_when_comments_are_enabled() { using (UoW.Create()) { bool eventWasFired = false; DomainEvents.When <UserCommentedOnPost>().Then(e => eventWasFired = true); new Post() .EnableComments() .ReplyTo(new UserInfo("Roger", "", "", ""), "This should work"); UoW.Commit(); Assert.IsTrue(eventWasFired); } }
public void can_approve_comments() { using (UoW.Create()) { bool eventWasFired = false; DomainEvents.When <CommentGotApproved>().Then(e => eventWasFired = true); Comment comment = NewPost() .ReplyTo(new UserInfo("Roger", "", "", "myid"), "this should fire an event") .Approve(); Assert.IsTrue(comment.Approved); Assert.IsTrue(eventWasFired); } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); string userId = Request.UserHostAddress; using (UoW.Create()) { PostProjectionWithComments post = PostProjections.GetById(PostId, userId); PublshDateLabel.Text = post.PublishDateString; SubjectLabel.Text = post.Subject; BodyLabel.Text = post.Body; CategoryLabel.Text = post.CategoryString; CommentRepeater.DataSource = post.Comments; CommentRepeater.DataBind(); } }
protected void ReplyButton_Click(object sender, EventArgs e) { string userId = Request.UserHostAddress; using (UoW.Create()) { Post post = Posts.GetById(PostId); string name = NameTextbox.Text; string email = EmailTextbox.Text; string website = WebsiteTextbox.Text; string body = CommentTextbox.Text; post.ReplyTo(new UserInfo(name, website, email, userId), body); UoW.Commit(); NameTextbox.Text = ""; EmailTextbox.Text = ""; WebsiteTextbox.Text = ""; CommentTextbox.Text = ""; } }
public void can_find_post_by_id() { var p1 = new Post(); SetProperty(p1, "Id", 1); var p2 = new Post(); SetProperty(p2, "Id", 2); var p3 = new Post(); SetProperty(p3, "Id", 3); testdata.Add(p1); testdata.Add(p2); testdata.Add(p3); using (UoW.Create()) { Post post = Posts.GetById(2); //find post #2 Assert.AreEqual(2, post.Id); //assert that we got the correct post back } }