Dummy class for the TeImporter so we can test it.
Inheritance: TeSfmImporter
Example #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialize the importer
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void TestSetup()
		{
			base.TestSetup();

			m_styleSheet = new FwStyleSheet();
			m_styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
			InitWsInfo();

			DummyTeImporter.s_translatorNoteDefn = Cache.ServiceLocator.GetInstance<ICmAnnotationDefnRepository>().TranslatorAnnotationDefn;
			DummyTeImporter.s_consultantNoteDefn = Cache.ServiceLocator.GetInstance<ICmAnnotationDefnRepository>().ConsultantAnnotationDefn;

			m_titus = new BCVRef(56001001);
			m_settings = m_scr.FindOrCreateDefaultImportSettings(TypeOfImport.Other);
			m_settings.StartRef = m_titus;
			m_settings.EndRef = m_titus;
			m_settings.ImportTranslation = true;
			InitializeImportSettings();

			m_actionHandler.EndUndoTask(); // Let the importer handle the undo/redo
			m_importer = new DummyTeImporter(m_settings, this, m_styleSheet);
			m_importer.Initialize();
			m_importer.UndoInfo.StartImportingFiles();
		}
Example #2
0
		public void DestroyTest()
		{
			CheckDisposed();
			m_cache.DatabaseAccessor.RollbackSavePoint(m_sSavepoint);
			m_cache.VwCacheDaAccessor.ClearInfoAbout(
				m_cache.LangProject.TranslatedScriptureOA.DefaultImportSettingsHvo, VwClearInfoAction.kciaRemoveObjectAndOwnedInfo);
			m_importer = null;
		}
Example #3
0
		public override void TestTearDown()
		{
			if (m_actionHandler.CurrentDepth > 0)
				m_importer.UndoInfo.DoneImportingFiles(true);
			m_importer.Dispose();
			m_importer = null;
			m_styleSheet = null;
			m_settings = null;

			// Restart an undo task so we don't crash :)
			m_actionHandler.BeginUndoTask("bla", "bla");
			base.TestTearDown();
		}
Example #4
0
		public void InitTest()
		{
			CheckDisposed();
			m_cache.DatabaseAccessor.SetSavePoint(out m_sSavepoint);

			(m_settings as ScrImportSet).StartRef = m_titus;
			(m_settings as ScrImportSet).EndRef = m_titus;
			m_settings.ImportTranslation = true;
			m_settings.ImportBackTranslation = false;
			m_settings.ImportBookIntros = true;
			m_settings.ImportAnnotations = false;
			// pass null as the in memory cache since the acceptance tests should use the real cache.
//			FilteredScrBooks bookFilter = null;
//			m_importer = new DummyTeImporter(m_settings, m_cache, m_styleSheet, bookFilter);
			m_importer = new DummyTeImporter((m_settings as ScrImportSet), m_cache, m_styleSheet);
			m_importer.Initialize();
		}
Example #5
0
		/// <summary>
		/// Correct way to deal with FixtureTearDown for class that derive from BaseTest.
		/// </summary>
		/// <param name="disposing"></param>
		protected override void Dispose(bool disposing)
		{
			if (IsDisposed)
				return;

			if (disposing)
			{
				if (m_cache != null)
				{
					if (m_cache.DatabaseAccessor.IsTransactionOpen())
						m_cache.DatabaseAccessor.RollbackTrans();
					m_cache.Dispose();
				}

				if (m_regData != null)
					m_regData.RestoreRegistryData();

				Unpacker.RemoveParatextTestProjects();
				Unpacker.RemoveSfTestProjects();

				if (m_fileMaker != null)
					m_fileMaker.Dispose();
			}
			m_cache = null;
			m_scr = null;
			m_importer = null;
			m_sSavepoint = null;
			m_styleSheet = null;
			m_settings = null;
			m_fileMaker = null;
			m_ttpVernWS = null;
			m_ttpAnalWS = null;

			base.Dispose(disposing);
		}
Example #6
0
		public override void Initialize()
		{
			base.Initialize();

			m_styleSheet = new FwStyleSheet();
			m_styleSheet.Init(Cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles);
			InitWsInfo();

			DummyTeImporter.s_translatorNoteDefn = m_scrInMemoryCache.m_translatorNoteDefn;
			DummyTeImporter.s_consultantNoteDefn = m_scrInMemoryCache.m_consultantNoteDefn;

			m_titus = new BCVRef(56001001);
			m_settings = new DummyScrImportSet();
			m_scr.ImportSettingsOC.Add(m_settings);
			m_settings.ImportTypeEnum = TypeOfImport.Other;
			m_settings.StartRef = m_titus;
			m_settings.EndRef = m_titus;
			m_settings.ImportTranslation = true;
			InitializeImportSettings();

			m_importer = new DummyTeImporter(m_settings, Cache, m_styleSheet, m_scrInMemoryCache);
			m_importer.Initialize();
		}
Example #7
0
		public override void Exit()
		{
			CheckDisposed();

			m_importer.Dispose();
			m_importer = null;
			m_styleSheet = null;
			m_settings = null;

			base.Exit();
		}
Example #8
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.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_importer != null)
					m_importer.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_styleSheet = null; // FwStyleSheet should implement IDisposable.
			m_settings = null;
			m_importer = null; // TeImporter should implement IDisposable.
			if (m_ttpVernWS != null)
			{
				//				Marshal.ReleaseComObject(m_ttpVernWS);
				m_ttpVernWS = null;
			}
			if (m_ttpAnalWS != null)
			{
				//				Marshal.ReleaseComObject(m_ttpAnalWS);
				m_ttpAnalWS = null;
			}

			base.Dispose(disposing);
		}