public void Clone() { IScrTxtPara[] paras = DiffTestHelper.CreateDummyParas(2, Cache); Difference diff = new Difference( new ScrReference(1, 1, 1, ScrVers.English), new ScrReference(1, 1, 30, ScrVers.English), paras[0], 1, 99, paras[1], 11, 88, DifferenceType.PictureDifference, null, null, "Whatever", "Whateverelse", "Esperanto", "Latvian", null, null); //diff.SectionsCurr = new int[] {6, 7, 8}; Difference clonedDiff = diff.Clone(); Assert.AreEqual(1001001, clonedDiff.RefStart); Assert.AreEqual(1001030, clonedDiff.RefEnd); Assert.AreSame(paras[0], clonedDiff.ParaCurr); Assert.AreEqual(1, clonedDiff.IchMinCurr); Assert.AreEqual(99, clonedDiff.IchLimCurr); Assert.AreSame(paras[1], clonedDiff.ParaRev); Assert.AreEqual(11, clonedDiff.IchMinRev); Assert.AreEqual(88, clonedDiff.IchLimRev); //Assert.AreEqual(987654321, clonedDiff.hvoAddedSection); Assert.AreEqual(DifferenceType.PictureDifference, clonedDiff.DiffType); Assert.IsNull(clonedDiff.SubDiffsForParas); Assert.IsNull(clonedDiff.SubDiffsForORCs); Assert.AreEqual("Whatever", clonedDiff.StyleNameCurr); Assert.AreEqual("Whateverelse", clonedDiff.StyleNameRev); Assert.AreEqual("Esperanto", clonedDiff.WsNameCurr); Assert.AreEqual("Latvian", clonedDiff.WsNameRev); }
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()); }
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()); }
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()); }
public void Clone_WithSubDiffs() { IScrTxtPara[] paras = DiffTestHelper.CreateDummyParas(8, Cache); Difference subSubDiff = new Difference( new ScrReference(1, 1, 3, ScrVers.English), new ScrReference(1, 1, 30, ScrVers.English), paras[0], 0, 99, paras[1], 11, 88, DifferenceType.PictureDifference, null, null, "Whatever", "Whateverelse", "Esperanto", "Latvian", null, null); Difference subDiff1 = new Difference( new ScrReference(1, 1, 2, ScrVers.English), new ScrReference(1, 1, 30, ScrVers.English), paras[2], 0, 99, paras[3], 11, 88, DifferenceType.PictureDifference, new List <Difference>(new Difference[] { subSubDiff }), new List <Difference>(new Difference[] { subSubDiff }), "Whatever", "Whateverelse", "Esperanto", "Latvian", null, null); Difference subDiff2 = new Difference( new ScrReference(1, 1, 4, ScrVers.English), new ScrReference(1, 1, 30, ScrVers.English), paras[4], 0, 99, paras[5], 11, 88, DifferenceType.PictureDifference, null, null, "Whatever", "Whateverelse", "Esperanto", "Latvian", null, null); Difference diff = new Difference( new ScrReference(1, 1, 1, ScrVers.English), new ScrReference(1, 1, 30, ScrVers.English), paras[6], 0, 99, paras[7], 11, 88, DifferenceType.PictureDifference, new List <Difference>(new Difference[] { subDiff1, subDiff2 }), new List <Difference>(new Difference[] { subDiff1, subDiff2 }), "Whatever", "Whateverelse", "Esperanto", "Latvian", null, null); Difference clonedDiff = diff.Clone(); Assert.AreEqual(2, clonedDiff.SubDiffsForORCs.Count); Assert.AreEqual(1, clonedDiff.SubDiffsForORCs[0].SubDiffsForORCs.Count); Assert.IsNull(clonedDiff.SubDiffsForORCs[1].SubDiffsForORCs); Assert.IsNull(clonedDiff.SubDiffsForORCs[0].SubDiffsForORCs[0].SubDiffsForORCs); Assert.AreEqual(2, clonedDiff.SubDiffsForParas.Count); Assert.AreEqual(1, clonedDiff.SubDiffsForParas[0].SubDiffsForParas.Count); Assert.IsNull(clonedDiff.SubDiffsForParas[1].SubDiffsForParas); Assert.IsNull(clonedDiff.SubDiffsForParas[0].SubDiffsForParas[0].SubDiffsForParas); }
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"); }
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()); }
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); }