Пример #1
0
        public void TwoTagsFirstWithContentAndPropertySecondTwoProperties()
        {
            TagServices tagServices = new TagServices(new BuildHandler());

            //                                                                                                                       11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112222222222222222222222222222222
            //                             11111111112222222222333333333344444444445555555555666666666677777777778888888888999999999900000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122222222223
            //                   012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
            string searchText = "some test text <!-- a_tag_name_START tag0property0='some value' -->some content<!-- a_tag_name_END -->  <!-- a_tag_name_START tag1Property0='another value' tag1Property1='yet another value' --> more content <!-- a_tag_name_END --> and some more text";
            string tagName    = "a_tag_name";

            List <Tag> actualTags = tagServices.ExtractTags(searchText, tagName, true);

            // Check result
            Dictionary <string, string> expectedTag0Properties = new Dictionary <string, string>()
            {
                { "tag0property0", "some value" }
            };
            Tag expectedTag0 = TagUtilities.CreateTestTag(tagName, searchText, 15, 37, 67, 79, 99, 102, "some content", expectedTag0Properties);

            Dictionary <string, string> expectedTag1Properties = new Dictionary <string, string>()
            {
                { "tag1Property0", "another value" }, { "tag1Property1", "yet another value" }
            };
            Tag expectedTag1 = TagUtilities.CreateTestTag(tagName, searchText, 104, 126, 193, 207, 227, 230, " more content ", expectedTag1Properties);

            Assert.True(2 == actualTags.Count);
            TagUtilities.AreTagsSame(expectedTag0, actualTags[0]);
            TagUtilities.AreTagsSame(expectedTag1, actualTags[1]);
        }
Пример #2
0
        public void TwoTagsOnePropertyTwoProperties()
        {
            TagServices tagServices = new TagServices(new BuildHandler());

            //                                                                                                                       111111111111111111111111111111111111111111111111111
            //                             111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999000000000011111111112222222222333333333344444444445
            //                   0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
            string searchText = "some test text <!-- a_tag_name tag0property0='some value' --> <!-- a_tag_name tag1Property0='another value' tag1Property1='yet another value' --> and some more text";
            string tagName    = "a_tag_name";

            List <Tag> actualTags = tagServices.ExtractTags(searchText, tagName, false);

            // Check result
            Dictionary <string, string> expectedTag0Properties = new Dictionary <string, string>()
            {
                { "tag0property0", "some value" }
            };
            Tag expectedTag0 = TagUtilities.CreateTestTag(tagName, searchText, 15, 31, 61, null, null, null, null, expectedTag0Properties);

            Dictionary <string, string> expectedTag1Properties = new Dictionary <string, string>()
            {
                { "tag1Property0", "another value" }, { "tag1Property1", "yet another value" }
            };
            Tag expectedTag1 = TagUtilities.CreateTestTag(tagName, searchText, 62, 78, 145, null, null, null, null, expectedTag1Properties);

            Assert.True(2 == actualTags.Count);
            TagUtilities.AreTagsSame(expectedTag0, actualTags[0]);
            TagUtilities.AreTagsSame(expectedTag1, actualTags[1]);
        }
Пример #3
0
        /// <summary>
        /// Checks that two Tag objects have identical properties
        /// </summary>
        /// <param name="expectedTag">Expected tag.</param>
        /// <param name="actualTag">Actual tag.</param>
        internal static void AreTagsSame(Tag expectedTag, Tag actualTag)
        {
            Assert.IsTrue((expectedTag == null) == (actualTag == null), "One Tag is null but the other isn't");

            Assert.AreEqual(expectedTag.Contents, actualTag.Contents);
            Assert.AreEqual(expectedTag.HasContent, actualTag.HasContent);
            Assert.AreEqual(expectedTag.Name, actualTag.Name);
            Assert.AreEqual(expectedTag.SearchText, actualTag.SearchText);

            TagUtilities.AreTagPositionsSame(expectedTag.StartTagPosition, actualTag.StartTagPosition);
            TagUtilities.AreTagPositionsSame(expectedTag.EndTagPosition, actualTag.EndTagPosition);

            TagUtilities.ArePropertiesSame(expectedTag.Properties, actualTag.Properties);
        }
Пример #4
0
        public void OneTagStart()
        {
            TagServices tagServices = new TagServices(new BuildHandler());

            //                             1111111111222222222233333333334444444444555
            //                   01234567890123456789012345678901234567890123456789012
            string searchText = "<!-- a_tag_name --> some test text and some more text\", \"a_tag_name";
            string tagName    = "a_tag_name";

            List <Tag> actualTags = tagServices.ExtractTags(searchText, tagName, false);

            // Check result
            Tag expectedTag = TagUtilities.CreateTestTag(tagName, searchText, 0, 16, 19);

            Assert.True(1 == actualTags.Count);
            TagUtilities.AreTagsSame(expectedTag, actualTags[0]);
        }
        public void OneTagWithContent()
        {
            TagServices tagServices = new TagServices(new BuildHandler());

            //                             11111111112222222222333333333344444444445555555555666666666677777777778888888888999
            //                   012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012
            string searchText = "some test text <!-- a_tag_name_START -->some content<!-- a_tag_name_END --> and some more text";
            string tagName    = "a_tag_name";
            string content    = "some content";

            List <Tag> actualTags = tagServices.ExtractTags(searchText, tagName, true);

            // Check result
            Tag expectedTag = TagUtilities.CreateTestTag(tagName, searchText, 15, 37, 40, 52, 72, 75, content);

            Assert.True(1 == actualTags.Count);
            TagUtilities.AreTagsSame(expectedTag, actualTags[0]);
        }
Пример #6
0
        public void TwoTagsStartAndEnd()
        {
            TagServices tagServices = new TagServices(new BuildHandler());

            //                             1111111111222222222233333333334444444444555555555566666666667
            //                   01234567890123456789012345678901234567890123456789012345678901234567890
            string searchText = "<!-- a_tag_name -->some test text and some more text<!-- a_tag_name -->";
            string tagName    = "a_tag_name";

            List <Tag> actualTags = tagServices.ExtractTags(searchText, tagName, false);

            // Check result
            Tag expectedTag0 = TagUtilities.CreateTestTag(tagName, searchText, 0, 16, 19);
            Tag expectedTag1 = TagUtilities.CreateTestTag(tagName, searchText, 52, 68, 71);

            Assert.True(2 == actualTags.Count);
            TagUtilities.AreTagsSame(expectedTag0, actualTags[0]);
            TagUtilities.AreTagsSame(expectedTag1, actualTags[1]);
        }
Пример #7
0
        public void ThreeTagsStartMiddleEnd()
        {
            TagServices tagServices = new TagServices(new BuildHandler());

            //                             11111111112222222222333333333344444444445555555555666666666677777777778888888888999
            //                   012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012
            string searchText = "<!-- a_tag_name -->some search text<!-- a_tag_name --> and some more text<!-- a_tag_name -->";
            string tagName    = "a_tag_name";

            List <Tag> actualTags = tagServices.ExtractTags(searchText, tagName, false);

            // Check result
            Tag expectedTag0 = TagUtilities.CreateTestTag(tagName, searchText, 0, 16, 19);
            Tag expectedTag1 = TagUtilities.CreateTestTag(tagName, searchText, 35, 51, 54);
            Tag expectedTag2 = TagUtilities.CreateTestTag(tagName, searchText, 73, 89, 92);

            Assert.True(3 == actualTags.Count);
            TagUtilities.AreTagsSame(expectedTag0, actualTags[0]);
            TagUtilities.AreTagsSame(expectedTag1, actualTags[1]);
            TagUtilities.AreTagsSame(expectedTag2, actualTags[2]);
        }
Пример #8
0
        public void ThreeTags()
        {
            TagServices tagServices = new TagServices(new BuildHandler());

            //                             11111111112222222222333333333344444444445555555555666666666677777777778888888888999
            //                   012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012
            string searchText = "some search text <!-- a_tag_name --><!-- a_tag_name --><!-- a_tag_name --> and some more text";
            string tagName    = "a_tag_name";

            List <Tag> actualTags = tagServices.ExtractTags(searchText, tagName, false);

            // Check result
            Tag expectedTag0 = TagUtilities.CreateTestTag(tagName, searchText, 17, 33, 36);
            Tag expectedTag1 = TagUtilities.CreateTestTag(tagName, searchText, 36, 52, 55);
            Tag expectedTag2 = TagUtilities.CreateTestTag(tagName, searchText, 55, 71, 74);

            Assert.True(3 == actualTags.Count);
            TagUtilities.AreTagsSame(expectedTag0, actualTags[0]);
            TagUtilities.AreTagsSame(expectedTag1, actualTags[1]);
            TagUtilities.AreTagsSame(expectedTag2, actualTags[2]);
        }
Пример #9
0
        public void OneTagWithTwoPropertiesNoSpace()
        {
            TagServices tagServices = new TagServices(new BuildHandler());

            //                             11111111112222222222333333333344444444445555555555666666666677777777778888888888999
            //                   012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012
            string searchText = "some test text <!-- a_tag_name property0='some value'property1='another value' --> and some more text";
            string tagName    = "a_tag_name";

            List <Tag> actualTags = tagServices.ExtractTags(searchText, tagName, false);

            // Check result
            Dictionary <string, string> expectedProperties = new Dictionary <string, string>()
            {
                { "property0", "some value" }, { "property1", "another value" }
            };
            Tag expectedTag = TagUtilities.CreateTestTag(tagName, searchText, 15, 31, 82, null, null, null, null, expectedProperties);

            Assert.True(1 == actualTags.Count);
            TagUtilities.AreTagsSame(expectedTag, actualTags[0]);
        }
        public void TwoTagsWithContent()
        {
            TagServices tagServices = new TagServices(new BuildHandler());

            //                                                                                                                       111111111111111111111111111111111111111111111111111
            //                             111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999000000000011111111112222222222333333333344444444445
            //                   0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
            string searchText  = "some test text <!-- a_tag_name_START -->some content<!-- a_tag_name_END --> text <!-- a_tag_name_START -->more content<!-- a_tag_name_END --> more text";
            string tagName     = "a_tag_name";
            string tag0Content = "some content";
            string tag1Content = "more content";

            List <Tag> actualTags = tagServices.ExtractTags(searchText, tagName, true);

            // Check result
            Tag expectedTag0 = TagUtilities.CreateTestTag(tagName, searchText, 15, 37, 40, 52, 72, 75, tag0Content);
            Tag expectedTag1 = TagUtilities.CreateTestTag(tagName, searchText, 81, 103, 106, 118, 138, 141, tag1Content);

            Assert.True(2 == actualTags.Count);
            TagUtilities.AreTagsSame(expectedTag0, actualTags[0]);
            TagUtilities.AreTagsSame(expectedTag1, actualTags[1]);
        }