예제 #1
0
        public void DifferentText()
        {
            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")
                    {
                        new DbItem("comment", ID.NewID, Settings.CommentTemplateID)
                        {
                            new DbField("Name")
                            {
                                { "de", "commentor" }
                            },
                            new DbField("Email")
                            {
                                { "de", "*****@*****.**" }
                            },
                            new DbField("Comment")
                            {
                                { "de", "the comment" }
                            },
                        }
                    }
                }
            })
            {
                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 updated"
                    }
                };

                processor.Process(args);

                Assert.That(args.Aborted, Is.False);
            }
        }
예제 #2
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);
            }
        }
예제 #3
0
 public void NullArgs()
 {
     var processor = new DuplicateSubmissionGuard();
     Assert.That(() => processor.Process(null), Throws.ArgumentNullException);
 }
예제 #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 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);
            }
        }