상속: GetSummaryProcessorBase
예제 #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));
            }
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
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);
        }
예제 #6
0
        public void StripTags_TagsPresent()
        {
            var procesor = new AutoGenerate();
            procesor.FieldName = "Text";
            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);
        }
예제 #7
0
        public void StripTags_NoTags()
        {
            var procesor = new AutoGenerate();
            procesor.FieldName = "Text";
            procesor.StripTags = true;
            procesor.MaximumCharacterCount = m_contentNoTagsSmall["text"].Length;

            var args = new GetSummaryArgs();
            args.Entry = m_contentNoTagsSmall;

            procesor.Process(args);

            Assert.AreEqual(m_contentNoTagsSmall["text"], args.Summary);
        }
예제 #8
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);
        }