public void Test(string input, string expected, int limit, bool stripTags) { var procesor = new AutoGenerate { FieldName = "Text", StripTags = stripTags, MaximumCharacterCount = limit }; using (var db = new Db { new DbItem("item") { new DbField("text") { Value = input } } }) { var args = new GetSummaryArgs { Entry = db.GetItem("/sitecore/content/item") }; procesor.Process(args); Assert.That(args.Summary, Is.EqualTo(expected)); } }
public void Test(string input, string expected, string xpath) { var procesor = new FirstContentBlock { FieldName = "Text", XPath = xpath }; using (var db = new Db { new DbItem("item") { new DbField("text") { Value = input } } }) { var args = new GetSummaryArgs { Entry = db.GetItem("/sitecore/content/item") }; procesor.Process(args); Assert.That(args.Summary, Is.EqualTo(expected)); } }
public void Process(GetSummaryArgs args) { if (ShouldProcess(args)) { GetSummary(args); } }
protected string GetSummary(EntryItem entry) { var args = new GetSummaryArgs(); args.Entry = entry; CorePipeline.Run("weblogGetSummary", args, true); return(args.Summary); }
protected string GetSummary(EntryItem entry) { var args = new GetSummaryArgs(); args.Entry = entry; //#if SC62 || SC64 // CorePipeline.Run("weblogGetSummary", args); //#else CorePipeline.Run("weblogGetSummary", args, true); //#endif return(args.Summary); }
public void ContainsCutTag() { var procesor = new FirstContentBlock(); procesor.XPath = "//hr"; var args = new GetSummaryArgs(); args.Entry = m_contentSurroundingTag; procesor.Process(args); Assert.AreEqual("<div>Lorem ipsum</div>", args.Summary); }
public void ContainsNoTag() { var procesor = new FirstContentBlock(); procesor.XPath = "//hr"; var args = new GetSummaryArgs(); args.Entry = m_contentNoTags; procesor.Process(args); Assert.IsNullOrEmpty(args.Summary); }
public void ContainsSurroundingTag() { var procesor = new FirstContentBlock(); procesor.XPath = "//span"; var args = new GetSummaryArgs(); args.Entry = m_contentContainsSpan; procesor.Process(args); Assert.AreEqual("Nullam et arcu dui, in pharetra diam. In vitae ante ac orci mollis egestas a ", args.Summary); }
public void ContainsSelfClosingTag() { var procesor = new FirstContentBlock(); procesor.XPath = "//hr"; var args = new GetSummaryArgs(); args.Entry = m_contentContainsHr; procesor.Process(args); Assert.AreEqual("Lorem ipsum", args.Summary); }
public void NullItem() { var procesor = new AutoGenerate(); procesor.StripTags = true; procesor.MaximumCharacterCount = 300; var args = new GetSummaryArgs(); args.Entry = null; procesor.Process(args); Assert.IsNullOrEmpty(args.Summary); }
public void StripTags_NoTags() { var procesor = new AutoGenerate(); procesor.StripTags = true; procesor.MaximumCharacterCount = m_contentNoTagsSmall["content"].Length; var args = new GetSummaryArgs(); args.Entry = m_contentNoTagsSmall; procesor.Process(args); Assert.AreEqual(m_contentNoTagsSmall["content"], args.Summary); }
public void StripTags_TagsPresent() { var procesor = new AutoGenerate(); procesor.StripTags = true; procesor.MaximumCharacterCount = 300; var args = new GetSummaryArgs(); args.Entry = m_contentTagsSmall; procesor.Process(args); Assert.AreEqual("Lorem ipsum dolor sit amet", args.Summary); }
public void StripTagsLimit_OverLimit() { var procesor = new AutoGenerate(); procesor.StripTags = true; procesor.MaximumCharacterCount = 200; var args = new GetSummaryArgs(); args.Entry = m_contentTagsLarge; procesor.Process(args); Assert.AreEqual("HTML Ipsum PresentsPellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu ...", args.Summary); }
public void AlreadyWrapped_AlwaysWrap() { var processor = new Wrap(); processor.OnlyWhenRequired = false; processor.WrappingTag = "span"; var args = new GetSummaryArgs(); args.Summary = "<span>lorem ipsum</span>"; processor.Process(args); Assert.AreEqual("<span><span>lorem ipsum</span></span>", args.Summary); }
public void EmptySummary() { var processor = new Wrap(); processor.OnlyWhenRequired = true; processor.WrappingTag = "p"; var args = new GetSummaryArgs(); args.Summary = string.Empty; processor.Process(args); Assert.AreEqual("<p></p>", args.Summary); }
public void Unwrapped_OnlyRequiredWrap() { var processor = new Wrap(); processor.OnlyWhenRequired = true; processor.WrappingTag = "span"; var args = new GetSummaryArgs(); args.Summary = "lorem ipsum"; processor.Process(args); Assert.AreEqual("<span>lorem ipsum</span>", args.Summary); }
public void KeepTagsLimit_OverLimit() { var procesor = new AutoGenerate(); procesor.StripTags = false; procesor.MaximumCharacterCount = 41; var args = new GetSummaryArgs(); args.Entry = m_contentTagsLarge; procesor.Process(args); // It doesn't appear HAP is closing the P tag. Assert.AreEqual("<h1>HTML Ipsum Presents</h1><p><strong>Pellentesque habitant ...</strong>", args.Summary); }
public void EmptyField() { var procesor = new AutoGenerate(); procesor.FieldName = "Text"; procesor.StripTags = true; procesor.MaximumCharacterCount = 300; var args = new GetSummaryArgs(); args.Entry = m_testRoot; procesor.Process(args); Assert.IsNullOrEmpty(args.Summary); }
public void NullItem() { var procesor = new FirstContentBlock { FieldName = "Text", XPath = "//hr" }; var args = new GetSummaryArgs { Entry = null }; procesor.Process(args); Assert.That(args.Summary, Is.Empty); }
public void Test(bool onlyWhenRequired, string tag, string input, string expected) { var processor = new Wrap { OnlyWhenRequired = onlyWhenRequired, WrappingTag = tag }; var args = new GetSummaryArgs { Summary = input }; processor.Process(args); Assert.That(args.Summary, Is.EqualTo(expected)); }
public void NullItem() { var procesor = new AutoGenerate { FieldName = "Text", StripTags = true, MaximumCharacterCount = 200 }; var args = new GetSummaryArgs { Entry = null }; procesor.Process(args); Assert.That(args.Summary, Is.Empty); }
protected abstract void GetSummary(GetSummaryArgs args);
protected virtual bool ShouldProcess(GetSummaryArgs args) { return(string.IsNullOrEmpty(args.Summary)); }
protected virtual bool ShouldProcess(GetSummaryArgs args) { return string.IsNullOrEmpty(args.Summary); }
public void Process(GetSummaryArgs args) { if (ShouldProcess(args)) GetSummary(args); }