public void RemoveOwnedObjectsForString_Simple() { CheckDisposed(); StTxtParaBldr paraBldr = new StTxtParaBldr(Cache); paraBldr.ParaProps = StyleUtils.ParaStyleTextProps("Normal"); paraBldr.AppendRun("Test Paragraph", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs)); StTxtPara para = paraBldr.CreateParagraph(m_currentText.Hvo); m_inMemoryCache.AddFootnote(m_currentFootnotesOS, para, 10, null); Assert.AreEqual(1, m_currentFootnotesOS.Count); para.RemoveOwnedObjectsForString(5, 12); Assert.AreEqual(0, m_currentFootnotesOS.Count); }
public void RemoveOwnedObjectsForString_FootnotesWithBT() { CheckDisposed(); StTxtPara para = (StTxtPara)m_currentText.ParagraphsOS[0]; // Add footnotes to existing paragraph. StFootnote footnote1 = m_inMemoryCache.AddFootnote(m_currentFootnotesOS, para, 6, "Footnote1"); StFootnote footnote2 = m_inMemoryCache.AddFootnote(m_currentFootnotesOS, para, 10, "Footnote2"); Assert.AreEqual(2, m_currentFootnotesOS.Count); // add two back translations of the para and footnotes ICmTranslation trans; int[] wsBt = new int[] { InMemoryFdoCache.s_wsHvos.En, InMemoryFdoCache.s_wsHvos.De }; foreach (int ws in wsBt) { // add back translation of the para trans = m_inMemoryCache.AddBtToMockedParagraph(para, ws); m_inMemoryCache.AddRunToMockedTrans(trans, ws, "BT of test paragraph", null); // add BT footnotes m_inMemoryCache.AddFootnoteORCtoTrans(trans, 2, ws, footnote1, "BT of footnote1"); m_inMemoryCache.AddFootnoteORCtoTrans(trans, 6, ws, footnote2, "BT of footnote2"); Assert.AreEqual("BT" + StringUtils.kchObject + " of" + StringUtils.kchObject + " test paragraph", trans.Translation.GetAlternative(ws).Text); // confirm that ORCs were inserted in BTs } para.RemoveOwnedObjectsForString(5, 12); Assert.AreEqual(0, m_currentFootnotesOS.Count); // We expect that the ORCs would have also been removed from both back translations. trans = para.GetBT() as CmTranslation; Assert.IsNotNull(trans); foreach (int ws in wsBt) { Assert.AreEqual("BT of test paragraph", trans.Translation.GetAlternative(ws).Text); } }