예제 #1
0
        public void VerseIterator_EmptyParasInMiddle()
        {
            // Create section 1 for Genesis, with an empty section.
            IScrSection section1 = CreateSection(m_genesis, "My aching head!");

            // build first paragraph with content, two empty and the last with content
            IScrTxtPara contentPara1 = AddParaToMockedSectionContent(section1, ScrStyleNames.NormalParagraph);

            AddVerse(contentPara1, 0, 1, "First verse before empty paragraph.");

            AddEmptyPara(section1, ScrStyleNames.Line1);
            AddEmptyPara(section1, ScrStyleNames.ListItem1);

            IScrTxtPara contentPara2 = AddParaToMockedSectionContent(section1, ScrStyleNames.NormalParagraph);

            AddVerse(contentPara2, 0, 2, "First verse after empty paragraphs.");

            //Create an iterator and test it
            m_bookMerger.CreateVerseIteratorForStText(section1.ContentOA);

            // Verify section 1 content--first two will be empty
            DiffTestHelper.VerifyScrVerse(m_bookMerger.NextVerseInStText(), "1First verse before empty paragraph.",
                                          ScrStyleNames.NormalParagraph, 01001001, 01001001);
            ScrVerse verse = m_bookMerger.NextVerseInStText();

            DiffTestHelper.VerifyScrVerse(verse, "2First verse after empty paragraphs.", ScrStyleNames.NormalParagraph,
                                          01001002, 01001002);

            Assert.IsNull(m_bookMerger.NextVerseInStText());
        }
예제 #2
0
        public void VerseIterator_EmptyParasAtStart()
        {
            // Create section 1 for Genesis, with an empty section.
            IScrSection section1 = CreateSection(m_genesis, "My aching head!");

            // build two empty paragraphs for section 1
            AddEmptyPara(section1, ScrStyleNames.Line1);
            AddEmptyPara(section1, ScrStyleNames.ListItem1);

            // build third paragraph with content
            IScrTxtPara contentPara = AddParaToMockedSectionContent(section1,
                                                                    ScrStyleNames.NormalParagraph);

            AddVerse(contentPara, 0, 2, "First verse after empty paragraphs.");

            //Create an iterator and test it
            m_bookMerger.CreateVerseIteratorForStText(section1.ContentOA);
            ScrVerse verse = m_bookMerger.NextVerseInStText();

            DiffTestHelper.VerifyScrVerse(verse, "2First verse after empty paragraphs.",
                                          ScrStyleNames.NormalParagraph, 01001002, 01001002);
            Assert.AreEqual(contentPara, verse.Para);
            Assert.AreEqual(0, verse.VerseStartIndex);

            Assert.IsNull(m_bookMerger.NextVerseInStText());
        }
예제 #3
0
        public void VerseIterator_StanzaBreakOnlyPara()
        {
            // Create section 1 for Genesis, with an empty section.
            IScrSection section1 = CreateSection(m_genesis, "My aching head!");
            // add one stanza break for section 1
            IScrTxtPara stanzaPara = AddEmptyPara(section1, ScrStyleNames.StanzaBreak);

            //Create an iterator and test it
            m_bookMerger.CreateVerseIteratorForStText(section1.ContentOA);

            // Verify section 1 content
            ScrVerse verse = m_bookMerger.NextVerseInStText();

            DiffTestHelper.VerifyScrVerse(verse, null, ScrStyleNames.StanzaBreak,
                                          01001001, 01001001);
            Assert.AreEqual(stanzaPara, verse.Para);
            Assert.IsTrue(verse.IsStanzaBreak);
            Assert.AreEqual(0, verse.VerseStartIndex);

            Assert.IsNull(m_bookMerger.NextVerseInStText());
        }
예제 #4
0
        public void VerseIterator_EmptyParasAtEnd()
        {
            // Create section 1 for Genesis, with an empty section.
            IScrSection section1 = CreateSection(m_genesis, "My aching head!");

            // build first paragraph with content, followed by two empty paragraphs
            IScrTxtPara contentPara1 = AddParaToMockedSectionContent(section1, ScrStyleNames.NormalParagraph);

            AddVerse(contentPara1, 0, 1, "First verse before empty paragraphs.");

            AddEmptyPara(section1, ScrStyleNames.Line1);
            AddEmptyPara(section1, ScrStyleNames.ListItem1);


            //Create an iterator and test it
            m_bookMerger.CreateVerseIteratorForStText(section1.ContentOA);

            // Verify section 1 content--last two will be empty
            DiffTestHelper.VerifyScrVerse(m_bookMerger.NextVerseInStText(),
                                          "1First verse before empty paragraphs.", ScrStyleNames.NormalParagraph,
                                          01001001, 01001001);
            Assert.IsNull(m_bookMerger.NextVerseInStText(), "The empty paragraphs should not return a ScrVerse");
        }
예제 #5
0
        public void VerseIterator_EmptyBook()
        {
            // Create section 1 for Genesis, with an empty section head and empty paragraph.
            IScrSection section1 = CreateSection(m_genesis, "");
            IScrTxtPara para     = AddEmptyPara(section1);

            //Create an iterator for the section heading
            m_bookMerger.CreateVerseIteratorForStText(section1.HeadingOA);

            // Verify that the verse iterator returns nothing
            Assert.IsNull(m_bookMerger.NextVerseInStText());

            //Create an iterator for the section contents
            m_bookMerger.CreateVerseIteratorForStText(section1.ContentOA);

            // Verify section 1 content contains only one empty paragraph.
            ScrVerse emptyVerse = m_bookMerger.CallFirstVerseForStText((IStText)section1.ContentOA);

            Assert.IsNotNull(emptyVerse);
            DiffTestHelper.VerifyScrVerse(emptyVerse, string.Empty, ScrStyleNames.NormalParagraph, 0, 0);

            // Verify that the verse iterator doesn't return any more ScrVerses
            Assert.IsNull(m_bookMerger.NextVerseInStText());
        }
예제 #6
0
        public void VerseIterator_ForSetOfStTexts()
        {
            // Create section 1 for Genesis.
            IScrSection section1 = CreateSection(m_genesis, "My aching head!");

            // build paragraph for section 1
            StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);

            paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
            paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
                                                                  Cache.DefaultVernWs));
            paraBldr.AppendRun("Verse 1. ",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            IScrTxtPara para1 = (IScrTxtPara)paraBldr.CreateParagraph(section1.ContentOA);

            // Create section 2 for Genesis.
            IScrSection section2 = CreateSection(m_genesis, "My aching behind!");

            // build paragraph for section 2
            paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
            paraBldr.AppendRun("3", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
                                                                  Cache.DefaultVernWs));
            paraBldr.AppendRun("Verse 1. ",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            IScrTxtPara para2 = (IScrTxtPara)paraBldr.CreateParagraph(section2.ContentOA);

            // Create section 3 for Genesis.
            IScrSection section3 = CreateSection(m_genesis, "");

            // build paragraph for section 3
            paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
            IScrTxtPara para3 = (IScrTxtPara)paraBldr.CreateParagraph(section3.ContentOA);

            // Create an iterator to test group of StTexts
            List <IStText> list = new List <IStText>(6);

            // this is not a typical list for TE, just a bunch of StTexts for this test
            list.Add(section1.HeadingOA);
            list.Add(section2.HeadingOA);
            list.Add(section3.HeadingOA);
            list.Add(section1.ContentOA);
            list.Add(section2.ContentOA);
            list.Add(section3.ContentOA);
            m_bookMerger.CreateVerseIteratorForSetOfStTexts(list);

            // Verify section 1 heading
            ScrVerse scrVerse = m_bookMerger.NextVerseInSet();

            DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section1.HeadingOA[0],
                                          01002001, 01002001, "My aching head!", 0, false, true, 0);

            // Verify section 2 heading
            scrVerse = m_bookMerger.NextVerseInSet();
            DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section2.HeadingOA[0],
                                          01003001, 01003001, "My aching behind!", 0, false, true, 1);

            // section 3 heading is empty, but returns an empty ScrVerse
            scrVerse = m_bookMerger.NextVerseInSet();
            DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section3.HeadingOA[0],
                                          01003001, 01003001, null, 0, false, true, 2);

            // Verify section 1 content
            scrVerse = m_bookMerger.NextVerseInSet();
            DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section1.ContentOA[0],
                                          01002001, 01002001, "2Verse 1. ", 0, true, false, 0);

            // Verify section 2 content
            scrVerse = m_bookMerger.NextVerseInSet();
            DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section2.ContentOA[0],
                                          01003001, 01003001, "3Verse 1. ", 0, true, false, 1);

            // Verify section 3 content--an empty ScrVerse
            scrVerse = m_bookMerger.NextVerseInSet();
            DiffTestHelper.VerifyScrVerse(scrVerse, (IScrTxtPara)section3.ContentOA[0],
                                          01003001, 01003001, null, 0, false, false, 2);

            // Verify there are no more scrVerses
            scrVerse = m_bookMerger.NextVerseInSet();
            Assert.IsNull(scrVerse);
        }