/// ------------------------------------------------------------------------------------ /// <summary> /// Create test data /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_matthew = m_scrInMemoryCache.AddBookToMockedScripture(40, "Matthews"); m_philemon = m_scrInMemoryCache.AddBookToMockedScripture(57, "Philemon"); m_scrInMemoryCache.AddTitleToMockedBook(m_philemon.Hvo, "Philemon"); m_inMemoryCache.InitializeWritingSystemEncodings(); // Initialize Philemon with intro and scripture sections IScrSection section = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_philemon.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "Intro1", ScrStyleNames.IntroSectionHead); StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "some intro text", null); section.AdjustReferences(); section = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_philemon.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "Intro2", ScrStyleNames.IntroSectionHead); para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "some more intro text", null); section.AdjustReferences(); // intro ends // normal scripture section = m_scrInMemoryCache.AddSectionToMockedBook(m_philemon.Hvo); para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "Scripture1", ScrStyleNames.SectionHead); m_scrInMemoryCache.AddRunToMockedPara(para, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); m_scrInMemoryCache.AddRunToMockedPara(para, "2", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); m_scrInMemoryCache.AddRunToMockedPara(para, "3-5", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); section.AdjustReferences(); section = m_scrInMemoryCache.AddSectionToMockedBook(m_philemon.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "Scripture2", ScrStyleNames.SectionHead); para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "6", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); m_scrInMemoryCache.AddRunToMockedPara(para, "7", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); section.AdjustReferences(); }
public void IsDataLossDifference_VerseAdded() { // Create a Current with two verses IScrSection sectionCur1 = m_scrInMemoryCache.AddSectionToMockedBook(m_genesis.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(sectionCur1.Hvo, "Section 1", ScrStyleNames.SectionHead); StTxtPara para1Cur = AddPara(sectionCur1); AddVerse(para1Cur, 1, 0, "Verse one. "); AddVerse(para1Cur, 0, 2, "Verse two."); sectionCur1.AdjustReferences(); // Create a Revision with only one section IScrSection sectionRev1 = m_scrInMemoryCache.AddSectionToMockedBook(m_genesisRevision.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(sectionRev1.Hvo, "Section 1", ScrStyleNames.SectionHead); StTxtPara para1Rev = AddPara(sectionRev1); AddVerse(para1Rev, 1, 0, "Verse one. "); sectionRev1.AdjustReferences(); m_bookMerger.DetectDifferences(null); // We expect that we would have one difference: a ParagraphAdded difference which should be // a data loss difference. Assert.AreEqual(1, m_bookMerger.Differences.Count); Difference diff = m_bookMerger.Differences.MoveFirst(); Assert.AreEqual(DifferenceType.VerseAddedToCurrent, diff.DiffType); Assert.IsTrue(m_bookMerger.IsDataLossDifference(diff)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create test data in a right-to-left script. /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { // Set the default writing system to a right-to-left writing system (Urdu) m_wsUrdu = InMemoryFdoCache.s_wsHvos.Ur; m_scrInMemoryCache.ChangeDefaultVernWs(m_wsUrdu); LgWritingSystem defWs = new LgWritingSystem(Cache, Cache.DefaultVernWs); // Add basic data for Genesis m_genesis = m_scrInMemoryCache.AddBookToMockedScripture(1, "Genesis"); m_scrInMemoryCache.AddTitleToMockedBook(1, m_StartText); IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_genesis.Hvo); StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, null); m_scrInMemoryCache.AddFormatTextToMockedPara(m_genesis, para, @"\c12\v13-14\*" + m_WordsText, m_wsUrdu); section.AdjustReferences(); // Add footnote ITsTextProps normalFootnoteParaProps = StyleUtils.ParaStyleTextProps(ScrStyleNames.NormalFootnoteParagraph); StFootnote footnote = m_scrInMemoryCache.AddFootnote(m_genesis, para, 10); StTxtPara footPara = new StTxtPara(); footnote.ParagraphsOS.Append(footPara); footPara.StyleRules = normalFootnoteParaProps; ITsStrFactory strfact = TsStrFactoryClass.Create(); footPara.Contents.UnderlyingTsString = strfact.MakeString(m_WordsText, m_wsUrdu); }
public void UserPromptForSectionHeadWithEmptyPara() { CheckDisposed(); // Set up section head with an empty paragraph IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo); StTxtPara para = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "", ScrStyleNames.SectionHead); section.AdjustReferences(); Options.ShowEmptyParagraphPromptsSetting = true; DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultVernWs); CreateExpectedUserPrompt(stVc, para.Hvo, (int)ScrSection.ScrSectionTags.kflidHeading, (int)StTxtPara.StTxtParaTags.kflidContents); IVwEnv vwEnv = (IVwEnv)m_vwenvMock.MockInstance; bool fTextAdded = stVc.CallInsertUserPrompt(vwEnv, para.Hvo); Assert.IsTrue(fTextAdded, "User prompt not added"); ITsString text = stVc.DisplayVariant(vwEnv, SimpleRootSite.kTagUserPrompt, null, (int)ScrSection.ScrSectionTags.kflidHeading); string difference; bool fEqual = TsStringHelper.TsStringsAreEqual( ExpectedUserPrompt("Type section head here", m_inMemoryCache.Cache.DefaultVernWs), text, out difference); Assert.IsTrue(fEqual, difference); m_vwenvMock.Verify(); }
public void NoUserPromptForBTWithEmptyPara() { CheckDisposed(); // Set up a section and empty paragraph IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo); StTxtPara para = m_inMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); section.AdjustReferences(); // Add an empty translation to the paragraph int wsBT = m_inMemoryCache.Cache.DefaultAnalWs; ICmTranslation trans = m_inMemoryCache.AddBtToMockedParagraph(para, wsBT); m_inMemoryCache.AddRunToMockedTrans(trans, wsBT, string.Empty, null); DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultAnalWs); m_vwenvMock.ExpectNoCall("NoteDependency", new string[] { typeof(int[]).FullName, typeof(int[]).FullName, typeInt }); m_vwenvMock.ExpectNoCall("AddProp", new string[] { typeInt, typeof(IVwViewConstructor).FullName, typeInt }); // verify that the prompt does not get added IVwEnv vwEnv = (IVwEnv)m_vwenvMock.MockInstance; bool fTextAdded = stVc.CallInsertBackTranslationUserPrompt(vwEnv, trans.Hvo); Assert.IsFalse(fTextAdded, "User prompt was added and should not have been"); // verify the mock m_vwenvMock.Verify(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a book with 2 sections with the following layout: /// bookName /// Heading 1 /// (1)1Verse one. /// Heading 2 /// (2)1Verse one.2Verse two. /// (3)1Verse one. /// /// Numbers in () are chapter numbers. /// </summary> /// <returns>the book for testing</returns> /// ------------------------------------------------------------------------------------ protected IScrBook CreateBook(int nBookNumber, string bookName) { IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(nBookNumber, bookName); m_scrInMemoryCache.AddTitleToMockedBook(book.Hvo, bookName); IScrSection section1 = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section1.Hvo, "Heading 1", ScrStyleNames.SectionHead); StTxtPara para11 = m_scrInMemoryCache.AddParaToMockedSectionContent(section1.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para11, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para11, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para11, "Verse one.", null); section1.AdjustReferences(); IScrSection section2 = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section2.Hvo, "Heading 2", ScrStyleNames.SectionHead); StTxtPara para21 = m_scrInMemoryCache.AddParaToMockedSectionContent(section2.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para21, "2", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para21, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para21, "Verse one.", null); m_scrInMemoryCache.AddRunToMockedPara(para21, "2", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para21, "Verse two.", null); StTxtPara para22 = m_scrInMemoryCache.AddParaToMockedSectionContent(section2.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para22, "3", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para22, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para22, "Verse one.", null); section2.AdjustReferences(); return(book); }
public void AdjustReferences_ChapterOutOfOrder() { CheckDisposed(); // add section and paragraph IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_matthew.Hvo); StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "2", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); m_scrInMemoryCache.AddRunToMockedPara(para, "2", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); m_scrInMemoryCache.AddRunToMockedPara(para, "3", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); m_scrInMemoryCache.AddRunToMockedPara(para, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); m_scrInMemoryCache.AddRunToMockedPara(para, "2", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); m_scrInMemoryCache.AddRunToMockedPara(para, "3", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "some text", null); section.AdjustReferences(); // Check the section references and squawk if wrong VerifySectionRefs(section, 40002001, 40001003, 40001001, 40002003); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { ITsStrFactory strfact = TsStrFactoryClass.Create(); //Jude IScrBook jude = m_scrInMemoryCache.AddBookToMockedScripture(65, "Jude"); m_scrInMemoryCache.AddTitleToMockedBook(jude.Hvo, "Jude"); // Jude Scripture section IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(jude.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "First section", "Section Head"); StTxtPara judePara = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, "Paragraph"); m_scrInMemoryCache.AddRunToMockedPara(judePara, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(judePara, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(judePara, "This is the first verse", null); // Insert footnote into para 1 of Jude ITsStrBldr bldr = judePara.Contents.UnderlyingTsString.GetBldr(); StFootnote foot = ScrFootnote.InsertFootnoteAt(jude, 0, bldr, 10, "#"); StTxtPara footPara = new StTxtPara(); foot.ParagraphsOS.Append(footPara); footPara.StyleRules = StyleUtils.ParaStyleTextProps(ScrStyleNames.NormalFootnoteParagraph); footPara.Contents.UnderlyingTsString = strfact.MakeString("This is text for the footnote.", Cache.DefaultVernWs); judePara.Contents.UnderlyingTsString = bldr.GetString(); section.AdjustReferences(); }
public void IsDataLossDifference_ParaAdded_MidVerse() { IScrSection sectionCur0 = m_scrInMemoryCache.AddSectionToMockedBook(m_genesis.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(sectionCur0.Hvo, "Section 0", ScrStyleNames.SectionHead); StTxtPara para0aCur = AddPara(sectionCur0); AddVerse(para0aCur, 1, 0, "Here is the very first section."); StTxtPara para0bCur = AddPara(sectionCur0); AddVerse(para0bCur, 0, 0, "This is an added paragraph that would be data loss if reverted."); sectionCur0.AdjustReferences(); IScrSection sectionRev0 = m_scrInMemoryCache.AddSectionToMockedBook(m_genesisRevision.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(sectionRev0.Hvo, "Section 0", ScrStyleNames.SectionHead); StTxtPara para0Rev = AddPara(sectionRev0); AddVerse(para0Rev, 1, 0, "Here is the very first section."); sectionRev0.AdjustReferences(); m_bookMerger.DetectDifferences(null); // Expect 1 difference: ParagraphSplitInCurrent difference would cause data loss. // This diff should be ParagraphAddedInCurrent, but is constrained by TE-7334. Assert.AreEqual(1, m_bookMerger.Differences.Count); Difference diff0 = m_bookMerger.Differences.MoveFirst(); Assert.AreEqual(DifferenceType.ParagraphSplitInCurrent, diff0.DiffType); Assert.IsTrue(m_bookMerger.IsDataLossDifference(diff0)); }
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()); }
public void DeleteFootnoteMarkerInBt_ContextMenu() { CheckDisposed(); IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(2, "Exodus"); m_scrInMemoryCache.AddTitleToMockedBook(book.Hvo, "Exodus"); m_btDraftView.BookFilter.Insert(0, book.Hvo); IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "The first section", ScrStyleNames.SectionHead); // Construct a parent paragraph StTxtPara parentPara = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(parentPara, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(parentPara, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(parentPara, "uno ", null); m_scrInMemoryCache.AddRunToMockedPara(parentPara, "2", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(parentPara, "dos ", null); StFootnote footnote1 = m_scrInMemoryCache.AddFootnote(book, parentPara, 5); m_scrInMemoryCache.AddParaToMockedText(footnote1.Hvo, ScrStyleNames.NormalFootnoteParagraph); StFootnote footnote2 = m_scrInMemoryCache.AddFootnote(book, parentPara, 10); m_scrInMemoryCache.AddParaToMockedText(footnote2.Hvo, ScrStyleNames.NormalFootnoteParagraph); Guid guid1 = footnote1.Guid; Guid guid2 = footnote2.Guid; Assert.AreEqual(2, book.FootnotesOS.Count); section.AdjustReferences(); // Construct the initial back translation int wsBt = m_inMemoryCache.Cache.DefaultAnalWs; ICmTranslation trans = m_inMemoryCache.AddBtToMockedParagraph(parentPara, wsBt); m_inMemoryCache.AddRunToMockedTrans(trans, wsBt, "one two", null); ITsStrBldr btTssBldr = trans.Translation.GetAlternative(wsBt).UnderlyingTsString.GetBldr(); footnote1.InsertRefORCIntoTrans(btTssBldr, 3, wsBt); footnote2.InsertRefORCIntoTrans(btTssBldr, 8, wsBt); trans.Translation.SetAlternative(btTssBldr.GetString(), wsBt); SelectionHelper selHelper = m_btDraftView.SetInsertionPoint(0, 0, 0, 3, false); //set the IP // Delete the marker for the back translation of the first footnote m_btDraftView.OnDeleteFootnote(); // Verify that both original footnotes still exist and that the first BT footnote marker is // deleted. Assert.AreEqual(2, book.FootnotesOS.Count); VerifyFootnote(footnote1, parentPara, 5); VerifyFootnote(footnote2, parentPara, 10); Assert.AreEqual("one two" + StringUtils.kchObject, trans.Translation.GetAlternative(wsBt).UnderlyingTsString.Text); StTxtParaTests.VerifyBtFootnote(footnote2, parentPara, wsBt, 7); }
public void EnterKey_InBtSectionHead() { CheckDisposed(); IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(2, "Exodus"); m_scrInMemoryCache.AddTitleToMockedBook(book.Hvo, "Exodus"); m_btDraftView.BookFilter.Insert(0, book.Hvo); IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo); StTxtPara headPara = m_scrInMemoryCache.AddSectionHeadParaToSection( section.Hvo, "The first section", ScrStyleNames.SectionHead); // Construct a parent paragraph StTxtPara parentPara = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(parentPara, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(parentPara, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(parentPara, "uno ", null); section.AdjustReferences(); // Construct the initial back translation. int wsBt = m_inMemoryCache.Cache.DefaultAnalWs; ICmTranslation headingTrans = m_inMemoryCache.AddBtToMockedParagraph(headPara, wsBt); m_inMemoryCache.AddRunToMockedTrans(headingTrans, wsBt, "BT heading", ScrStyleNames.Header); ICmTranslation paraTrans = m_inMemoryCache.AddBtToMockedParagraph(parentPara, wsBt); m_inMemoryCache.AddRunToMockedTrans(paraTrans, wsBt, "one", null); // Set the following style for section head. IStStyle styleHead = m_scr.FindStyle(ScrStyleNames.SectionHead); IStStyle stylePara = m_scr.FindStyle(ScrStyleNames.NormalParagraph); styleHead.NextRA = stylePara; // Set IP at the end of the section head. int sectionHeadLength = headingTrans.Translation.GetAlternativeTss(wsBt).Length; m_btDraftView.TeEditingHelper.SetInsertionPoint( (int)ScrSection.ScrSectionTags.kflidHeading, 0, 0, 0, sectionHeadLength, false); m_btDraftView.OnKeyPress(new KeyPressEventArgs('\r')); // Verify that the selection has moved to the start of the BT of the section Content. IVwSelection vwsel = m_btDraftView.RootBox.Selection; int ich, hvo, textTag, enc; bool fAssocPrev; ITsString tss; vwsel.TextSelInfo(false, out tss, out ich, out fAssocPrev, out hvo, out textTag, out enc); Assert.AreEqual((int)CmTranslation.CmTranslationTags.kflidTranslation, textTag); Assert.AreEqual(paraTrans.Hvo, hvo, "Current paragraph should be content following section head."); Assert.AreEqual(0, ich); // selection is at start of paragraph }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds a section with references in the specified book. /// </summary> /// <param name="book">The book.</param> /// <param name="startChapter">The start chapter.</param> /// <param name="firstVerse">The first verse.</param> /// <param name="endChapter">The end chapter.</param> /// <param name="lastVerse">The last verse.</param> /// ------------------------------------------------------------------------------------ private void AddSection(IScrBook book, int startChapter, int firstVerse, int endChapter, int lastVerse) { IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo); StTxtPara para = AddPara(section); AddVerse(para, startChapter, firstVerse, "verse " + firstVerse.ToString() + ". "); AddVerse(para, (endChapter > startChapter) ? endChapter : 0, lastVerse, "verse " + lastVerse.ToString() + ". "); section.AdjustReferences(); }
public void IsDataLossDifference_VerseMoved() { // Set up the three curr sections IScrSection section0Curr = CreateSection(m_genesis, "Section Zilch"); StTxtPara para0Curr = AddPara(section0Curr); AddVerse(para0Curr, 0, "1-2", string.Empty); section0Curr.AdjustReferences(); IScrSection section1Curr = CreateSection(m_genesis, "Section Uno"); StTxtPara para1Curr = AddPara(section1Curr); AddVerse(para1Curr, 0, 3, "tres "); AddVerse(para1Curr, 0, 9, "nueve "); AddVerse(para1Curr, 0, 10, "diez "); section1Curr.AdjustReferences(); IScrSection section2Curr = CreateSection(m_genesis, "Section Dos"); StTxtPara para2Curr = AddPara(section2Curr); AddVerse(para2Curr, 0, 12, "doce "); AddVerse(para2Curr, 0, 20, "vente "); section2Curr.AdjustReferences(); // Set up two revision sections IScrSection section0Rev = CreateSection(m_genesisRevision, "Section Zilch"); StTxtPara para0Rev = AddPara(section0Rev); AddVerse(para0Rev, 0, "1-2", string.Empty); section0Rev.AdjustReferences(); IScrSection section1Rev = CreateSection(m_genesisRevision, "Section Ek"); StTxtPara para1Rev = AddPara(section1Rev); AddVerse(para1Rev, 0, 10, "diez "); AddVerse(para1Rev, 0, 12, "doce "); AddVerse(para1Rev, 0, 20, "vente "); section1Rev.AdjustReferences(); // find the diffs for Genesis m_bookMerger.DetectDifferences(null); // We expect two diffs: SectionAdded (containing a VerseMoved) and a TextDifference Assert.AreEqual(2, m_bookMerger.Differences.Count); Difference diff0 = m_bookMerger.Differences.MoveFirst(); Difference diff1 = m_bookMerger.Differences.MoveNext(); Assert.AreEqual(DifferenceType.SectionAddedToCurrent, diff0.DiffType); Assert.AreEqual(DifferenceType.TextDifference, diff1.DiffType); // We expect both the differences to not be data loss differences. Assert.IsFalse(m_bookMerger.IsDataLossDifference(diff0)); Assert.IsFalse(m_bookMerger.IsDataLossDifference(diff1)); }
public void InsertFootnote_InBt() { CheckDisposed(); IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(2, "Exodus"); m_scrInMemoryCache.AddTitleToMockedBook(book.Hvo, "Exodus"); m_btDraftView.BookFilter.Insert(0, book.Hvo); IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "The first section", ScrStyleNames.SectionHead); // Construct a parent paragraph in the vernacular. StTxtPara parentPara = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); AddVerse(parentPara, 1, 1, "uno"); AddVerse(parentPara, 0, 2, "dos"); StFootnote footnote1 = m_scrInMemoryCache.AddFootnote(book, parentPara, 5); m_scrInMemoryCache.AddParaToMockedText(footnote1.Hvo, ScrStyleNames.NormalFootnoteParagraph); StFootnote footnote2 = m_scrInMemoryCache.AddFootnote(book, parentPara, 10); m_scrInMemoryCache.AddParaToMockedText(footnote2.Hvo, ScrStyleNames.NormalFootnoteParagraph); Assert.AreEqual(2, book.FootnotesOS.Count); section.AdjustReferences(); // Construct the initial back translation int wsBt = m_inMemoryCache.Cache.DefaultAnalWs; ICmTranslation trans = m_inMemoryCache.AddBtToMockedParagraph(parentPara, wsBt); m_inMemoryCache.AddRunToMockedTrans(trans, wsBt, "one two", null); ITsStrBldr btTssBldr = trans.Translation.GetAlternative(wsBt).UnderlyingTsString.GetBldr(); trans.Translation.SetAlternative(btTssBldr.GetString(), wsBt); m_btDraftView.SetInsertionPoint(0, 0, 0, 3, false); //set the IP after the word "one" int iBtFootnote1; m_btDraftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote1); m_btDraftView.SetInsertionPoint(0, 0, 0, 8, false); // set the IP after the word "two" int iBtFootnote2; m_btDraftView.TeEditingHelper.InsertFootnote(ScrStyleNames.NormalFootnoteParagraph, out iBtFootnote2); // Confirm that the footnote callers were inserted in the correct locations. Assert.AreEqual("one" + StringUtils.kchObject + " two" + StringUtils.kchObject, trans.Translation.GetAlternative(wsBt).UnderlyingTsString.Text); StTxtParaTests.VerifyBtFootnote(footnote1, parentPara, wsBt, 3); StTxtParaTests.VerifyBtFootnote(footnote2, parentPara, wsBt, 8); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a book with 2 sections with the following layout: /// bookName /// Heading 1 /// (1)1Verse one. /// Heading 2 /// (2)1Verse one.2Verse two. /// (3)1Verse one. /// 2This is a pretty long... /// .. /// 11This is a pretty long... /// /// /// Numbers in () are chapter numbers. /// </summary> /// <returns>the book for testing</returns> /// ------------------------------------------------------------------------------------ private IScrBook CreateBook(int nBookNumber, string bookName) { IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(nBookNumber, bookName); m_scrInMemoryCache.AddTitleToMockedBook(book.Hvo, bookName); IScrSection section1 = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section1.Hvo, "Heading 1", ScrStyleNames.SectionHead); StTxtPara para11 = m_scrInMemoryCache.AddParaToMockedSectionContent(section1.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para11, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para11, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para11, "Verse one.", null); section1.AdjustReferences(); IScrSection section2 = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section2.Hvo, "Heading 2", ScrStyleNames.SectionHead); StTxtPara para21 = m_scrInMemoryCache.AddParaToMockedSectionContent(section2.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para21, "2", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para21, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para21, "Verse one.", null); m_scrInMemoryCache.AddRunToMockedPara(para21, "2", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para21, "Verse two.", null); StTxtPara para22 = m_scrInMemoryCache.AddParaToMockedSectionContent(section2.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para22, "3", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para22, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para22, "Verse one.", null); for (int i = 0; i < 10; i++) { StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section2.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, (i + 2).ToString(), ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "This is a pretty long paragraph that doesn't say much " + "that would be worth saying if it wouldn't be for these test. In these tests " + "we simply need some long paragraphs with a lot of text so that we hopefully " + "fill more than one page full of text. Let's just pretend this is something " + "useful and let's hope we have enough text now so that we can stop here.", null); } section2.AdjustReferences(); return(book); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a book (Exodus) with 3 sections with the following layout: /// /// (Exodus) /// Heading 1 /// Intro text /// Heading 2 /// (1)1Verse one. 2Verse two. /// 3Verse three. /// 4Verse four. 5Verse five. /// Heading 3 /// 6Verse six. 7Verse seven. /// /// (1) = chapter number 1 /// </summary> /// <returns>the book of Exodus for testing</returns> /// ------------------------------------------------------------------------------------ protected IScrBook CreateExodusData() { IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(2, "Exodus"); m_scrInMemoryCache.AddTitleToMockedBook(book.Hvo, "Exodus"); IScrSection section1 = m_scrInMemoryCache.AddIntroSectionToMockedBook(book.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section1.Hvo, "Heading 1", ScrStyleNames.IntroSectionHead); StTxtPara para11 = m_scrInMemoryCache.AddParaToMockedSectionContent(section1.Hvo, ScrStyleNames.IntroParagraph); m_scrInMemoryCache.AddRunToMockedPara(para11, "Intro text. We need lots of stuff here so that our footnote tests will work.", null); section1.AdjustReferences(); IScrSection section2 = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section2.Hvo, "Heading 2", ScrStyleNames.SectionHead); StTxtPara para21 = m_scrInMemoryCache.AddParaToMockedSectionContent(section2.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para21, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para21, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para21, "Verse one. ", null); m_scrInMemoryCache.AddRunToMockedPara(para21, "2", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para21, "Verse two.", null); StTxtPara para22 = m_scrInMemoryCache.AddParaToMockedSectionContent(section2.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para22, "3", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para22, "Verse three.", null); StTxtPara para23 = m_scrInMemoryCache.AddParaToMockedSectionContent(section2.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para23, "4", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para23, "Verse four. ", null); m_scrInMemoryCache.AddRunToMockedPara(para23, "5", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para23, "Verse five.", null); section2.AdjustReferences(); IScrSection section3 = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section3.Hvo, "Heading 3", ScrStyleNames.SectionHead); StTxtPara para31 = m_scrInMemoryCache.AddParaToMockedSectionContent(section3.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para31, "6", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para31, "Verse six. ", null); m_scrInMemoryCache.AddRunToMockedPara(para31, "7", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para31, "Verse seven.", null); section3.AdjustReferences(); return(book); }
public void UserPromptChangeWSWhenPasting() { CheckDisposed(); // Set up section head with an empty paragraph IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo); StTxtPara para = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "", ScrStyleNames.SectionHead); section.AdjustReferences(); Options.ShowEmptyParagraphPromptsSetting = true; DynamicMock rootb = new DynamicMock(typeof(IVwRootBox)); rootb.SetupResult("IsCompositionInProgress", false); DynamicMock vwsel = new DynamicMock(typeof(IVwSelection)); IVwRootBox mockRootbox = (IVwRootBox)rootb.MockInstance; vwsel.SetupResult("RootBox", mockRootbox); vwsel.SetupResult("CLevels", 4, typeof(bool)); vwsel.Ignore("AllTextSelInfo"); #if DEBUG vwsel.SetupResult("IsValid", true); #endif DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache, m_inMemoryCache.Cache.DefaultAnalWs, mockRootbox); // set up the text to paste - will be TE2ST with vernacular WS int ws = m_inMemoryCache.Cache.DefaultVernWs; ITsPropsFactory propFact = TsPropsFactoryClass.Create(); ITsTextProps ttp = propFact.MakeProps(null, ws, 0); ITsStrBldr bldr = TsStrBldrClass.Create(); bldr.ReplaceRgch(0, 0, "TEST", 4, ttp); ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, ws, 0); bldr.ReplaceRgch(2, 2, "2", 1, ttp); ITsString tssVal = bldr.GetString(); // Now simulate the user pasting over the user prompt stVc.UpdateProp((IVwSelection)vwsel.MockInstance, para.Hvo, SimpleRootSite.kTagUserPrompt, 0, tssVal); // verify that the text is in the paragraph, that there is no longer a user // prompt, and that the ws changed but the character formatting survives. bldr = tssVal.GetBldr(); bldr.SetIntPropValues(0, 5, (int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs); AssertEx.AreTsStringsEqual(bldr.GetString(), para.Contents.UnderlyingTsString); m_vwenvMock.Verify(); }
public void EnterKey_InBtSectionTitle() { CheckDisposed(); IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(2, "Exodus"); StText title = m_scrInMemoryCache.AddTitleToMockedBook(book.Hvo, "Exodus"); m_btDraftView.BookFilter.Insert(0, book.Hvo); IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo); StTxtPara headPara = m_scrInMemoryCache.AddSectionHeadParaToSection( section.Hvo, "The first section", ScrStyleNames.SectionHead); // Construct a parent paragraph StTxtPara parentPara = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(parentPara, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(parentPara, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(parentPara, "uno ", null); section.AdjustReferences(); // Construct the initial back translation. int wsBt = m_inMemoryCache.Cache.DefaultAnalWs; ICmTranslation titleTrans = m_inMemoryCache.AddBtToMockedParagraph((StTxtPara)title.ParagraphsOS[0], wsBt); m_inMemoryCache.AddRunToMockedTrans(titleTrans, wsBt, "Exodo", ScrStyleNames.MainBookTitle); ICmTranslation headingTrans = m_inMemoryCache.AddBtToMockedParagraph(headPara, wsBt); m_inMemoryCache.AddRunToMockedTrans(headingTrans, wsBt, "BT heading", ScrStyleNames.Header); ICmTranslation paraTrans = m_inMemoryCache.AddBtToMockedParagraph(parentPara, wsBt); m_inMemoryCache.AddRunToMockedTrans(paraTrans, wsBt, "one", null); // Set IP at the start of the title. m_btDraftView.Refresh(); m_btDraftView.RootBox.MakeSimpleSel(true, false, false, true); m_btDraftView.OnKeyPress(new KeyPressEventArgs('\r')); // Verify that the selection has moved to the start of the BT of the section Head. IVwSelection vwsel = m_btDraftView.RootBox.Selection; int ich, hvo, textTag, enc; bool fAssocPrev; ITsString tss; vwsel.TextSelInfo(false, out tss, out ich, out fAssocPrev, out hvo, out textTag, out enc); Assert.AreEqual((int)CmTranslation.CmTranslationTags.kflidTranslation, textTag); Assert.AreEqual(headingTrans.Hvo, hvo, "Current paragraph should first section head."); Assert.AreEqual(0, ich); // selection is at start of paragraph }
public void InsertNote_FromBtAndVern() { CheckDisposed(); // Create vernacular Scripture data. IScrBook philemon = m_scrInMemoryCache.AddBookToMockedScripture(57, "Philemon"); IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(philemon.Hvo); StTxtPara para1 = m_scrInMemoryCache.AddParaToMockedSectionContent( section.Hvo, ScrStyleNames.IntroParagraph); m_scrInMemoryCache.AddRunToMockedPara(para1, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para1, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para1, "This is text", null); m_scrInMemoryCache.AddRunToMockedPara(para1, "2", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para1, "This is text", null); StTxtPara para2 = m_scrInMemoryCache.AddParaToMockedSectionContent( section.Hvo, ScrStyleNames.IntroParagraph); m_scrInMemoryCache.AddRunToMockedPara(para2, "3", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para2, "This is text", null); section.AdjustReferences(); // Create back translation paras. int wsBt = m_scrInMemoryCache.Cache.DefaultAnalWs; ICmTranslation trans1 = m_scrInMemoryCache.AddBtToMockedParagraph(para1, wsBt); m_inMemoryCache.AddRunToMockedTrans(trans1, wsBt, "1", ScrStyleNames.ChapterNumber); m_inMemoryCache.AddRunToMockedTrans(trans1, wsBt, "1", ScrStyleNames.VerseNumber); m_inMemoryCache.AddRunToMockedTrans(trans1, wsBt, "Verse one BT. ", null); m_inMemoryCache.AddRunToMockedTrans(trans1, wsBt, "2", ScrStyleNames.VerseNumber); m_inMemoryCache.AddRunToMockedTrans(trans1, wsBt, "Verse two BT. ", null); ICmTranslation trans2 = m_scrInMemoryCache.AddBtToMockedParagraph(para2, wsBt); m_inMemoryCache.AddRunToMockedTrans(trans1, wsBt, "3", ScrStyleNames.VerseNumber); m_inMemoryCache.AddRunToMockedTrans(trans1, wsBt, "Verse three BT. ", null); // Add annotations at beginning and end of vernacular text. CreateAndCheckAnnotation(para1.Hvo, para1.Hvo, 57001001, 57001001, 2, 6, "This"); CreateAndCheckAnnotation(para2.Hvo, para2.Hvo, 57001003, 57001003, 6, 8, "is"); // Add an annotation in verse 2 of the back translation. CreateAndCheckAnnotation(trans1.Hvo, trans1.Hvo, 57001002, 57001002, 23, 26, "two"); // Confirm that the notes are in the expected order. Assert.AreEqual(para1.Hvo, m_scr.BookAnnotationsOS[56].NotesOS[0].BeginObjectRAHvo, "The first note should be on the first para of the vernacular."); Assert.AreEqual(trans1.Hvo, m_scr.BookAnnotationsOS[56].NotesOS[1].BeginObjectRAHvo, "The second note should be on the translation for the first para of the vernacular."); Assert.AreEqual(para2.Hvo, m_scr.BookAnnotationsOS[56].NotesOS[2].BeginObjectRAHvo, "The third note should be on the third para of the vernacular."); }
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."); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a paragraph from a format string, and append it to the given section's /// content. /// </summary> /// <param name="scrInMemoryCache">in-memory cache to use for testing</param> /// <param name="book">book to use</param> /// <param name="section">section to append to</param> /// <param name="format">(See CreateText for the definition of the format string)</param> /// <param name="ws">writing system to use</param> /// <param name="paraStyle">paragraph style name</param> /// <returns>the new paragraph</returns> /// ------------------------------------------------------------------------------------ internal static StTxtPara AppendParagraph(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book, IScrSection section, string format, int ws, string paraStyle) { // insert a new para in the section content StTxtPara para = new StTxtPara(); section.ContentOA.ParagraphsOS.Append(para); // set the para's fields scrInMemoryCache.AddFormatTextToMockedPara(book as ScrBook, para, format, ws); para.StyleRules = StyleUtils.ParaStyleTextProps(paraStyle); section.AdjustReferences(); return(para); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create basic data for the book of Philemon. /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_scrInMemoryCache.InitializeScripture(); m_scrInMemoryCache.InitializeWritingSystemEncodings(); m_phm = m_scrInMemoryCache.AddBookToMockedScripture(57, "Fylemon"); m_scrInMemoryCache.AddTitleToMockedBook(m_phm.Hvo, "Fylemon"); IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_phm.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "Section Heading", ScrStyleNames.SectionHead); section.AdjustReferences(); m_stylesheet = new FwStyleSheet(); m_stylesheet.Init(Cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles); }
public void InsertNote_RangeSelInIntroPara() { CheckDisposed(); IScrBook philemon = m_scrInMemoryCache.AddBookToMockedScripture(57, "Philemon"); IScrSection section = m_scrInMemoryCache.AddIntroSectionToMockedBook(philemon.Hvo); StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.IntroParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "This is the paragraph", null); section.AdjustReferences(); int hvoPara = para.Hvo; CreateAndCheckAnnotation(hvoPara, hvoPara, 57001000, 57001000, 0, 3, "Thi"); }
public void InsertNote_IpSelInVersePara() { CheckDisposed(); IScrBook philemon = m_scrInMemoryCache.AddBookToMockedScripture(57, "Philemon"); IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(philemon.Hvo); StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.IntroParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "3", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "This is text", null); section.AdjustReferences(); CreateAndCheckAnnotation(para.Hvo, para.Hvo, 57001003, 57001003, 4, 4, string.Empty); }
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()); }
public void IsDataLossDifference_SectionHeadAdded_MidVerse() { IScrSection sectionCur1 = m_scrInMemoryCache.AddSectionToMockedBook(m_genesis.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(sectionCur1.Hvo, "Section 1", ScrStyleNames.SectionHead); StTxtPara para1Cur = AddPara(sectionCur1); AddVerse(para1Cur, 1, 0, "Here is a paragraph that "); sectionCur1.AdjustReferences(); IScrSection sectionCur2 = m_scrInMemoryCache.AddSectionToMockedBook(m_genesis.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(sectionCur2.Hvo, "Section 2", ScrStyleNames.SectionHead); StTxtPara para2Cur = AddPara(sectionCur2); AddVerse(para2Cur, 0, 0, "will have a section inserted into it."); sectionCur2.AdjustReferences(); IScrSection sectionRev1 = m_scrInMemoryCache.AddSectionToMockedBook(m_genesisRevision.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(sectionRev1.Hvo, "Section 1", ScrStyleNames.SectionHead); StTxtPara para1Rev = AddPara(sectionRev1); AddVerse(para1Rev, 1, 0, "Here is a paragraph that will have a section inserted into it."); sectionRev1.AdjustReferences(); m_bookMerger.DetectDifferences(null); // Expect 2 differences: ParagraphAdded difference should not cause data loss as // it is treated as a unit with other 2 differences Assert.AreEqual(3, m_bookMerger.Differences.Count); Difference diff0 = m_bookMerger.Differences.MoveFirst(); Assert.AreEqual(DifferenceType.TextDifference, diff0.DiffType); Difference diff1 = m_bookMerger.Differences.MoveNext(); Assert.AreEqual(DifferenceType.SectionHeadAddedToCurrent, diff1.DiffType); Difference diff2 = m_bookMerger.Differences.MoveNext(); Assert.AreEqual(DifferenceType.ParagraphAddedToCurrent, diff2.DiffType); Assert.IsFalse(m_bookMerger.IsDataLossDifference(diff0)); Assert.IsFalse(m_bookMerger.IsDataLossDifference(diff1)); Assert.IsFalse(m_bookMerger.IsDataLossDifference(diff2)); }
public void GetBookInfo_LastPartMissing() { IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_importedVersion.BooksOS[0].Hvo); StTxtPara para = AddPara(section); AddVerse(para, 1, 1, "first verse in Genesis"); AddVerse(para, 50, 25, "NOT the last verse in Genesis"); section.AdjustReferences(); using (DummyImportedBooks importedBooks = new DummyImportedBooks(Cache, m_importedVersion, m_savedVersion)) { string bookName = (string)ReflectionHelper.GetStrResult(typeof(ImportedBooks), "GetBookInfo", m_importedVersion.BooksOS[0]); Assert.AreEqual("1:1-50:25", bookName); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a book and section /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { base.CreateTestData(); m_flidContainingTexts = (int)ScrBook.ScrBookTags.kflidSections; IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(57, "Philemon"); m_scrInMemoryCache.AddTitleToMockedBook(book.Hvo, "Philemon"); m_hvoRoot = book.Hvo; IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(book.Hvo); m_hvoSection = section.Hvo; section.AdjustReferences(); m_frag = 7; }
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()); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create test data /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_inMemoryCache.InitializeWritingSystemEncodings(); m_book = m_scrInMemoryCache.AddBookToMockedScripture(40, "Matthews"); // add section and paragraph m_section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo); m_para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(m_para, "15", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(m_para, "This is verse one. ", null); m_scrInMemoryCache.AddRunToMockedPara(m_para, "16", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(m_para, "This is a verse. ", null); m_scrInMemoryCache.AddRunToMockedPara(m_para, "17", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(m_para, "This is a verse. ", null); m_section.AdjustReferences(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates test data /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_stylesheet = new FwStyleSheet(); m_scrInMemoryCache.AddScrStyle("User added title style", ContextValues.Title, StructureValues.Undefined, FunctionValues.Prose, false); m_scrInMemoryCache.AddScrStyle("Poetry", ContextValues.Text, StructureValues.Body, FunctionValues.Prose, false); m_scrInMemoryCache.AddScrStyle("Parallel Passage", ContextValues.Text, StructureValues.Heading, FunctionValues.Prose, false); m_scrInMemoryCache.AddScrStyle("Line 1", ContextValues.Text, StructureValues.Body, FunctionValues.Prose, false); m_stylesheet.Init(Cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles); m_scrInMemoryCache.AddBookWithTwoSections(40, "Matthew"); m_philemon = m_scrInMemoryCache.AddBookWithTwoSections(57, "Philemon"); m_scrInMemoryCache.AddBookWithTwoSections(66, "Revelation"); m_section1 = (ScrSection)m_philemon.SectionsOS[0]; m_scrInMemoryCache.AddSectionHeadParaToSection(m_section1.Hvo, "Matt. 4:5-9; Luke 2:6-10", "Parallel Passage"); StTxtPara para = (StTxtPara)m_section1.ContentOA.ParagraphsOS[0]; m_scrInMemoryCache.AddRunToMockedPara(para, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, " One is the best verse. ", null); m_scrInMemoryCache.AddRunToMockedPara(para, "2", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, " I like two better. ", null); m_scrInMemoryCache.AddRunToMockedPara(para, "3", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, " No, three rocks! ", null); m_scrInMemoryCache.AddRunToMockedPara(para, "4-8", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, " Nobody can touch four through eight. ", null); m_section1.AdjustReferences(); m_section2 = (ScrSection)m_philemon.SectionsOS[1]; para = (StTxtPara)m_section2.ContentOA.ParagraphsOS[0]; m_scrInMemoryCache.AddRunToMockedPara(para, "10", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, " Ten is the best verse. ", null); m_scrInMemoryCache.AddRunToMockedPara(para, "11", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, " I like eleven better. ", null); m_scrInMemoryCache.AddRunToMockedPara(para, "12", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, " No, twelve rocks! ", null); m_scrInMemoryCache.AddRunToMockedPara(para, "13", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, " Nobody can touch thirteen. ", null); para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_section2.Hvo, "Line 1"); m_scrInMemoryCache.AddRunToMockedPara(para, "Second Stanza.", null); m_section2.AdjustReferences(); m_section3 = m_scrInMemoryCache.AddSectionToMockedBook(m_philemon.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(m_section3.Hvo, "Heading for section 3", ScrStyleNames.SectionHead); para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_section3.Hvo, "Poetry"); m_scrInMemoryCache.AddRunToMockedPara(para, "24", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, " Hi, I'm verse 24.", null); para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_section3.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "25", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, " Welcome to the twenty-fifth verse. ", null); m_scrInMemoryCache.AddRunToMockedPara(para, "26", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, " Welcome to the twenty-sixth verse.", null); para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_section3.Hvo, "Line 1"); m_scrInMemoryCache.AddRunToMockedPara(para, "27", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, " This is the end.", null); m_section3.AdjustReferences(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Add a section, with empty heading and contents. /// Sets the following members: m_currSection, m_hvoSectionHeading, m_hvoSectionContent /// </summary> /// ------------------------------------------------------------------------------------ protected void MakeSection() { // Finalize the previous section, if there is one. FinalizePrevSection(); m_currSection = new ScrSection(); m_iCurrSection++; CurrentBook.SectionsOS.InsertAt(m_currSection, m_iCurrSection); m_currSection.ContentOA = new StText(); m_currSection.HeadingOA = new StText(); m_hvoSectionHeading = m_currSection.HeadingOA.Hvo; m_hvoSectionContent = m_currSection.ContentOA.Hvo; // REVIEW TomB: what should we do if we don't get a valid HVO? Debug.Assert(m_hvoSectionContent > 0); // Default new section refs to current segment's ref (or range) // in case the new section lacks verse number and verse text segments. m_currSection.VerseRefEnd = m_currentRef; m_currSection.AdjustReferences(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a paragraph from a format string, and append it to the given section's /// content. /// </summary> /// <param name="scrInMemoryCache">in-memory cache to use for testing</param> /// <param name="book">book to use</param> /// <param name="section">section to append to</param> /// <param name="format">(See CreateText for the definition of the format string)</param> /// <param name="ws">writing system to use</param> /// <param name="paraStyle">paragraph style name</param> /// <returns>the new paragraph</returns> /// ------------------------------------------------------------------------------------ internal static StTxtPara AppendParagraph(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book, IScrSection section, string format, int ws, string paraStyle) { // insert a new para in the section content StTxtPara para = new StTxtPara(); section.ContentOA.ParagraphsOS.Append(para); // set the para's fields scrInMemoryCache.AddFormatTextToMockedPara(book as ScrBook, para, format, ws); para.StyleRules = StyleUtils.ParaStyleTextProps(paraStyle); section.AdjustReferences(); return para; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create book of Genesis with 3 sections. First section contains one content para, /// second section contains head and two content paragraphs (with one footnote each), /// third section contains head and one content paragraph (with one footnote). /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_genesis = m_scrInMemoryCache.AddBookToMockedScripture(1, "Genesis"); m_scrInMemoryCache.AddTitleToMockedBook(m_genesis.Hvo, "Genesis"); // Intro section m_introSection = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_genesis.Hvo); StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_introSection.Hvo, ScrStyleNames.IntroParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "Introduction para", null); m_scrInMemoryCache.AddFootnote(m_genesis, para, 10); m_introSection.AdjustReferences(); // First section m_section = m_scrInMemoryCache.AddSectionToMockedBook(m_genesis.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(m_section.Hvo, "Heading", ScrStyleNames.SectionHead); para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "1", ScrStyleNames.ChapterNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "1", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "This is the first paragraph.", null); m_scrInMemoryCache.AddRunToMockedPara(para, "2", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "Verse two.", null); m_scrInMemoryCache.AddFootnote(m_genesis, para, 5); para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_section.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "5", ScrStyleNames.VerseNumber); m_scrInMemoryCache.AddRunToMockedPara(para, "This is the last paragraph.", null); m_scrInMemoryCache.AddFootnote(m_genesis, para, 10); m_section.AdjustReferences(); // Second section m_secondSection = m_scrInMemoryCache.AddSectionToMockedBook(m_genesis.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(m_secondSection.Hvo, "Heading of last section", ScrStyleNames.SectionHead); para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_secondSection.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "This is the paragraph of the last section", null); m_scrInMemoryCache.AddFootnote(m_genesis, para, 20); m_secondSection.AdjustReferences(); }