public void ErrorListIsUpdatedWhenBookFilterChanges() { // We have to add a paragraph that is owned to add a valid annotation, so create // a book, section, paragraph. IScrBook book1 = m_scrInMemoryCache.AddBookToMockedScripture(1, "Genesis"); IScrSection section1 = m_scrInMemoryCache.AddSectionToMockedBook(book1.Hvo); StTxtPara para1 = m_scrInMemoryCache.AddParaToMockedSectionContent(section1.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para1, "some text for an annotation", ScrStyleNames.Normal); IScrBook book2 = m_scrInMemoryCache.AddBookToMockedScripture(2, "Exodus"); IScrSection section2 = m_scrInMemoryCache.AddSectionToMockedBook(book2.Hvo); StTxtPara para2 = m_scrInMemoryCache.AddParaToMockedSectionContent(section2.Hvo, ScrStyleNames.NormalParagraph); m_scrInMemoryCache.AddRunToMockedPara(para1, "some text for an annotation", ScrStyleNames.Normal); // Add both books to the book filter m_bookFilter.UpdateFilter(book1.Hvo, book2.Hvo); EditorialChecksRenderingsControl renderingCtl = new EditorialChecksRenderingsControl(Cache, m_bookFilter, null); // Add some checking errors for each book m_scrInMemoryCache.AddAnnotation(para1, new BCVRef(1001001), NoteType.CheckingError); m_scrInMemoryCache.AddAnnotation(para1, new BCVRef(1001003), NoteType.CheckingError); m_scrInMemoryCache.AddAnnotation(para2, new BCVRef(2002005), NoteType.CheckingError); m_scrInMemoryCache.AddAnnotation(para2, new BCVRef(2005005), NoteType.CheckingError); renderingCtl.LoadCheckingErrors(); SortableBindingList <CheckingError> checkingErrors = ReflectionHelper.GetField(renderingCtl, "m_checkingErrors") as SortableBindingList <CheckingError>; Assert.AreEqual(4, checkingErrors.Count); m_bookFilter.UpdateFilter(book1.Hvo); // Should update the error list Assert.AreEqual(2, checkingErrors.Count, "The error list should have been updated when the book filter changed"); #if DEBUG // For some very strange reason, without this dispose call in debug mode, // there is an assertion in the c++ code when nunit is shut down. With the // dispose call in release mode there is a different assertion in c++ code // (something about calling a pure virtual method) when nunit is shut down. // So, it seems we can't win either way unless making this line conditional // on the build config. Argh!!!! - DDO: 16-Jul-2008 renderingCtl.Dispose(); #endif }
public void OneColumnOneBook() { foreach (PubDivision div in m_dbPub.DivisionsOS) { div.NumColumns = 1; } m_BookFilter.UpdateFilter( Cache.LangProject.TranslatedScriptureOA.ScriptureBooksOS.HvoArray[1]); Assert.AreEqual(1, m_BookFilter.BookCount); m_ScrPubCtrl.Configure(); m_ScrPubCtrl.CreatePages(); // Verify that both divisions are one-column Assert.AreEqual(2, m_ScrPubCtrl.Divisions.Count); DivisionLayoutMgr divTitleIntro = m_ScrPubCtrl.Divisions[0]; DivisionLayoutMgr divScripture = m_ScrPubCtrl.Divisions[1]; Assert.AreEqual(divTitleIntro.AvailableMainStreamColumWidthInPrinterPixels, divScripture.AvailableMainStreamColumWidthInPrinterPixels); Assert.AreEqual(divTitleIntro.AvailableMainStreamColumWidthInPrinterPixels, divTitleIntro.AvailablePageWidthInPrinterPixels); Assert.AreNotEqual(DivisionStartOption.Continuous, divTitleIntro.StartAt); Assert.AreEqual(DivisionStartOption.Continuous, divScripture.StartAt); Assert.Greater(divTitleIntro.MainRootBox.Height, 0); Assert.Greater(divScripture.MainRootBox.Height, 0); Assert.Greater(divScripture.MainRootBox.Height, divTitleIntro.MainRootBox.Height); Assert.Greater(m_ScrPubCtrl.PageCount, 2); Assert.IsNotNull(divTitleIntro.MainVc as ScriptureBookIntroVc); Assert.IsNotNull(divScripture.MainVc as ScriptureBodyVc); foreach (DivisionLayoutMgr div in m_ScrPubCtrl.Divisions) { IVwLayoutStream layoutStream = div.MainLayoutStream; Assert.IsNotNull(layoutStream); Assert.IsNotNull(layoutStream as IVwRootBox); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Redoes the Insert Book - the book is being added /// </summary> /// <param name="fRefreshPending">Ignored</param> /// ------------------------------------------------------------------------------------ public override bool Redo(bool fRefreshPending) { // find out the HVO of the book that is being restored. // We can't use m_bookHvo because if multiple users are connected with // this database the HVO might already be gone. IScrBook book = ScrBook.FindBookByID(m_cache, m_bookID); m_bookHvo = book.Hvo; if (FwApp.App != null) { FwApp.App.Synchronize(new SyncInfo(SyncMsg.ksyncScriptureNewBook, m_bookHvo, (int)Scripture.ScriptureTags.kflidScriptureBooks), m_cache); } m_bookFilter.UpdateFilter(m_bookHvo); m_bookFilter.Load(m_bookHvo, m_bookFilter.Tag, m_cache.DefaultVernWs, m_cache.VwCacheDaAccessor); return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Setup the test. /// </summary> /// ------------------------------------------------------------------------------------ public override void Initialize() { base.Initialize(); m_bookFilter = new FilteredScrBooks(Cache, 1); m_bookFilter.UpdateFilter(new int[] { m_Genesis.Hvo }); m_dummyParaDlg = new DummyParatextDialog(Cache, m_bookFilter); //ScrImportSet importSet = new ScrImportSet(); //Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSet); //importSet.ParatextScrProj = "xyz"; //importSet.ParatextBTProj = "xyzBT"; //Cache.LangProject.TranslatedScriptureOA.DefaultImportSettings = importSet; ILgWritingSystem wsVern = ((LgWritingSystem)Cache.LangProject.CurVernWssRS[0]); wsVern.Abbr.UserDefaultWritingSystem = "xyz"; // Initialize in-memory registry settings. m_dummyParaDlg.Registry.SetIntValue("ParatextOneDomainExportWhat", 0); m_dummyParaDlg.Registry.SetStringValue("ParatextOutputSpec", @"C:\My Paratext Projects"); m_dummyParaDlg.Registry.SetStringValue("ParatextBTOutputSpec", @"C:\My Paratext Projects"); }