Ejemplo n.º 1
0
        public void MultipleCommentsSameName()
        {
            using (var db = new Db
            {
                new DbTemplate(Settings.CommentTemplateID)
                {
                    new DbField("Name"),
                    new DbField("Email"),
                    new DbField("Comment"),
                    new DbField("Website"),
                    new DbField("IP Address"),
                },
                new DbItem("blog")
                {
                    new DbItem("entry")
                }
            })
            {
                var blog  = db.GetItem("/sitecore/content/blog");
                var entry = db.GetItem("/sitecore/content/blog/entry");

                var blogManager = Mock.Of <IBlogManager>(x =>
                                                         x.GetCurrentBlog(entry) == new BlogHomeItem(blog)
                                                         );
                var processor = new TestableCreateCommentItemProcessor(blogManager);

                var args = new CreateCommentArgs
                {
                    Database = entry.Database,
                    Comment  = new Comment
                    {
                        AuthorName  = "commenter",
                        AuthorEmail = "*****@*****.**",
                        Text        = "the comment"
                    },
                    EntryID  = entry.ID,
                    Language = Language.Parse("da")
                };

                processor.Process(args);

                Assert.That(args.CommentItem, Is.Not.Null);
                Assert.That(args.CommentItem.InnerItem.Axes.IsDescendantOf(entry), Is.True);

                var firstComment = args.CommentItem;

                processor.Process(args);

                Assert.That(args.CommentItem, Is.Not.Null);
                Assert.That(args.CommentItem.InnerItem.Axes.IsDescendantOf(entry), Is.True);
                Assert.That(args.CommentItem.ID, Is.Not.EqualTo(firstComment.ID));
                Assert.That(args.CommentItem.InnerItem.Name, Is.Not.EqualTo(firstComment.InnerItem.Name));
                Assert.That(args.CommentItem.InnerItem.Name, Does.Match(".+\\d$"));
            }
        }
Ejemplo n.º 2
0
        public void MultipleCommentsSameName()
        {
            using (var db = new Db
            {
                new DbTemplate(Settings.CommentTemplateID)
                {
                    new DbField("Name"),
                    new DbField("Email"),
                    new DbField("Comment"),
                    new DbField("Website"),
                    new DbField("IP Address"),
                },
                new DbItem("blog")
                {
                    new DbItem("entry")
                }
            })
            {
                var blog = db.GetItem("/sitecore/content/blog");
                var entry = db.GetItem("/sitecore/content/blog/entry");

                var blogManager = Mock.Of<IBlogManager>(x =>
                    x.GetCurrentBlog(entry) == new BlogHomeItem(blog)
                    );
                var processor = new TestableCreateCommentItemProcessor(blogManager);

                var args = new CreateCommentArgs
                {
                    Database = entry.Database,
                    Comment = new Comment
                    {
                        AuthorName = "commenter",
                        AuthorEmail = "*****@*****.**",
                        Text = "the comment"
                    },
                    EntryID = entry.ID,
                    Language = Language.Parse("da")
                };

                processor.Process(args);

                Assert.That(args.CommentItem, Is.Not.Null);
                Assert.That(args.CommentItem.InnerItem.Axes.IsDescendantOf(entry), Is.True);

                var firstComment = args.CommentItem;

                processor.Process(args);

                Assert.That(args.CommentItem, Is.Not.Null);
                Assert.That(args.CommentItem.InnerItem.Axes.IsDescendantOf(entry), Is.True);
                Assert.That(args.CommentItem.ID, Is.Not.EqualTo(firstComment.ID));
                Assert.That(args.CommentItem.InnerItem.Name, Is.Not.EqualTo(firstComment.InnerItem.Name));
                Assert.That(args.CommentItem.InnerItem.Name, Does.Match(".+\\d$"));
            }
        }