예제 #1
0
        public void InvalidEntryID()
        {
            var blogTemplateId = ID.NewID;

            using (var db = new Db
            {
                new DbItem("blog", ID.NewID, blogTemplateId)
            })
            {
                var blog = db.GetItem("/sitecore/content/blog");

                var blogManager = Mock.Of <IBlogManager>(x =>
                                                         x.GetCurrentBlog(It.IsAny <Item>()) == new BlogHomeItem(blog)
                                                         );
                var processor = new CreateCommentItem(blogManager);

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

                processor.Process(args);

                Assert.That(args.CommentItem, Is.Null);
            }
        }
        public void NullLanguage()
        {
            var processor = new CreateCommentItem(Mock.Of <IBlogManager>(), Mock.Of <IBlogSettingsResolver>());

            using (var db = new Db
            {
                new DbItem("blog")
                {
                    new DbItem("entry")
                }
            })
            {
                var entry = db.GetItem("/sitecore/content/blog/entry");
                var args  = new CreateCommentArgs
                {
                    Database = entry.Database,
                    EntryID  = entry.ID,
                    Comment  = new Comment
                    {
                        AuthorEmail = "*****@*****.**",
                        AuthorName  = "commentor",
                        Text        = "the comment"
                    }
                };

                Assert.That(() => processor.Process(args), Throws.InvalidOperationException);
            }
        }
예제 #3
0
        public void CustomFields()
        {
            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 DbField("field1"),
                    new DbField("field2")
                },
                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 CreateCommentItem(blogManager);

                var args = new CreateCommentArgs
                {
                    Database = entry.Database,
                    Comment  = new Comment
                    {
                        AuthorName  = "commenter",
                        AuthorEmail = "*****@*****.**",
                        Text        = "the comment",
                        Fields      =
                        {
                            { "field1", "value1" },
                            { "field2", "value2" },
                        }
                    },
                    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);
                Assert.That(args.CommentItem["field1"], Is.EqualTo("value1"));
                Assert.That(args.CommentItem["field2"], Is.EqualTo("value2"));
            }
        }
예제 #4
0
        public void NullLanguage()
        {
            var processor = new CreateCommentItem();

            using (var db = new Db
            {
                new DbItem("entry")
            })
            {
                var entry = db.GetItem("/sitecore/content/entry");
                var args  = new CreateCommentArgs
                {
                    Database = entry.Database,
                    Comment  = new Comment(),
                    EntryID  = entry.ID
                };

                Assert.That(() => processor.Process(args), Throws.InvalidOperationException);
            }
        }
        public void NullEntryId()
        {
            var processor = new CreateCommentItem(Mock.Of <IBlogManager>(), Mock.Of <IBlogSettingsResolver>());

            using (var db = new Db
            {
                new DbItem("entry")
            })
            {
                var entry = db.GetItem("/sitecore/content/entry");
                var args  = new CreateCommentArgs
                {
                    Database = entry.Database,
                    Comment  = new Comment(),
                    Language = Language.Parse("da")
                };

                Assert.That(() => processor.Process(args), Throws.InvalidOperationException);
            }
        }
예제 #6
0
        public void NullArgs()
        {
            var processor = new CreateCommentItem();

            Assert.That(() => processor.Process(null), Throws.ArgumentNullException);
        }
        public void NullArgs()
        {
            var processor = new CreateCommentItem(Mock.Of <IBlogManager>(), Mock.Of <IBlogSettingsResolver>());

            Assert.That(() => processor.Process(null), Throws.ArgumentNullException);
        }