Пример #1
0
        public void MoveNext_ImplicitChapter1AndVerse1()
        {
            CheckDisposed();

            IScrSection      sectionCur = ScrSection.CreateSectionWithEmptyParas(m_genesis, 0, false);
            TsStringAccessor heading    = ((StTxtPara)sectionCur.HeadingOA.ParagraphsOS[0]).Contents;
            ITsStrBldr       strBldr    = heading.UnderlyingTsString.GetBldr();

            strBldr.Replace(0, strBldr.Length, "My aching head!", null);
            heading.UnderlyingTsString = strBldr.GetString();

            TsStringAccessor content = ((StTxtPara)sectionCur.ContentOA.ParagraphsOS[0]).Contents;

            strBldr = content.UnderlyingTsString.GetBldr();
            strBldr.Replace(0, strBldr.Length, "Verse One. ", null);
            content.UnderlyingTsString = strBldr.GetString();

            sectionCur.AdjustReferences();

            ScrTxtPara  stPara   = new ScrTxtPara(Cache, sectionCur.ContentOA.ParagraphsOS.HvoArray[0]);
            ScrVerseSet verseSet = new ScrVerseSet(stPara);

            // Iterate through the verses in the paragraph
            ScrVerse verse;

            Assert.IsTrue(verseSet.MoveNext());
            verse = (ScrVerse)verseSet.Current;
            Assert.AreEqual("Verse One. ", verse.Text.Text);
            Assert.AreEqual(01001001, verse.StartRef);
            Assert.AreEqual(01001001, verse.EndRef);

            Assert.IsFalse(verseSet.MoveNext());
        }
Пример #2
0
        public void MoveNext_EmptyPara()
        {
            CheckDisposed();
            IScrSection section   = m_scrInMemoryCache.AddSectionToMockedBook(m_genesis.Hvo);
            StTxtPara   emptyPara = AddEmptyPara(section, ScrStyleNames.SpeechLine1);

            section.AdjustReferences();

            // Create and iterate through the verses in the StText.
            ScrTxtPara  emptyScrPara = new ScrTxtPara(m_inMemoryCache.Cache, emptyPara.Hvo);
            ScrVerseSet verseSet     = new ScrVerseSet(emptyScrPara);

            Assert.IsFalse(verseSet.MoveNext(),
                           "The iterator provided a ScrVerse for an empty para that wasn't a Stanza Break.");
        }
Пример #3
0
        public void MoveNext_NonNumericChapter()
        {
            CheckDisposed();

            IScrSection      sectionCur = ScrSection.CreateSectionWithEmptyParas(m_genesis, 0, false);
            TsStringAccessor heading    = ((StTxtPara)sectionCur.HeadingOA.ParagraphsOS[0]).Contents;
            ITsStrBldr       strBldr    = heading.UnderlyingTsString.GetBldr();

            strBldr.Replace(0, strBldr.Length, "My aching head!", null);
            heading.UnderlyingTsString = strBldr.GetString();

            TsStringAccessor content = ((StTxtPara)sectionCur.ContentOA.ParagraphsOS[0]).Contents;

            strBldr = content.UnderlyingTsString.GetBldr();
            strBldr.Replace(0, strBldr.Length, "A",
                            StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, Cache.DefaultVernWs));
            strBldr.Replace(strBldr.Length, strBldr.Length, "Verse One. ",
                            StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            strBldr.Replace(strBldr.Length, strBldr.Length, "2",
                            StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber, Cache.DefaultVernWs));
            strBldr.Replace(strBldr.Length, strBldr.Length, " Verse Two. ",
                            StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            content.UnderlyingTsString = strBldr.GetString();

            sectionCur.AdjustReferences();

            ScrTxtPara stPara = new ScrTxtPara(Cache, sectionCur.ContentOA.ParagraphsOS.HvoArray[0]);

            ScrVerseSet verseSet = new ScrVerseSet(stPara);

            // Iterate through the verses in the paragraph
            ScrVerse verse;

            Assert.IsTrue(verseSet.MoveNext());
            verse = (ScrVerse)verseSet.Current;
            Assert.AreEqual("AVerse One. ", verse.Text.Text);
            Assert.AreEqual(01001001, verse.StartRef);
            Assert.AreEqual(01001001, verse.EndRef);

            Assert.IsTrue(verseSet.MoveNext());
            verse = (ScrVerse)verseSet.Current;
            Assert.AreEqual("2 Verse Two. ", verse.Text.Text);
            Assert.AreEqual(01001002, verse.StartRef);
            Assert.AreEqual(01001002, verse.EndRef);

            Assert.IsFalse(verseSet.MoveNext());
        }
Пример #4
0
        public void MoveNext_StanzaBreak()
        {
            CheckDisposed();
            IScrSection section   = m_scrInMemoryCache.AddSectionToMockedBook(m_genesis.Hvo);
            StTxtPara   emptyPara = AddEmptyPara(section, ScrStyleNames.StanzaBreak);

            section.AdjustReferences();

            // Create and iterate through the verses in the StText.
            ScrTxtPara  emptyScrPara = new ScrTxtPara(m_inMemoryCache.Cache, emptyPara.Hvo);
            ScrVerseSet verseSet     = new ScrVerseSet(emptyScrPara);

            Assert.IsTrue(verseSet.MoveNext());
            VerifyScrVerse((ScrVerse)verseSet.Current, m_inMemoryCache.Cache, null,
                           ScrStyleNames.StanzaBreak, 01001001, 01001001);
            Assert.IsFalse(verseSet.MoveNext());
        }
Пример #5
0
        public void MoveNext_SpacesInVerses()
        {
            CheckDisposed();

            ScrSection sectionCur = new ScrSection();

            m_genesis.SectionsOS.Append(sectionCur);
            // Create a section head for this section
            sectionCur.HeadingOA = new StText();
            StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);

            paraBldr.ParaProps = StyleUtils.ParaStyleTextProps(ScrStyleNames.SectionHead);
            paraBldr.AppendRun("My aching head!",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            paraBldr.CreateParagraph(sectionCur.HeadingOAHvo);
            sectionCur.ContentOA = new StText();

            paraBldr           = new StTxtParaBldr(Cache);
            paraBldr.ParaProps = StyleUtils.ParaStyleTextProps(ScrStyleNames.NormalParagraph);
            paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
                                                                  Cache.DefaultVernWs));
            paraBldr.AppendRun("Verse One. ",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
                                                                  Cache.DefaultVernWs));
            paraBldr.AppendRun(" Verse Two. ",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            paraBldr.AppendRun("3", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
                                                                  Cache.DefaultVernWs));
            paraBldr.AppendRun("Verse Three.",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            paraBldr.AppendRun("4", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
                                                                  Cache.DefaultVernWs));
            paraBldr.AppendRun("     ",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            StTxtPara para = paraBldr.CreateParagraph(sectionCur.ContentOA.Hvo);

            sectionCur.AdjustReferences();

            ScrTxtPara  stPara   = new ScrTxtPara(Cache, para.Hvo);
            ScrVerseSet verseSet = new ScrVerseSet(stPara);

            // Iterate through the verses in the paragraph
            ScrVerse verse;

            Assert.IsTrue(verseSet.MoveNext());
            verse = (ScrVerse)verseSet.Current;
            Assert.AreEqual("1", verse.Text.Text);
            Assert.AreEqual(01001001, verse.StartRef);
            Assert.AreEqual(01001001, verse.EndRef);

            Assert.IsTrue(verseSet.MoveNext());
            verse = (ScrVerse)verseSet.Current;
            Assert.AreEqual("Verse One. ", verse.Text.Text);
            Assert.AreEqual(01001001, verse.StartRef);
            Assert.AreEqual(01001001, verse.EndRef);

            Assert.IsTrue(verseSet.MoveNext());
            verse = (ScrVerse)verseSet.Current;
            Assert.AreEqual("2 Verse Two. ", verse.Text.Text);
            Assert.AreEqual(01001002, verse.StartRef);
            Assert.AreEqual(01001002, verse.EndRef);

            Assert.IsTrue(verseSet.MoveNext());
            verse = (ScrVerse)verseSet.Current;
            Assert.AreEqual("3Verse Three.", verse.Text.Text);
            Assert.AreEqual(01001003, verse.StartRef);
            Assert.AreEqual(01001003, verse.EndRef);

            Assert.IsTrue(verseSet.MoveNext());
            verse = (ScrVerse)verseSet.Current;
            Assert.AreEqual("4     ", verse.Text.Text);
            Assert.AreEqual(01001004, verse.StartRef);
            Assert.AreEqual(01001004, verse.EndRef);

            Assert.IsFalse(verseSet.MoveNext());
        }