コード例 #1
0
        public void NullLanguage()
        {
            var processor = new DuplicateSubmissionGuard();

            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);
            }
        }
コード例 #2
0
        public void InvalidEntryId()
        {
            var processor = new DuplicateSubmissionGuard();

            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,
                    Language = Language.Parse("de"),
                    Comment  = new Comment
                    {
                        AuthorEmail = "*****@*****.**",
                        AuthorName  = "commentor",
                        Text        = "the comment"
                    }
                };

                processor.Process(args);

                Assert.That(args.Aborted, Is.False);
            }
        }
コード例 #3
0
        public void NoDuplicateComment()
        {
            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 DuplicateSubmissionGuard(blogManager);

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

                processor.Process(args);

                Assert.That(args.Aborted, Is.False);
            }
        }
コード例 #4
0
        public void NullComment()
        {
            var processor = new DuplicateSubmissionGuard();

            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,
                    Language = Language.Parse("de")
                };

                Assert.That(() => processor.Process(args), Throws.InvalidOperationException);
            }
        }
コード例 #5
0
        public void NullArgs()
        {
            var processor = new DuplicateSubmissionGuard();

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