Beispiel #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());
        }
Beispiel #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());
        }
        /// --------------------------------------------------------------------------------
        /// <summary>
        /// Calls FirstVerseForStText in the book merger.
        /// </summary>
        /// <param name="text">IStText from which we want to get the first verse.</param>
        /// --------------------------------------------------------------------------------
        public ScrVerse CallFirstVerseForStText(IStText text)
        {
            ScrVerse prevVerse = null;

            using (VerseIteratorForStText iterator = new VerseIteratorForStText(text))
                return(FirstVerseForStText(iterator, ref prevVerse));
        }
Beispiel #4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="DiffLocation"/> class that covers an
 /// entire Scripture verse.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 internal DiffLocation(ScrVerse scrVerse) : this(scrVerse.Para, scrVerse.VerseStartIndex)
 {
     if (scrVerse.Text != null)
     {
         IchLim = IchMin + scrVerse.TextLength;
     }
 }
Beispiel #5
0
        /// -----------------------------------------------------------------------------------
        ///<summary>
        /// Verify the specified ScrVerse
        ///</summary>
        ///<param name="verse">specified ScrVerse</param>
        ///<param name="verseText">expected text within the ScrVerse</param>
        ///<param name="styleName">expected stylename for the ScrVerse paragraph</param>
        ///<param name="startRef">expected starting reference</param>
        ///<param name="endRef">expected ending reference</param>
        /// -----------------------------------------------------------------------------------
        public static void VerifyScrVerse(ScrVerse verse, string verseText, string styleName,
                                          BCVRef startRef, BCVRef endRef)
        {
            IScrTxtPara versePara = verse.Para;

            if (string.IsNullOrEmpty(verseText))
            {
                Assert.IsTrue(verse.Text == null || string.IsNullOrEmpty(verse.Text.Text));
            }
            else
            {
                Assert.AreEqual(verseText, verse.Text.Text);
            }
            Assert.AreEqual(styleName, versePara.StyleName);
            Assert.AreEqual(startRef, verse.StartRef);
            Assert.AreEqual(endRef, verse.EndRef);
        }
Beispiel #6
0
        public void MoveNext_StanzaBreak()
        {
            IScrSection section   = AddSectionToMockedBook(m_genesis);
            IScrTxtPara emptyPara = AddEmptyPara(section, ScrStyleNames.StanzaBreak);

            // Create and iterate through the verses in the StText.
            using (ScrVerseSet verseSet = new ScrVerseSet(emptyPara))
            {
                Assert.IsTrue(verseSet.MoveNext());
                ScrVerse verse = verseSet.Current;
                Assert.IsTrue(verse.Text == null || string.IsNullOrEmpty(verse.Text.Text));
                Assert.AreEqual(ScrStyleNames.StanzaBreak, verse.Para.StyleName);
                Assert.AreEqual(01001001, verse.StartRef);
                Assert.AreEqual(01001001, verse.EndRef);
                Assert.IsFalse(verseSet.MoveNext());
            }
        }
Beispiel #7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Helper method for verifying a ScrVerse.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public static void VerifyScrVerse(ScrVerse scrVerse, IScrTxtPara para, int startRef, int endRef,
                                          string verseText, int iVerseStart, bool fIsChapter, bool fIsHeading, int iSection)
        {
            Assert.AreEqual(para, scrVerse.Para);
            Assert.AreEqual(startRef, scrVerse.StartRef);
            Assert.AreEqual(endRef, scrVerse.EndRef);
            Assert.AreEqual(verseText, scrVerse.Text.Text);
            Assert.AreEqual(iVerseStart, scrVerse.VerseStartIndex);
            Assert.AreEqual(fIsChapter, scrVerse.ChapterNumberRun);
            // check the ParaNodeMap too
            Assert.AreEqual(ScrBookTags.kflidSections, scrVerse.ParaNodeMap.BookFlid);
            Assert.AreEqual(iSection, scrVerse.ParaNodeMap.SectionIndex);
            Assert.AreEqual(fIsHeading ? ScrSectionTags.kflidHeading :
                            ScrSectionTags.kflidContent, scrVerse.ParaNodeMap.SectionFlid);
            Assert.AreEqual(0, scrVerse.ParaNodeMap.ParaIndex);
            ParaNodeMap map = new ParaNodeMap(para);

            Assert.IsTrue(map.Equals(scrVerse.ParaNodeMap));
        }
Beispiel #8
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());
        }
Beispiel #9
0
        public void VerseIterator_InitialText()
        {
            // Create section 1 for Genesis.
            IScrSection section1 = CreateSection(m_genesis, "My aching head!", 01001001, 01001001);

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

            paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
            paraBldr.AppendRun("Some initial text. ",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            paraBldr.AppendRun("5-6", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
                                                                    Cache.DefaultVernWs));
            paraBldr.AppendRun("Verses 5-6.",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            IScrTxtPara hvoS1Para = (IScrTxtPara)paraBldr.CreateParagraph(section1.ContentOA);


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

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

            Assert.AreEqual(hvoS1Para, scrVerse.Para);
            Assert.AreEqual(01001001, scrVerse.StartRef);
            Assert.AreEqual(01001001, scrVerse.EndRef);
            Assert.AreEqual("Some initial text. ", scrVerse.Text.Text);
            Assert.AreEqual(0, scrVerse.VerseStartIndex);

            scrVerse = m_bookMerger.NextVerseInStText();
            Assert.AreEqual(hvoS1Para, scrVerse.Para);
            Assert.AreEqual(01001005, scrVerse.StartRef);
            Assert.AreEqual(01001006, scrVerse.EndRef);
            Assert.AreEqual("5-6Verses 5-6.", scrVerse.Text.Text);
            Assert.AreEqual(19, scrVerse.VerseStartIndex);

            Assert.IsNull(m_bookMerger.NextVerseInStText());
        }
Beispiel #10
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());
        }
Beispiel #11
0
			/// --------------------------------------------------------------------------------
			/// <summary>
			/// Constructor for an OverlapInfo proxy for a ScrVerse.
			/// Initializes a new instance of the <see cref="OverlapInfo"/> class.
			/// </summary>
			/// <param name="verse">The ScrVerse.</param>
			/// <param name="bookType">Type of the book (current or revision).</param>
			/// <param name="indexInList">The index of the ScrVerse in its owning list.</param>
			/// --------------------------------------------------------------------------------
			public OverlapInfo(ScrVerse verse, int bookType, int indexInList)
			{
				// Set the max and the min to that supplied by our caller
				verseRefMin = verse.StartRef;
				verseRefMax = verse.EndRef;
				// for a chapter number ScrVerse, we will fudge the oi's ref to verse zero,
				// so that the chapter number oi's will form their own cluster. We do this to
				// avoid confusing it with the actual verse one oi's.

				// so that the chapter number oi's will form their own cluster, without
				// confusing it with the actual verse one oi's
				if (verse.ChapterNumberRun)
				{
					verseRefMin.Verse = 0;
					verseRefMax.Verse = 0;
				}

				// Set the type
				myBook = bookType;
				// set the index
				indexInOwner = indexInList;
				// set the hvo
				myHvo = verse.HvoPara;
				// set the hvo of the owning StText
				myParaOwner = verse.HvoParaOwner;
				// set whether the ScrVerse is from an empty paragraph
				isStanzaBreak = verse.IsStanzaBreak;
				// the overlap list should be created when needed
				overlappedItemsInOther = null;
			}
Beispiel #12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="DiffLocation"/> class that covers an
		/// entire Scripture verse.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		internal DiffLocation(ScrVerse scrVerse) : this(scrVerse.Para, scrVerse.VerseStartIndex)
		{
			if (scrVerse.Text != null)
				IchLim = IchMin + scrVerse.TextLength;
		}
Beispiel #13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Helper method for verifying a ScrVerse.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public static void VerifyScrVerse(ScrVerse scrVerse, IScrTxtPara para, int startRef, int endRef,
			string verseText, int iVerseStart, bool fIsChapter, bool fIsHeading, int iSection)
		{
			Assert.AreEqual(para, scrVerse.Para);
			Assert.AreEqual(startRef, scrVerse.StartRef);
			Assert.AreEqual(endRef, scrVerse.EndRef);
			Assert.AreEqual(verseText, scrVerse.Text.Text);
			Assert.AreEqual(iVerseStart, scrVerse.VerseStartIndex);
			Assert.AreEqual(fIsChapter, scrVerse.ChapterNumberRun);
			// check the ParaNodeMap too
			Assert.AreEqual(ScrBookTags.kflidSections, scrVerse.ParaNodeMap.BookFlid);
			Assert.AreEqual(iSection, scrVerse.ParaNodeMap.SectionIndex);
			Assert.AreEqual(fIsHeading ? ScrSectionTags.kflidHeading :
				ScrSectionTags.kflidContent, scrVerse.ParaNodeMap.SectionFlid);
			Assert.AreEqual(0, scrVerse.ParaNodeMap.ParaIndex);
			ParaNodeMap map = new ParaNodeMap(para);
			Assert.IsTrue(map.Equals(scrVerse.ParaNodeMap));
		}
Beispiel #14
0
		/// -----------------------------------------------------------------------------------
		///<summary>
		/// Verify the specified ScrVerse
		///</summary>
		///<param name="verse">specified ScrVerse</param>
		///<param name="verseText">expected text within the ScrVerse</param>
		///<param name="styleName">expected stylename for the ScrVerse paragraph</param>
		///<param name="startRef">expected starting reference</param>
		///<param name="endRef">expected ending reference</param>
		/// -----------------------------------------------------------------------------------
		public static void VerifyScrVerse(ScrVerse verse, string verseText, string styleName,
					BCVRef startRef, BCVRef endRef)
		{
			IScrTxtPara versePara = verse.Para;
			if (string.IsNullOrEmpty(verseText))
				Assert.IsTrue(verse.Text == null || string.IsNullOrEmpty(verse.Text.Text));
			else
				Assert.AreEqual(verseText, verse.Text.Text);
			Assert.AreEqual(styleName, versePara.StyleName);
			Assert.AreEqual(startRef, verse.StartRef);
			Assert.AreEqual(endRef, verse.EndRef);
		}
Beispiel #15
0
		/// --------------------------------------------------------------------------------
		/// <summary>
		/// Constructor for an OverlapInfo proxy for a ScrVerse.
		/// Initializes a new instance of the <see cref="OverlapInfo"/> class.
		/// </summary>
		/// <param name="verse">The ScrVerse.</param>
		/// <param name="isRevisionBook">Type of the book (current or revision).</param>
		/// <param name="indexInList">The index of the ScrVerse in its owning list.</param>
		/// --------------------------------------------------------------------------------
		public OverlapInfo(ScrVerse verse, bool isRevisionBook, int indexInList)
		{
			// Set the max and the min to that supplied by our caller
			verseRefMin = verse.StartRef;
			verseRefMax = verse.EndRef;

			// Set the type
			bookIsFromRev = isRevisionBook;
			// set the index
			indexInOwner = indexInList;
			// set the hvo
			myObj = verse.Para;
			// set the hvo of the owning StText
			myParaOwner = verse.ParaOwner;
			// set whether the ScrVerse is from an empty paragraph
			isStanzaBreak = verse.IsStanzaBreak;
			// the overlap list should be created when needed
			overlappedItemsInOther = null;
		}
Beispiel #16
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets Scripture reference for a selection
        /// </summary>
        /// <param name="helper">The selection helper that represents the selection</param>
        /// <param name="fInclusive"><c>true</c> if the reference returned should include the
        /// reference of the text of the verse where the selection is, even if that selection
        /// is not at the start of the verse; <c>false</c> if the reference should be that of
        /// the first full verse at or following the selection</param>
        /// <param name="scriptureRef">returns the scripture reference found</param>
        /// <returns>A TsString representing the reference of the selection, or null if the
        /// selection represents a book title or something weird.</returns>
        /// ------------------------------------------------------------------------------------
        private ITsString GetSelectionReference(SelectionHelper helper, bool fInclusive,
                                                out BCVRef scriptureRef)
        {
            scriptureRef = new BCVRef();
            if (helper != null && m_page.Publication != null && m_page.Publication is ScripturePublication)
            {
                int iParaLevel = helper.GetLevelForTag(StTextTags.kflidParagraphs);
                if (iParaLevel >= 0)
                {
                    int         hvo  = helper.LevelInfo[iParaLevel].hvo;
                    IScrTxtPara para =
                        m_cache.ServiceLocator.GetInstance <IScrTxtParaRepository>().GetObject(hvo);
                    // Look through the verses of the paragraph until we pass the location
                    // where the page break occurs. This verse reference will then be the
                    // first one on the page.
                    ScrVerse firstVerseOnPage = null;
                    int      ichPageBreak     = helper.IchAnchor;
                    foreach (ScrVerse verse in para)
                    {
                        if (!fInclusive)
                        {
                            firstVerseOnPage = verse;
                        }
                        if (verse.VerseStartIndex > ichPageBreak ||
                            (verse.VerseStartIndex == ichPageBreak && !fInclusive))
                        {
                            break;
                        }
                        if (fInclusive)
                        {
                            firstVerseOnPage = verse;
                        }
                    }

                    ITsString tssBookName = GetBookName(helper);
                    if (tssBookName != null)
                    {
                        ITsStrBldr bldr = tssBookName.GetBldr();
                        int        cch  = bldr.Length;
                        if (firstVerseOnPage != null)
                        {
                            if (firstVerseOnPage.StartRef.Verse != 0)
                            {
                                bldr.Replace(cch, cch,
                                             " " + m_scr.ChapterVerseRefAsString(firstVerseOnPage.StartRef),
                                             null);
                            }
                            scriptureRef = firstVerseOnPage.StartRef;
                        }
                        return(bldr.GetString());
                    }
                    //else
                    //{
                    //    // Probably no verses were found in the paragraph
                    //    IVwSelection sel = FindNextPara(helper);
                    //    helper = SelectionHelper.Create(sel, helper.RootSite);

                    //    return GetSelectionReference(helper, fInclusive, out scriptureRef);
                    //}
                }
            }
            return(null);
        }
Beispiel #17
0
		/// -----------------------------------------------------------------------------------
		///<summary>
		/// Verify the specified ScrVerse
		///</summary>
		///<param name="verse">specified ScrVerse</param>
		///<param name="cache">database</param>
		///<param name="verseText">expected text within the ScrVerse</param>
		///<param name="styleName">expected stylename for the ScrVerse paragraph</param>
		///<param name="startRef">expected starting reference</param>
		///<param name="endRef">expected ending reference</param>
		/// -----------------------------------------------------------------------------------
		public static void VerifyScrVerse(ScrVerse verse, FdoCache cache, string verseText,
						string styleName, BCVRef startRef, BCVRef endRef)
		{
			ScrTxtPara versePara = new ScrTxtPara(cache, verse.HvoPara);
			if (string.IsNullOrEmpty(verseText))
				Assert.IsTrue(verse.Text == null || string.IsNullOrEmpty(verse.Text.Text));
			else
				Assert.AreEqual(verseText, verse.Text.Text);
			Assert.AreEqual(styleName, ScrStyleNames.GetStyleName(versePara.Hvo, cache));
			Assert.AreEqual(startRef, verse.StartRef);
			Assert.AreEqual(endRef, verse.EndRef);
		}
Beispiel #18
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates a new ParaNodeMap containing the location information that
		/// can be extracted from this ScrVerse (namely whether it is in a title
		/// or section, what section is lives in, whether that section is a heading
		/// or content section, which paragraph it is within that section, and the character
		/// offset in the paragraph)
		/// </summary>
		/// <param name="verse">The given ScrVerse.</param>
		/// <param name="cache">The cache.</param>
		/// ------------------------------------------------------------------------------------
		public ParaNodeMap(ScrVerse verse, FdoCache cache)
		{
			// Get para containing the ScrVerse and
			StTxtPara para = new StTxtPara(cache, verse.HvoPara);
			ConstructFromPara(para);

			// Add character offset of ScrVerse
			m_location[kCharIndex] = verse.VerseStartIndex;
		}
Beispiel #19
0
        public void VerseIterator()
        {
            // 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));
            paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
                                                                  Cache.DefaultVernWs));
            paraBldr.AppendRun("Verse 2. ",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            paraBldr.AppendRun("3-4", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
                                                                    Cache.DefaultVernWs));
            paraBldr.AppendRun("Verse 3-4.",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            IScrTxtPara hvoS1Para = (IScrTxtPara)paraBldr.CreateParagraph(section1.ContentOA);


            // Create an iterator to test heading
            m_bookMerger.CreateVerseIteratorForStText(section1.HeadingOA);

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

            Assert.AreEqual(section1.HeadingOA[0], scrVerse.Para);
            Assert.AreEqual(01002001, scrVerse.StartRef);
            Assert.AreEqual(01002001, scrVerse.EndRef);
            Assert.AreEqual("My aching head!", scrVerse.Text.Text);
            Assert.AreEqual(0, scrVerse.VerseStartIndex);

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

            // Create an iterator to test content
            m_bookMerger.CreateVerseIteratorForStText(section1.ContentOA);

            // Verify section 1 content
            scrVerse = m_bookMerger.NextVerseInStText();
            Assert.AreEqual(hvoS1Para, scrVerse.Para);
            Assert.AreEqual(01002001, scrVerse.StartRef);
            Assert.AreEqual(01002001, scrVerse.EndRef);
            Assert.AreEqual("2Verse 1. ", scrVerse.Text.Text);
            Assert.AreEqual(0, scrVerse.VerseStartIndex);
            Assert.AreEqual(1, scrVerse.TextStartIndex);

            scrVerse = m_bookMerger.NextVerseInStText();
            Assert.AreEqual(01002002, scrVerse.StartRef);
            Assert.AreEqual(01002002, scrVerse.EndRef);
            Assert.AreEqual("2Verse 2. ", scrVerse.Text.Text);
            Assert.AreEqual(10, scrVerse.VerseStartIndex);

            scrVerse = m_bookMerger.NextVerseInStText();
            Assert.AreEqual(01002003, scrVerse.StartRef);
            Assert.AreEqual(01002004, scrVerse.EndRef);
            Assert.AreEqual("3-4Verse 3-4.", scrVerse.Text.Text);
            Assert.AreEqual(20, scrVerse.VerseStartIndex);

            // Verify there are no more scrVerses
            scrVerse = m_bookMerger.NextVerseInStText();
            Assert.IsNull(scrVerse);
        }
Beispiel #20
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);
        }