Example #1
0
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();
			m_inMemoryCache.InitializeWritingSystemEncodings();

			// init the DummyBookMerger
			Debug.Assert(m_bookMerger == null, "m_bookMerger is not null.");
			m_bookMerger = new DummyBookMerger(Cache, null, m_genesisRevision);
			EnsureAnnDefn(LangProject.kguidAnnTextSegment);
			EnsureAnnDefn(LangProject.kguidAnnFreeTranslation);
			EnsureAnnDefn(LangProject.kguidAnnWordformInContext);
			EnsureAnnDefn(LangProject.kguidAnnPunctuationInContext);
			if (Cache.LangProject.WordformInventoryOA == null)
			{
				WordformInventory wfi = new WordformInventory();
				Cache.LangProject.WordformInventoryOA = wfi;
			}
		}
Example #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Completes the initialize. Every test needs to call this before initializing.
		/// We don't include this in the initialize run before every test because, if we want
		/// to create another archive, it will cause a crash.
		/// </summary>
		/// <param name="fMakePhilemonChanges">if <c>true</c> make changes in Philemon and
		/// detect differences</param>
		/// <param name="bookRev">the book to use for the revision in the bookmerger.</param>
		/// ------------------------------------------------------------------------------------
		private void CompleteInitialize(bool fMakePhilemonChanges, IScrBook bookRev)
		{
			Debug.Assert(m_bookMerger == null, "m_bookMerger is not null.");

			if (fMakePhilemonChanges)
			{
				m_philemonCurr = m_scr.FindBook(57);
				m_draft = m_scr.CreateSavedVersion("PhilemonArchive",
					new int[] {m_philemonCurr.Hvo});
				m_philemonRev = m_draft.FindBook(57);
				m_draft.Type = ScrDraftType.ImportedVersion;
			}
			//if (m_bookMerger != null)
			//	m_bookMerger.Dispose();
			m_bookMerger = new BookMerger(Cache, null, fMakePhilemonChanges ? m_philemonRev : bookRev);

			if (fMakePhilemonChanges)
			{
				MakeChangesInPhilemonCurrent();
				m_bookMerger.DetectDifferences(null);
				Assert.AreEqual(6, m_bookMerger.Differences.Count,
					"Problem in Initialize (unexpected number of diffs)");
			}

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

			Debug.Assert(m_dlg == null, "m_dlg is not null.");
			//if (m_dlg != null)
			//	m_dlg.Dispose();
			m_dlg = new DummyDiffDialog(m_bookMerger, Cache, m_styleSheet, null);
			m_dlg.CreateControl();

			// Pieces that may be needed for merging BT segments.
			using (new SuppressSubTasks(Cache))
			{
				EnsureAnnDefn(LangProject.kguidAnnTextSegment);
				EnsureAnnDefn(LangProject.kguidAnnFreeTranslation);
				EnsureAnnDefn(LangProject.kguidAnnWordformInContext);
				EnsureAnnDefn(LangProject.kguidAnnPunctuationInContext);
				if (Cache.LangProject.WordformInventoryOA == null)
				{
					WordformInventory wfi = new WordformInventory();
					Cache.LangProject.WordformInventoryOA = wfi;
				}
			}
		}
		private void RebuildConcordance(WordformInventory wfi, int kflidConcordanceWords)
		{
			IVwVirtualHandler vh = Cache.VwCacheDaAccessor.GetVirtualHandlerId(kflidConcordanceWords);
			vh.Load(wfi.Hvo, kflidConcordanceWords, 0, Cache.VwCacheDaAccessor);
			m_fdoCache.GetVectorProperty(wfi.Hvo, kflidConcordanceWords, false);
		}
Example #4
0
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();

			// init the DummyBookMerger
			Debug.Assert(m_bookMerger == null, "m_bookMerger is not null.");
			//if (m_bookMerger != null)
			//	m_bookMerger.Dispose();
			m_bookMerger = new DummyBookMerger(Cache, null, m_philemonRev);

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

			Debug.Assert(m_dlg == null, "m_dlg is not null.");
			//if (m_dlg != null)
			//	m_dlg.Dispose();
			m_dlg = new MockedCacheDiffDialog(m_bookMerger, Cache, m_styleSheet, null);

			ScriptureChangeWatcher.Create(Cache);

			// Additional pieces needed for Interlinear segment merging.
			EnsureAnnDefn(LangProject.kguidAnnTextSegment);
			EnsureAnnDefn(LangProject.kguidAnnFreeTranslation);
			EnsureAnnDefn(LangProject.kguidAnnWordformInContext);
			EnsureAnnDefn(LangProject.kguidAnnPunctuationInContext);
			if (Cache.LangProject.WordformInventoryOA == null)
			{
				WordformInventory wfi = new WordformInventory();
				Cache.LangProject.WordformInventoryOA = wfi;
			}
		}
		private void CheckExpectedWordformsAndOccurrences(WordformInventory wfi, Dictionary<string, int> expectedOccurrences)
		{
			int kflidWordformOccurrences = WfiWordform.OccurrencesFlid(Cache);
			// Get the words parsed while generating our list.
			Set<int> wordsCollected = ParagraphParser.WordformsFromLastParseSession(m_fdoCache);

			List<string> expectedWordforms = new List<string>(expectedOccurrences.Keys);
			foreach (string key in expectedWordforms)
			{
				int ichWs = key.IndexOfAny(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' });
				string form = key.Substring(0, ichWs);
				int ws = Convert.ToInt32(key.Substring(ichWs));
				int hvoWordform = wfi.GetWordformId(form, ws);
				Assert.AreNotEqual(0, hvoWordform, String.Format("Expected to find key {0} in ConcordanceWords.", key));
				Assert.Contains(hvoWordform, wordsCollected.ToArray(), "The wordforms collected in last parse session doesn't contain this id.");

				// see if we match the expected occurrences.
				int[] actualOccurrences = Cache.GetVectorProperty(hvoWordform, kflidWordformOccurrences, true);
				Assert.AreEqual(expectedOccurrences[key], actualOccurrences.Length,
					String.Format("Unexpected number of occurrences for wordform {0}", key));
			}
			Assert.AreEqual(expectedWordforms.Count, wordsCollected.Count, "Word count mismatch.");
		}