예제 #1
0
		public void DestroyTest()
		{
			CheckDisposed();

			while (m_cache.CanUndo)
				m_cache.Undo();
			m_cache.DatabaseAccessor.RollbackSavePoint(m_sSavepoint);
			m_cache.ClearAllData();
			m_importMgr = null;
		}
예제 #2
0
		public void InitTest()
		{
			CheckDisposed();

			m_cache.DatabaseAccessor.SetSavePoint(out m_sSavepoint);

			MockScrObjWrapper.s_fSimulateCancel = true;
			using (new SuppressSubTasks(m_cache))
			{
				m_settings.StartRef = m_titus;
				m_settings.EndRef = m_titus;
				m_settings.ImportTranslation = true;
				m_settings.ImportBackTranslation = false;
				m_settings.ImportBookIntros = true;
				m_settings.ImportAnnotations = false;
			}
			m_importMgr = new DummyTeImportManager(m_cache, m_styleSheet);
		}
예제 #3
0
        public void SFImportJonahTOB()
        {
            using (UndoableUnitOfWorkHelper undoHelper = new UndoableUnitOfWorkHelper(
                m_actionHandler, "import settings"))
            {
                m_settings.ImportBookIntros = true;
                m_settings.ImportAnnotations = false;
                m_settings.ImportTranslation = true;
                m_settings.ImportBackTranslation = false;
                MakeSFImportTestSettings((m_settings as IScrImportSet));
                (m_settings as IScrImportSet).StartRef = (m_settings as IScrImportSet).EndRef = m_bcvRefJonah;
                undoHelper.RollBack = false; // keep the changes
            }

            // do the import
            DummyTeImportManager mgr = new DummyTeImportManager(Cache, m_styleSheet);
            mgr.SimulateAcceptAllBooks = true;
            mgr.CallImportWithUndoTask(m_settings);
            //TeSfmImporter.Import(m_settings, Cache, m_styleSheet,
            //    new DummyUndoImportManager(this), new TeImportNoUi());

            //verify the results
            IScrBook jonah = Cache.LangProject.TranslatedScriptureOA.FindBook("JON");
            Assert.IsNotNull(jonah, "Jonah wasn't created.");
            Assert.AreEqual(8, jonah.SectionsOS.Count, "Incorrect number of sections");
            IFdoOwningSequence<IStPara> titleParas = jonah.TitleOA.ParagraphsOS;
            Assert.AreEqual(1, titleParas.Count, "The title should consist of 1 para");
            string title = ((IStTxtPara)titleParas[0]).Contents.Text;
            Assert.AreEqual("JONAS", title.Trim(), "Incorrect book title");
            Assert.AreEqual("JONAS", jonah.Name.VernacularDefaultWritingSystem,
                "Incorrect book name");
            Assert.AreEqual(@"TOB32.SBF, CB 28.09.94", jonah.IdText);
            Assert.AreEqual(32001000, jonah.SectionsOS[0].VerseRefStart,
                "Introductory Section start reference");
            Assert.AreEqual(32001000, jonah.SectionsOS[0].VerseRefEnd,
                "Introductory Section end reference");
            Assert.AreEqual(32001000, jonah.SectionsOS[3].VerseRefStart,
                "Introductory Section start reference");
            Assert.AreEqual(32001000, jonah.SectionsOS[3].VerseRefEnd,
                "Introductory Section end reference");
            Assert.AreEqual(32001001, jonah.SectionsOS[4].VerseRefStart,
                "Section 4 start reference");
            Assert.AreEqual(32001016, jonah.SectionsOS[4].VerseRefEnd,
                "Section 4 end reference");
            Assert.AreEqual(32004001, jonah.SectionsOS[7].VerseRefStart,
                "Section 7 start reference");
            Assert.AreEqual(32004011, jonah.SectionsOS[7].VerseRefEnd,
                "Section 7 end reference");
            Assert.AreEqual(1, jonah.SectionsOS[0].HeadingOA.ParagraphsOS.Count,
                "Incorrect number of paras in first section heading.");
            IStTxtPara firstIntroHeadingPara =
                (IStTxtPara)jonah.SectionsOS[0].HeadingOA.ParagraphsOS[0];

            string sBrkChar = new string((char)0x2028, 1);
            Assert.AreEqual("Composition", firstIntroHeadingPara.Contents.Text,
                "First para of first intro section incorrect");

            // Verify the text in section[6], para[0], irun 0-2 (Jonah 3:1)
            Assert.AreEqual(1, jonah.SectionsOS[6].ContentOA.ParagraphsOS.Count);
            IStTxtPara para = (IStTxtPara)jonah.SectionsOS[6].ContentOA.ParagraphsOS[0]; //first para
            Assert.AreEqual(21, para.Contents.RunCount);
            AssertEx.RunIsCorrect(para.Contents, 0, "3", "Chapter Number", m_wsVern);
            AssertEx.RunIsCorrect(para.Contents, 1, "1", "Verse Number", m_wsVern);
            AssertEx.RunIsCorrect(para.Contents, 2, "La parole du SEIGNEUR s'adressa une seconde fois à Jonas: ",
                null, m_wsVern);

            // Check some text toward the end (in verse 4:11)
            para = (IStTxtPara)jonah.SectionsOS[7].ContentOA.ParagraphsOS[0];
            Assert.AreEqual("11Et moi", para.Contents.Text.Substring(1543, 8));
        }
예제 #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose(bool disposing)
		{
			Debug.WriteLine("Start of Dispose");
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
				if (m_cache != null)
				{
					if (m_cache.DatabaseAccessor.IsTransactionOpen())
						m_cache.DatabaseAccessor.RollbackTrans();
					m_cache.Dispose();
				}
			}
			m_cache = null;
			m_importMgr = null;
			m_scr = null;
			m_styleSheet = null; // FwStyleSheet should implement IDisposable.
			m_settings = null;
			Debug.WriteLine("Before calling base.Dispose");

			base.Dispose(disposing);
			Debug.WriteLine("End of Dispose");
		}
예제 #5
0
        public void ParatextImportTitusTEV()
        {
            using (UndoableUnitOfWorkHelper undoHelper = new UndoableUnitOfWorkHelper(
                m_actionHandler, "import settings"))
            {
                m_settings.ImportBookIntros = true;
                m_settings.ImportAnnotations = false;
                m_settings.ImportTranslation = true;
                m_settings.ImportBackTranslation = false;
                MakeParatextImportTestSettings((m_settings as IScrImportSet));
                (m_settings as IScrImportSet).StartRef = (m_settings as IScrImportSet).EndRef = m_bcvRefTitus;
                undoHelper.RollBack = false; // keep the changes
            }

            // do the import
            DummyTeImportManager mgr = new DummyTeImportManager(Cache, m_styleSheet);
            mgr.SimulateAcceptAllBooks = true;
            mgr.CallImportWithUndoTask(m_settings);
            //TeSfmImporter.Import(m_settings, Cache, m_styleSheet,
            //    new DummyUndoImportManager(this), new TeImportNoUi());

            // verify the results
            IScrBook titus = Cache.LangProject.TranslatedScriptureOA.FindBook("TIT");
            Assert.IsNotNull(titus, "Titus wasn't created.");
            Assert.AreEqual(7, titus.SectionsOS.Count, "Incorrect number of sections");
            IFdoOwningSequence<IStPara> titleParas = titus.TitleOA.ParagraphsOS;
            Assert.AreEqual(1, titleParas.Count, "Incorrect number of title Paragraphs");
            string title = ((IStTxtPara)titleParas[0]).Contents.Text;
            string sBrkChar = new string((char)0x2028, 1);
            Assert.AreEqual("Paul's Letter to" + sBrkChar + "TITUS", title.Trim(),
                "Incorrect book title");
            Assert.AreEqual("TITUS", titus.Name.VernacularDefaultWritingSystem.Text.ToUpper(),
                "Incorrect book name");
            Assert.AreEqual(@"57TIT.TEV updated to USFM JULY 30, 2002 epeters " +
                @"FOR PREDISTRIBUTION USE ONLY", titus.IdText);
            Assert.AreEqual(56001000, ((IScrSection)titus.SectionsOS[0]).VerseRefStart,
                "Introductory Section start reference");
            Assert.AreEqual(56001000, ((IScrSection)titus.SectionsOS[0]).VerseRefEnd,
                "Introductory Section end reference");
            Assert.AreEqual(56001000, ((IScrSection)titus.SectionsOS[1]).VerseRefStart,
                "Introductory Outline Section start reference");
            Assert.AreEqual(56001000, ((IScrSection)titus.SectionsOS[1]).VerseRefEnd,
                "Introductory Outline Section end reference");
            Assert.AreEqual(56001001, ((IScrSection)titus.SectionsOS[2]).VerseRefStart,
                "Section 2 start reference");
            Assert.AreEqual(56001004, ((IScrSection)titus.SectionsOS[2]).VerseRefEnd,
                "Section 2 end reference");
            Assert.AreEqual(56003012, ((IScrSection)titus.SectionsOS[6]).VerseRefStart,
                "Section 6 start reference");
            Assert.AreEqual(56003015, ((IScrSection)titus.SectionsOS[6]).VerseRefEnd,
                "Section 6 end reference");
            Assert.AreEqual(1, ((IScrSection)titus.SectionsOS[0]).HeadingOA.ParagraphsOS.Count,
                "First section should have a single para: 'Introduction'");
            IStTxtPara firstIntroHeadingPara = (IStTxtPara)titus.SectionsOS[0].HeadingOA.ParagraphsOS[0];
            Assert.AreEqual("Introduction", firstIntroHeadingPara.Contents.Text,
                "First intro section should be called 'Introduction'");

            // Verify the text in section[5], para[0], irun 0 (Tit 3:1)
            Assert.AreEqual(2, titus.SectionsOS[5].ContentOA.ParagraphsOS.Count);
            IStTxtPara para = (IStTxtPara)titus.SectionsOS[5].ContentOA.ParagraphsOS[0]; //first para
            Assert.AreEqual(17, para.Contents.RunCount);
            AssertEx.RunIsCorrect(para.Contents, 0, "3", "Chapter Number", m_wsVern);
            AssertEx.RunIsCorrect(para.Contents, 1, "1", "Verse Number", m_wsVern);

            // Verify the text in section[6], para[2], irun 0 (Tit 3:15)
            Assert.AreEqual(3, titus.SectionsOS[6].ContentOA.ParagraphsOS.Count);
            para = (IStTxtPara)titus.SectionsOS[6].ContentOA.ParagraphsOS[1]; //second para
            Assert.AreEqual(2, para.Contents.RunCount);
            AssertEx.RunIsCorrect(para.Contents, 0, "15", "Verse Number", m_wsVern);
            AssertEx.RunIsCorrect(para.Contents, 1, "All who are with me send you greetings. Give our greetings " +
                "to our friends in the faith.", null, m_wsVern);

            // Verify the text in section[6], para[3], irun 0 (Tit 3:15)
            para = (IStTxtPara)titus.SectionsOS[6].ContentOA.ParagraphsOS[2]; //third para
            Assert.AreEqual(1, para.Contents.RunCount);
            AssertEx.RunIsCorrect(para.Contents, 0, "God's grace be with you all.", null, m_wsVern);
            Assert.AreEqual(StyleUtils.ParaStyleTextProps("Paragraph"), para.StyleRules);

            // Check for verse bridge
            para = (IStTxtPara)titus.SectionsOS[3].ContentOA.ParagraphsOS[1];
            Assert.AreEqual("12-13", para.Contents.Text.Substring(274, 5));
        }