Ejemplo n.º 1
0
 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");
     }
 }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (UoW.Create())
     {
         IList <FlattenedCategoryProjection> categories = CategoryProjections.GetAll();
         CategoryRepeater.DataSource = categories;
         CategoryRepeater.DataBind();
     }
 }
Ejemplo n.º 3
0
 public void can_publish_post()
 {
     using (UoW.Create())
     {
         var post = new Post();
         Assert.IsNull(post.PublishDate);    //unpublished
         post.Publish();
         Assert.IsNotNull(post.PublishDate); //published
     }
 }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
        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());
            }
        }
Ejemplo n.º 6
0
        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 = "";
            }
        }
Ejemplo n.º 10
0
        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
            }
        }