Example #1
0
        public void GetSubEntitiesFormat_should_return_rawtext_if_entity_has_no_sub_entities()
        {
            const string rawText = "Some raw text";
            var testEnity = new TestEntity(rawText);
            var formatter = new TestFormatter();

            var result = testEnity.GetSubEntitiesFormat(formatter);
            Assert.AreEqual(rawText, result);
        }
Example #2
0
        public void AddParsedSubEntitiesWithBubbling_should_not_add_insignificant_leaves()
        {
            const string rawText = "RawText";
            var correctAnswer = new TestEntity(rawText);

            var testEnity = new TestEntity(rawText);
            var insignficantLeaf = new[] { (Entity) new ParsedTextEntity(rawText) }.ToList();
            testEnity.AddParsedSubEntitiesWithBubbling(insignficantLeaf);

            Assert.AreEqual(correctAnswer, testEnity);
        }
Example #3
0
        public void GetSubEntitiesFormat_should_return_formatted_text_if_entity_has_sub_entities()
        {
            const string rawText = "Some raw text";
            const string correctAnswer = "<test>Some</test><test>raw</test><test>text</test>";
            var formatter = new TestFormatter();
            var subEntities = rawText
                    .Split(' ')
                    .Select(str => (Entity)new TestEntity(str))
                    .ToList();
            var testEnity = new TestEntity(subEntities);

            var result = testEnity.GetSubEntitiesFormat(formatter);
            Assert.AreEqual(correctAnswer, result);
        }
Example #4
0
        public void AddParsedSubEntitiesWithBubbling_should_delete_insignificant_entities_using_bubbling()
        {
            var bottomLvl = ParseStringIntoTestEntities("test test");

            var topLvl = "test test text test"
                        .Split(' ')
                        .Select(s => s == "test" ? (Entity) new TestEntity(s) : new RawTextEntity(bottomLvl))
                        .ToList();

            var correctAnswerSubEntities = ParseStringIntoTestEntities("test test test test test");
            var correctAnswer = new TestEntity(correctAnswerSubEntities);

            var testEnity = new TestEntity("");
            testEnity.AddParsedSubEntitiesWithBubbling(topLvl);

            Assert.AreEqual(correctAnswer, testEnity);
        }
Example #5
0
 public void AddParsedSubEntitiesWithBubbling_should_not_throw_when_argument_is_null()
 {
     var testEnity = new TestEntity("RawText");
     Assert.DoesNotThrow(delegate { testEnity.AddParsedSubEntitiesWithBubbling(null); });
 }