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); } }
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); } }
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); } }
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); } }
public void NullArgs() { var processor = new DuplicateSubmissionGuard(); Assert.That(() => processor.Process(null), Throws.ArgumentNullException); }