Exemple #1
0
        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));
            }
        }
Exemple #2
0
        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));
            }
        }
Exemple #3
0
 public void Process(GetSummaryArgs args)
 {
     if (ShouldProcess(args))
     {
         GetSummary(args);
     }
 }
Exemple #4
0
        protected string GetSummary(EntryItem entry)
        {
            var args = new GetSummaryArgs();

            args.Entry = entry;

            CorePipeline.Run("weblogGetSummary", args, true);

            return(args.Summary);
        }
Exemple #5
0
        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);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        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);
        }
Exemple #12
0
        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);
        }
Exemple #13
0
        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);
        }
Exemple #14
0
        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);
        }
Exemple #15
0
        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);
        }
Exemple #16
0
        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);
        }
Exemple #17
0
        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);
        }
Exemple #18
0
        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);
        }
Exemple #19
0
        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);
        }
Exemple #20
0
        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));
        }
Exemple #21
0
        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);
        }
Exemple #22
0
 protected abstract void GetSummary(GetSummaryArgs args);
Exemple #23
0
 protected virtual bool ShouldProcess(GetSummaryArgs args)
 {
     return(string.IsNullOrEmpty(args.Summary));
 }
 protected virtual bool ShouldProcess(GetSummaryArgs args)
 {
     return string.IsNullOrEmpty(args.Summary);
 }
 protected abstract void GetSummary(GetSummaryArgs args);
 public void Process(GetSummaryArgs args)
 {
     if (ShouldProcess(args))
         GetSummary(args);
 }