public void InsertBookTest_BeforeEverything()
        {
            // Insert Exodus
            IScrBookRef bookRef = Cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().AllInstances().First().BooksOS[1];

            bookRef.BookName.SetVernacularDefaultWritingSystem("FunSquigles5");
            bookRef.BookName.SetUserWritingSystem("Exodus");
            bookRef.BookAbbrev.SetVernacularDefaultWritingSystem("STH");
            bookRef.BookAbbrev.SetUserWritingSystem("Exo");
            ((TestTeEditingHelper)m_mainWnd.ActiveEditingHelper).m_DeferSelectionUntilEndOfUOW = true;
            IScrBook exodus = m_mainWnd.ActiveEditingHelper.InsertBook(2);

            // Verify a bunch of stuff after inserting a book.
            TeEditingHelperTestsWithMockedFdoCache.VerifyInsertedBook(exodus, "EXO");
            Assert.AreEqual(exodus, m_scr.ScriptureBooksOS[0]);
            VerifyInsertedBookInDraftView(((DummyDraftView)m_mainWnd.TheDraftView).RequestedSelectionAtEndOfUow);

            // Verify that there is a filter in place for exodus
            Assert.AreEqual(1, m_mainWnd.BookFilter.BookCount);
            Assert.AreEqual(exodus.Hvo, m_mainWnd.BookFilter.GetBook(0).Hvo);

            Assert.AreEqual("Exodus", exodus.Name.UserDefaultWritingSystem.Text);
            Assert.AreEqual("Exo", exodus.Abbrev.UserDefaultWritingSystem.Text);
            Assert.AreEqual("FunSquigles5", exodus.Name.VernacularDefaultWritingSystem.Text);
            Assert.AreEqual("STH", exodus.Abbrev.VernacularDefaultWritingSystem.Text);
        }
Example #2
0
        public void CreateScrBookRefs()
        {
            ReflectionHelper.CallMethod(typeof(TeScrBookRefsInit), "SetNamesAndAbbreviations",
                                        new DummyProgressDlg(), Cache);

            IFdoOwningSequence <IScrBookRef> books =
                Cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().Singleton.BooksOS;

            // Make sure the right number of books was generated.
            Assert.AreEqual(66, books.Count);

            ILgWritingSystemFactory wsf = Cache.WritingSystemFactory;
            int wsEnglish = wsf.GetWsFromStr("en");
            int wsSpanish = wsf.GetWsFromStr("es");

            // Check English Genesis
            IScrBookRef genesis = books[0];

            Assert.AreEqual("Genesis",
                            genesis.BookName.get_String(wsEnglish).Text);
            Assert.AreEqual("Gen",
                            genesis.BookAbbrev.get_String(wsEnglish).Text);
            Assert.IsNull(genesis.BookNameAlt.get_String(wsEnglish).Text);

            // Check Spanish Matthew
            IScrBookRef mateo = books[39];

            Assert.AreEqual("Mateo",
                            mateo.BookName.get_String(wsSpanish).Text);
            Assert.AreEqual("Mt",
                            mateo.BookAbbrev.get_String(wsSpanish).Text);
            Assert.IsNull(mateo.BookNameAlt.get_String(wsSpanish).Text);

            // Check English 2 Corinthians
            IScrBookRef iiCor = books[46];

            Assert.AreEqual("2 Corinthians",
                            iiCor.BookName.get_String(wsEnglish).Text);
            Assert.AreEqual("2Cor",
                            iiCor.BookAbbrev.get_String(wsEnglish).Text);
            Assert.AreEqual("II Corinthians",
                            iiCor.BookNameAlt.get_String(wsEnglish).Text);

            // Check Spanish Revelation
            IScrBookRef apocalipsis = books[65];

            Assert.AreEqual("Apocalipsis",
                            apocalipsis.BookName.get_String(wsSpanish).Text);
            Assert.AreEqual("Ap",
                            apocalipsis.BookAbbrev.get_String(wsSpanish).Text);
            Assert.IsNull(apocalipsis.BookNameAlt.get_String(wsSpanish).Text);

            MultilingScrBooks mlsb = new MultilingScrBooks(m_scr.ScrProjMetaDataProvider);

            foreach (IScrBookRef brf in books)
            {
                Assert.IsTrue(!String.IsNullOrEmpty(brf.BookName.get_String(wsEnglish).Text));
                Assert.IsTrue(!String.IsNullOrEmpty(brf.BookAbbrev.get_String(wsEnglish).Text));
            }
        }
Example #3
0
        public void InsertBookTest_BeforeEverything()
        {
            CheckDisposed();

            // Insert Exodus
            IScrBookRef bookRef = m_cache.ScriptureReferenceSystem.BooksOS[1];

            bookRef.BookName.VernacularDefaultWritingSystem   = "FunSquigles5";
            bookRef.BookAbbrev.VernacularDefaultWritingSystem = "STH";
            IScrBook exodus = m_mainWnd.ActiveEditingHelper.InsertBook(2);

            // Verify a bunch of stuff after inserting a book.
            VerifyInsertedBook(exodus, "EXO");
            Assert.AreEqual(exodus.Hvo, m_scr.ScriptureBooksOS.HvoArray[0]);
            VerifyInsertedBookMainTitle(exodus.TitleOA, "Exodus");
            IScrSection section = exodus.SectionsOS[0];

            ScrSectionTests.VerifyInsertedBookSection(section, false, "1",
                                                      "Chapter Number", m_cache.DefaultVernWs, 02001001);
            VerifyInsertedBookInDraftView("Exodus", exodus);

            // Verify that there is a filter in place for exodus
            Assert.AreEqual(1, m_mainWnd.BookFilter.BookCount);
            Assert.AreEqual(exodus.Hvo, m_mainWnd.BookFilter.GetBook(0).Hvo);

            Assert.AreEqual("Exodus", exodus.Name.UserDefaultWritingSystem);
            Assert.AreEqual("Exo", exodus.Abbrev.UserDefaultWritingSystem);
            Assert.AreEqual("FunSquigles5", exodus.Name.VernacularDefaultWritingSystem);
            Assert.AreEqual("STH", exodus.Abbrev.VernacularDefaultWritingSystem);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the Scripture reference of the specified annotation as string.
        /// </summary>
        /// <param name="ann">The specified annotation.</param>
        /// ------------------------------------------------------------------------------------
        private string GetRefAsString(IScrScriptureNote ann)
        {
            BCVRef   startRef = new BCVRef(ann.BeginRef);
            IScrBook book     = m_scr.FindBook(startRef.Book);
            string   bookName;

            // Book for note may not be in the project.
            if (book != null)
            {
                bookName = book.BestUIName;
            }
            else
            {
                IScrBookRef bookRef = Cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().Singleton.BooksOS[startRef.Book - 1];
                ITsString   tsName  = bookRef.BookName.get_String(Cache.DefaultUserWs);
                if (tsName.Length == 0)
                {
                    tsName = bookRef.BookName.BestAnalysisAlternative;
                }
                bookName = tsName.Text;
            }

            string titleText = ResourceHelper.GetResourceString("kstidScriptureTitle");
            string introText = ResourceHelper.GetResourceString("kstidScriptureIntro");

            return(BCVRef.MakeReferenceString(bookName, startRef, new BCVRef(ann.EndRef),
                                              m_scr.ChapterVerseSepr, m_scr.Bridge, titleText, introText));
        }
Example #5
0
        public override void TestTearDown()
        {
            m_phm        = null;
            m_phmBkRef   = null;
            m_stylesheet = null;

            base.TestTearDown();
        }
		public override void TestTearDown()
		{
			m_phm = null;
			m_phmBkRef = null;
			m_stylesheet = null;

			base.TestTearDown();
		}
        /// -------------------------------------------------------------------------------------
        /// <summary>
        /// Create publications and header/footer sets (in the DB) from the given XML document.
        /// </summary>
        /// <remarks>tests are able to call this method</remarks>
        /// <param name="progressDlg">Progress dialog</param>
        /// <param name="rootNode">The XmlNode from which to read the publication info</param>
        /// -------------------------------------------------------------------------------------
        protected void SetNamesAndAbbreviations(IProgress progressDlg, XmlNode rootNode)
        {
            IScrRefSystem srs = m_cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().Singleton;

            Debug.Assert(srs != null && srs.BooksOS.Count == BCVRef.LastBook);

            XmlNodeList tagList = rootNode.SelectNodes("/ScrBookRef/writingsystem");

            progressDlg.Minimum  = 0;
            progressDlg.Maximum  = tagList.Count * BCVRef.LastBook;
            progressDlg.Position = 0;
            progressDlg.Title    = TeResourceHelper.GetResourceString("kstidCreatingBookNames");
            ITsStrFactory  tsf = m_cache.TsStrFactory;
            IWritingSystem ws;

            foreach (XmlNode writingSystem in tagList)
            {
                XmlAttributeCollection attributes = writingSystem.Attributes;
                string sWsTag = attributes.GetNamedItem("xml:lang").Value;
                m_cache.ServiceLocator.WritingSystemManager.GetOrSet(sWsTag, out ws);

                XmlNodeList WSBooks = writingSystem.SelectNodes("book");
                foreach (XmlNode book in WSBooks)
                {
                    XmlAttributeCollection bookAttributes = book.Attributes;
                    string sSilBookId = bookAttributes.GetNamedItem("SILBookId").Value;
                    Debug.Assert(sSilBookId != null);
                    int    nCanonicalBookNum = BCVRef.BookToNumber(sSilBookId);
                    string sName             = bookAttributes.GetNamedItem("Name").Value;
                    string sAbbrev           = bookAttributes.GetNamedItem("Abbreviation").Value;
                    string sAltName          = bookAttributes.GetNamedItem("AlternateName").Value;
                    progressDlg.Message = string.Format(
                        TeResourceHelper.GetResourceString("kstidCreatingBookNamesStatusMsg"), sName);
                    progressDlg.Step(0);

                    // check for the book id
                    IScrBookRef bookRef = srs.BooksOS[nCanonicalBookNum - 1];

                    int wsHandle = ws.Handle;
                    if (sName != null)
                    {
                        bookRef.BookName.set_String(wsHandle, tsf.MakeString(sName, wsHandle));
                    }
                    if (sAbbrev != null)
                    {
                        bookRef.BookAbbrev.set_String(wsHandle, tsf.MakeString(sAbbrev, wsHandle));
                    }
                    if (sAltName != null)
                    {
                        bookRef.BookNameAlt.set_String(wsHandle, tsf.MakeString(sAltName, wsHandle));
                    }
                }
            }
            // Finally, update resource version in database.
            SetNewResourceVersion(GetVersion(rootNode));
        }
Example #8
0
        public override void Exit()
        {
            CheckDisposed();

            m_phm        = null;
            m_phmBkRef   = null;
            m_stylesheet = null;

            base.Exit();
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the book properties on the current ScrBook and ScrBookRef.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected void UpdateBookProperties()
        {
            // Save book names and abbreviations to the current ScrBook
            m_listBookInfo.SaveMultiLingualStrings();

            // All new settings in the book should now be written to the ScrBookRef
            m_currentBook.BookIdRA.BookName.CopyAlternatives(m_currentBook.Name);
            m_currentBook.BookIdRA.BookAbbrev.CopyAlternatives(m_currentBook.Abbrev);

            IScrRefSystem scrRefSystem = m_currentBook.Cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().AllInstances().FirstOrDefault();
            IScrBookRef   scrBookRef   = scrRefSystem.BooksOS[m_currentBook.CanonicalNum - 1];

            scrBookRef.BookName.CopyAlternatives(m_currentBook.Name);
            scrBookRef.BookAbbrev.CopyAlternatives(m_currentBook.Abbrev);
        }
Example #10
0
        public void SetBookNameAbbrev()
        {
            CheckDisposed();

            CreateTestData();

            m_phm      = m_scr.ScriptureBooksOS[0];
            m_phmBkRef = Cache.ScriptureReferenceSystem.BooksOS[m_phm.CanonicalNum - 1];


            // Set up the analysis writing system in ScrBook and the analysis writing system in ScrBookRef.
            m_phm.Name.SetAlternative("Foilemon", m_inMemoryCache.Cache.DefaultAnalWs);
            m_phm.Abbrev.SetAlternative("Foil", m_inMemoryCache.Cache.DefaultAnalWs);
            m_phmBkRef.BookName.SetAlternative("Filemon", m_inMemoryCache.Cache.DefaultVernWs);
            m_phmBkRef.BookAbbrev.SetAlternative("Fil", m_inMemoryCache.Cache.DefaultVernWs);

            // Updating the name and abbreviation with the Book Properties dialog should set the
            // information from the ScrRefSystem in both ScrBook and ScrBookRef.
            using (DummyBookPropertiesDlg dlg = new DummyBookPropertiesDlg(m_phm, m_stylesheet))
            {
                dlg.Show();
                System.Threading.Thread.Sleep(1000);
                dlg.CallUpdateBookProperties();

                // We expect that the ScrBook and ScrBookRef will be set to the same values.
                // The BookPropertiesDialog should get the settings from the ScrBook, and if they are
                // not set there (as is the case with the vernacular), look in ScrBookRef.
                Assert.AreEqual("Filemon", m_phm.Name.VernacularDefaultWritingSystem);
                Assert.AreEqual("Filemon", m_phmBkRef.BookName.VernacularDefaultWritingSystem);
                Assert.AreEqual("Fil", m_phm.Abbrev.VernacularDefaultWritingSystem);
                Assert.AreEqual("Fil", m_phmBkRef.BookAbbrev.VernacularDefaultWritingSystem);
                Assert.AreEqual("Foilemon", m_phm.Name.AnalysisDefaultWritingSystem);
                Assert.AreEqual("Foilemon", m_phmBkRef.BookName.AnalysisDefaultWritingSystem);
                Assert.AreEqual("Foil", m_phm.Abbrev.AnalysisDefaultWritingSystem);
                Assert.AreEqual("Foil", m_phmBkRef.BookAbbrev.AnalysisDefaultWritingSystem);

                dlg.Close();
            }
            //dlg.Dispose();
        }
Example #11
0
        public void SetBookNameAbbrev()
        {
            m_phm = m_scr.ScriptureBooksOS[0];
            IScrRefSystem scrRefSystem =
                Cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().AllInstances().FirstOrDefault();

            m_phmBkRef = scrRefSystem.BooksOS[m_phm.CanonicalNum - 1];

            // Set up the analysis writing system in ScrBook and the analysis writing system in ScrBookRef.
            m_phm.Name.set_String(Cache.DefaultVernWs, string.Empty);
            m_phm.Name.set_String(Cache.DefaultAnalWs, "Foilemon");
            m_phm.Abbrev.set_String(Cache.DefaultAnalWs, "Foil");
            m_phmBkRef.BookName.set_String(Cache.DefaultVernWs, "Filemon");
            m_phmBkRef.BookAbbrev.set_String(Cache.DefaultVernWs, "Fil");

            // Updating the name and abbreviation with the Book Properties dialog should set the
            // information from the ScrRefSystem in both ScrBook and ScrBookRef.
            using (DummyBookPropertiesDlg dlg = new DummyBookPropertiesDlg(m_phm, m_stylesheet))
            {
                dlg.Show();
                dlg.CallUpdateBookProperties();

                // We expect that the ScrBook and ScrBookRef will be set to the same values.
                // The BookPropertiesDialog should get the settings from the ScrBook, and if they are
                // not set there (as is the case with the vernacular), look in ScrBookRef.
                Assert.AreEqual("Filemon", m_phm.Name.VernacularDefaultWritingSystem.Text);
                Assert.AreEqual("Filemon", m_phmBkRef.BookName.VernacularDefaultWritingSystem.Text);
                Assert.AreEqual("Fil", m_phm.Abbrev.VernacularDefaultWritingSystem.Text);
                Assert.AreEqual("Fil", m_phmBkRef.BookAbbrev.VernacularDefaultWritingSystem.Text);
                Assert.AreEqual("Foilemon", m_phm.Name.AnalysisDefaultWritingSystem.Text);
                Assert.AreEqual("Foilemon", m_phmBkRef.BookName.AnalysisDefaultWritingSystem.Text);
                Assert.AreEqual("Foil", m_phm.Abbrev.AnalysisDefaultWritingSystem.Text);
                Assert.AreEqual("Foil", m_phmBkRef.BookAbbrev.AnalysisDefaultWritingSystem.Text);

                dlg.Close();
            }
            //dlg.Dispose();
        }
Example #12
0
        public void CreateScrBookRefs()
        {
            CheckDisposed();

            IScrRefSystem scr = Cache.ScriptureReferenceSystem;

            m_scrInitializer.CallCreateScrBookRefs(Cache);

            FdoOwningSequence <IScrBookRef> books = scr.BooksOS;

            // Make sure the right number of books was generated.
            Assert.AreEqual(66, books.Count);

            ILgWritingSystemFactory wsf = Cache.LanguageWritingSystemFactoryAccessor;
            int wsEnglish = wsf.GetWsFromStr("en");
            int wsSpanish = wsf.GetWsFromStr("es");

            // Check English Genesis
            IScrBookRef genesis = books[0];

            Assert.AreEqual("Genesis",
                            genesis.BookName.GetAlternative(wsEnglish));
            Assert.AreEqual("Gen",
                            genesis.BookAbbrev.GetAlternative(wsEnglish));
            Assert.IsNull(genesis.BookNameAlt.GetAlternative(wsEnglish));

            // Check Spanish Matthew
            IScrBookRef mateo = books[39];

            Assert.AreEqual("Mateo",
                            mateo.BookName.GetAlternative(wsSpanish));
            Assert.AreEqual("Mt",
                            mateo.BookAbbrev.GetAlternative(wsSpanish));
            Assert.IsNull(mateo.BookNameAlt.GetAlternative(wsSpanish));

            // Check English 2 Corinthians
            IScrBookRef iiCor = books[46];

            Assert.AreEqual("2 Corinthians",
                            iiCor.BookName.GetAlternative(wsEnglish));
            Assert.AreEqual("2Cor",
                            iiCor.BookAbbrev.GetAlternative(wsEnglish));
            Assert.AreEqual("II Corinthians",
                            iiCor.BookNameAlt.GetAlternative(wsEnglish));

            // Check Spanish Revelation
            IScrBookRef apocalipsis = books[65];

            Assert.AreEqual("Apocalipsis",
                            apocalipsis.BookName.GetAlternative(wsSpanish));
            Assert.AreEqual("Ap",
                            apocalipsis.BookAbbrev.GetAlternative(wsSpanish));
            Assert.IsNull(apocalipsis.BookNameAlt.GetAlternative(wsSpanish));

            MultilingScrBooks mlsb = new MultilingScrBooks(m_scr);

            mlsb.InitializeWritingSystems(Cache.LanguageWritingSystemFactoryAccessor);

            foreach (IScrBookRef brf in books)
            {
                string sBookName = brf.BookName.GetAlternative(wsEnglish);
                Assert.IsTrue(sBookName != null && sBookName != string.Empty);
                string sBookAbbrev = brf.BookAbbrev.GetAlternative(wsEnglish);
                Assert.IsTrue(sBookAbbrev != null && sBookAbbrev != string.Empty);
            }
        }
Example #13
0
		public override void Exit()
		{
			CheckDisposed();

			m_phm = null;
			m_phmBkRef = null;
			m_stylesheet = null;

			base.Exit();
		}
Example #14
0
		public void SetBookNameAbbrev()
		{
			CheckDisposed();

			CreateTestData();

			m_phm = m_scr.ScriptureBooksOS[0];
			m_phmBkRef = Cache.ScriptureReferenceSystem.BooksOS[m_phm.CanonicalNum - 1];


			// Set up the analysis writing system in ScrBook and the analysis writing system in ScrBookRef.
			m_phm.Name.SetAlternative("Foilemon", m_inMemoryCache.Cache.DefaultAnalWs);
			m_phm.Abbrev.SetAlternative("Foil", m_inMemoryCache.Cache.DefaultAnalWs);
			m_phmBkRef.BookName.SetAlternative("Filemon", m_inMemoryCache.Cache.DefaultVernWs);
			m_phmBkRef.BookAbbrev.SetAlternative("Fil", m_inMemoryCache.Cache.DefaultVernWs);

			// Updating the name and abbreviation with the Book Properties dialog should set the
			// information from the ScrRefSystem in both ScrBook and ScrBookRef.
			using (DummyBookPropertiesDlg dlg = new DummyBookPropertiesDlg(m_phm, m_stylesheet))
			{
				dlg.Show();
				System.Threading.Thread.Sleep(1000);
				dlg.CallUpdateBookProperties();

				// We expect that the ScrBook and ScrBookRef will be set to the same values.
				// The BookPropertiesDialog should get the settings from the ScrBook, and if they are
				// not set there (as is the case with the vernacular), look in ScrBookRef.
				Assert.AreEqual("Filemon", m_phm.Name.VernacularDefaultWritingSystem);
				Assert.AreEqual("Filemon", m_phmBkRef.BookName.VernacularDefaultWritingSystem);
				Assert.AreEqual("Fil", m_phm.Abbrev.VernacularDefaultWritingSystem);
				Assert.AreEqual("Fil", m_phmBkRef.BookAbbrev.VernacularDefaultWritingSystem);
				Assert.AreEqual("Foilemon", m_phm.Name.AnalysisDefaultWritingSystem);
				Assert.AreEqual("Foilemon", m_phmBkRef.BookName.AnalysisDefaultWritingSystem);
				Assert.AreEqual("Foil", m_phm.Abbrev.AnalysisDefaultWritingSystem);
				Assert.AreEqual("Foil", m_phmBkRef.BookAbbrev.AnalysisDefaultWritingSystem);

				dlg.Close();
			}
			//dlg.Dispose();
		}
Example #15
0
		public void SetBookNameAbbrev()
		{
			m_phm = m_scr.ScriptureBooksOS[0];
			IScrRefSystem scrRefSystem =
				Cache.ServiceLocator.GetInstance<IScrRefSystemRepository>().AllInstances().FirstOrDefault();
			m_phmBkRef = scrRefSystem.BooksOS[m_phm.CanonicalNum - 1];

			// Set up the analysis writing system in ScrBook and the analysis writing system in ScrBookRef.
			m_phm.Name.set_String(Cache.DefaultVernWs, string.Empty);
			m_phm.Name.set_String(Cache.DefaultAnalWs, "Foilemon");
			m_phm.Abbrev.set_String(Cache.DefaultAnalWs, "Foil");
			m_phmBkRef.BookName.set_String(Cache.DefaultVernWs, "Filemon");
			m_phmBkRef.BookAbbrev.set_String(Cache.DefaultVernWs, "Fil");

			// Updating the name and abbreviation with the Book Properties dialog should set the
			// information from the ScrRefSystem in both ScrBook and ScrBookRef.
			using (DummyBookPropertiesDlg dlg = new DummyBookPropertiesDlg(m_phm, m_stylesheet))
			{
				dlg.Show();
				dlg.CallUpdateBookProperties();

				// We expect that the ScrBook and ScrBookRef will be set to the same values.
				// The BookPropertiesDialog should get the settings from the ScrBook, and if they are
				// not set there (as is the case with the vernacular), look in ScrBookRef.
				Assert.AreEqual("Filemon", m_phm.Name.VernacularDefaultWritingSystem.Text);
				Assert.AreEqual("Filemon", m_phmBkRef.BookName.VernacularDefaultWritingSystem.Text);
				Assert.AreEqual("Fil", m_phm.Abbrev.VernacularDefaultWritingSystem.Text);
				Assert.AreEqual("Fil", m_phmBkRef.BookAbbrev.VernacularDefaultWritingSystem.Text);
				Assert.AreEqual("Foilemon", m_phm.Name.AnalysisDefaultWritingSystem.Text);
				Assert.AreEqual("Foilemon", m_phmBkRef.BookName.AnalysisDefaultWritingSystem.Text);
				Assert.AreEqual("Foil", m_phm.Abbrev.AnalysisDefaultWritingSystem.Text);
				Assert.AreEqual("Foil", m_phmBkRef.BookAbbrev.AnalysisDefaultWritingSystem.Text);

				dlg.Close();
			}
			//dlg.Dispose();
		}