Exemple #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Update the existing categories and terms with new localized strings.
        /// </summary>
        /// <param name="dlg">The progress dialog.</param>
        /// <param name="parameters">The parameters: 1) the BiblicalTermsLocalization object
        /// representing the contents of the XML file with the localized strings; 2) The ICU
        /// locale (string).</param>
        /// <returns>always null</returns>
        /// ------------------------------------------------------------------------------------
        protected object UpdateLocalization(IThreadedProgress dlg, params object[] parameters)
        {
            BiblicalTermsLocalization loc = (BiblicalTermsLocalization)parameters[0];
            string locale = (string)parameters[1];

            const int kcStepsToBuildLookupTable = 4;

            dlg.Position = 0;
            dlg.Minimum  = 0;
            dlg.Maximum  = loc.Categories.Count + loc.Terms.Count + kcStepsToBuildLookupTable;
            dlg.Title    = TeResourceHelper.GetResourceString("kstidLoadKeyTermsInDBCaption");
            dlg.Message  = TeResourceHelper.FormatResourceString("kstidLoadKeyTermsLocalizations",
                                                                 m_wsf.get_Engine(locale).LanguageName);

            m_wsDefault = m_servLoc.WritingSystemManager.GetWsFromStr("en");

            int hvoLocWs = loc.WritingSystemHvo = m_wsf.GetWsFromStr(locale);

            IEnumerable <ICmPossibility> categories = ((ILangProject)m_scr.Owner).KeyTermsList.PossibilitiesOS;

            foreach (CategoryLocalization localizedCategory in loc.Categories)
            {
                ICmPossibility category = categories.FirstOrDefault(
                    p => p.Abbreviation.get_String(m_wsDefault).Text == localizedCategory.Id);
                if (category != null)
                {
                    category.Name.set_String(hvoLocWs, localizedCategory.Gloss);
                }
                dlg.Step(1);
            }

            Dictionary <int, IChkTerm> termLookupTable =
                m_servLoc.GetInstance <IChkTermRepository>().AllInstances().ToDictionary(t => t.TermId);

            dlg.Step(kcStepsToBuildLookupTable);

            IChkTerm term;
            string   message = TeResourceHelper.GetResourceString("kstidLoadKeyTermsInDBStatus");

            foreach (TermLocalization localizedTerm in loc.Terms)
            {
                dlg.Message = string.Format(message, localizedTerm.Gloss);

                if (termLookupTable.TryGetValue(localizedTerm.Id, out term))
                {
                    SetLocalizedGlossAndDescription(term, localizedTerm, loc.WritingSystemHvo);
                }
                dlg.Step(1);
            }
            return(null);
        }
Exemple #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets all the available Key Terms localizations.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected virtual List <BiblicalTermsLocalization> GetLocalizations()
        {
            int defaultUserWs = m_scr.Cache.DefaultUserWs;

            string[] locFiles = FwDirectoryFinder.KeyTermsLocalizationFiles;
            List <BiblicalTermsLocalization> localizations =
                new List <BiblicalTermsLocalization>(locFiles.Length);
            bool fFoundDefaultLoc = false;

            foreach (string localizationFile in locFiles)
            {
                int hvoWs = GetWsFromLocFile(m_wsf, localizationFile);
                if (hvoWs > 0)
                {
                    BiblicalTermsLocalization loc = DeserializeBiblicalTermsLocFile(localizationFile);
                    if (loc != null)
                    {
                        fFoundDefaultLoc    |= (hvoWs == defaultUserWs);
                        loc.WritingSystemHvo = hvoWs;
                        localizations.Add(loc);
                    }
                }
            }
            if (!fFoundDefaultLoc || localizations.Count == 0)
            {
                string icuLocale = m_wsf.GetStrFromWs(defaultUserWs);
                string message   = String.Format("File {0} is missing", FwDirectoryFinder.GetKeyTermsLocFilename(icuLocale));
                Debug.Fail(message);
                Logger.WriteEvent(message);
                if (icuLocale == "en" || localizations.Count == 0)
                {
#if !DEBUG
                    message = TeResourceHelper.GetResourceString("kstidInvalidInstallation");
#endif
                    throw new InstallationException(message, null);
                }
            }
            return(localizations);
        }
Exemple #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Deserializes a biblical terms localization file.
        /// </summary>
        /// <param name="filename">The filename.</param>
        /// <returns>a BiblicalTermsLocalization object</returns>
        /// ------------------------------------------------------------------------------------
        static protected BiblicalTermsLocalization DeserializeBiblicalTermsLocFile(string filename)
        {
            try
            {
                using (TextReader reader = new StreamReader(filename))
                {
                    XmlSerializer             deserializer = new XmlSerializer(typeof(BiblicalTermsLocalization));
                    BiblicalTermsLocalization data         =
                        (BiblicalTermsLocalization)deserializer.Deserialize(reader);
                    reader.Close();
                    return(data);
                }
            }
            catch (Exception e)
            {
                string message;
#if DEBUG
                message = "Error reading " + filename + ": file is missing or has invalid XML syntax.";
#else
                message = TeResourceHelper.GetResourceString("kstidInvalidInstallation");
#endif
                throw new InstallationException(message, e);
            }
        }
		public void UpgradeWhenExistingListHasRenderings()
		{
			CheckDisposed();

			ILangProject lp = m_fdoCache.LangProject;

			IWfiWordform abc = lp.WordformInventoryOA.AddRealWordform("abc", lp.DefaultVernacularWritingSystem);
			IWfiWordform def = lp.WordformInventoryOA.AddRealWordform("def", lp.DefaultVernacularWritingSystem);
			IWfiWordform ghi = lp.WordformInventoryOA.AddRealWordform("ghi", lp.DefaultVernacularWritingSystem);

			ICmPossibilityList oldKeyTermsList = new CmPossibilityList();
			lp.CheckListsOC.Add(oldKeyTermsList);
			ChkTerm term = new ChkTerm();
			oldKeyTermsList.PossibilitiesOS.Append(term);
			term.Name.SetAlternative("Abba", m_wsEn);
			term.Description.SetAlternative("Daddy", m_wsEn);
			AddOccurrenceToOldStyleSense(term, 41014036, abc, "abba", KeyTermRenderingStatus.Assigned);
			AddOccurrenceToOldStyleSense(term, 45008015, abc, "abba", KeyTermRenderingStatus.AutoAssigned);
			AddOccurrenceToOldStyleSense(term, 48004006, null, "abba"); // Not rendered
			AddOccurrenceToOldStyleSense(term, 48004007, abc, "abba"); // This one is not in new list

			term = new ChkTerm();
			oldKeyTermsList.PossibilitiesOS.Append(term);
			term.Name.SetAlternative("Angel", m_wsEn);
			ChkTerm subsense = new ChkTerm();
			term.SubPossibilitiesOS.Append(subsense);
			subsense.Name.SetAlternative("Heavenly being", m_wsEn);
			subsense.Description.SetAlternative("Supernatural being sent as a messenger from God", m_wsEn);
			AddOccurrenceToOldStyleSense(subsense, 040001020, def, "aggelos");
			AddOccurrenceToOldStyleSense(subsense, 040001024, ghi, "aggelos");
			AddOccurrenceToOldStyleSense(subsense, 040002013, null, "aggelos", KeyTermRenderingStatus.Ignored);

			subsense = new ChkTerm();
			term.SubPossibilitiesOS.Append(subsense);
			subsense.Name.SetAlternative("Demon", m_wsEn);
			subsense.Description.SetAlternative("A fallen angel", m_wsEn);
			AddOccurrenceToOldStyleSense(subsense, 040007022, null, "daimonion");

			BiblicalTermsList terms = new BiblicalTermsList();
			terms.Version = Guid.NewGuid();
			terms.KeyTerms = new List<Term>();
			terms.KeyTerms.Add(new Term(3, "KT", "\u03b1\u03b2\u03b2\u03b1", "Greek",
				"abba; father", null, null, 4101403603, 4500801516, 4800400618));
			terms.KeyTerms.Add(new Term(21, "KT", "\u1F04\u03B3\u03B3\u03B5\u03BB\u03BF\u03C2", "Greek",
				"angel", null, null, 04000102006, 04000102413, 04000201305));
			terms.KeyTerms.Add(new Term(363, "KT", "\u03B4\u03B1\u03B9\u03BC\u1F79\u03BD\u03B9\u03BF\u03BD-1",
				"Greek", "demon", "\u03B4\u03B1\u03B9\u03BC\u1F79\u03BD\u03B9\u03BF\u03BD",
				"\u03B4\u03B1\u03B9\u03BC\u03BF\u03BD\u1F77\u03B6\u03BF\u03BC\u03B1\u03B9, \u03B4\u03B1\u03B9\u03BC\u03BF\u03BD\u03B9\u1F7D\u03B4\u03B7\u03C2, \u03B4\u03B1\u1F77\u03BC\u03C9\u03BD",
				04000702219));

			List<BiblicalTermsLocalization> localizations = new List<BiblicalTermsLocalization>(1);
			BiblicalTermsLocalization loc = new BiblicalTermsLocalization(1);
			loc.WritingSystemHvo = m_wsEn;
			loc.Categories.Add(new CategoryLocalization("KT", "Key terms"));
			loc.Terms.Add(new TermLocalization(3, "abba; father", "title for God, literally dad"));
			localizations.Add(loc);

			// Load the terms
			ICmPossibilityList newChkTermsList = new CmPossibilityList();
			lp.CheckListsOC.Add(newChkTermsList);
			DummyTeKeyTermsInit.CallLoadKeyTerms(oldKeyTermsList, newChkTermsList, terms,
				localizations);

			int wsGreek = m_wsf.GetWsFromStr("grc");

			// Make sure the old list has been blown away
			// We can't do this now because we delete the list asynchronously
			// Assert.IsFalse(oldKeyTermsList.IsValidObject());
			oldKeyTermsList = null;

			// Make sure there is one category (possibility) in the new list
			ICmPossibility ktCategory = newChkTermsList.PossibilitiesOS[0];
			Assert.AreEqual("KT", ktCategory.Abbreviation.GetAlternative(m_wsEn));

			// Make sure there are three keyterms in that category
			Assert.AreEqual(3, ktCategory.SubPossibilitiesOS.Count);

			// Check the ChkTerm and ChkRefs for "abba"
			IChkTerm keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(3, keyterm.TermId);
			Assert.AreEqual("\u03b1\u03b2\u03b2\u03b1", keyterm.Name.GetAlternative(wsGreek));
			Assert.AreEqual("abba", keyterm.Name.GetAlternative(m_wsEn));
			Assert.AreEqual("title for God, literally dad",
				keyterm.Description.GetAlternative(m_wsEn).Text);
			Assert.AreEqual("father", keyterm.SeeAlso.GetAlternative(m_wsEn));
			Assert.AreEqual(1, keyterm.RenderingsOC.Count);
			ChkRendering abbaRendering = new ChkRendering(m_fdoCache, keyterm.RenderingsOC.HvoArray[0]);
			Assert.AreEqual(abc, abbaRendering.SurfaceFormRA);
			Assert.AreEqual(3, keyterm.OccurrencesOS.Count, "There should be 3 references for abba");
			Assert.AreEqual(KeyTermRenderingStatus.Assigned, keyterm.OccurrencesOS[0].Status);
			Assert.AreEqual(abc, keyterm.OccurrencesOS[0].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.AutoAssigned, keyterm.OccurrencesOS[1].Status);
			Assert.AreEqual(abc, keyterm.OccurrencesOS[1].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[2].Status);
			Assert.AreEqual(0, keyterm.OccurrencesOS[2].RenderingRAHvo);

			// Check the ChkRefs for "angel"
			keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[1];
			Assert.AreEqual(21, keyterm.TermId);
			Assert.AreEqual(2, keyterm.RenderingsOC.Count);
			bool fFoundDEF = false;
			bool fFoundGHI = false;
			foreach (IChkRendering rendering in keyterm.RenderingsOC)
			{
				fFoundDEF |= (rendering.SurfaceFormRAHvo == def.Hvo);
				fFoundGHI |= (rendering.SurfaceFormRAHvo == ghi.Hvo);
			}
			Assert.IsTrue(fFoundDEF);
			Assert.IsTrue(fFoundGHI);
			Assert.AreEqual(3, keyterm.OccurrencesOS.Count);
			Assert.AreEqual(KeyTermRenderingStatus.Assigned, keyterm.OccurrencesOS[0].Status);
			Assert.AreEqual(def, keyterm.OccurrencesOS[0].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Assigned, keyterm.OccurrencesOS[1].Status);
			Assert.AreEqual(ghi, keyterm.OccurrencesOS[1].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Ignored, keyterm.OccurrencesOS[2].Status);
			Assert.IsNull(keyterm.OccurrencesOS[2].RenderingRA);

			// Check the ChkRefs for "demon"
			keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[2];
			Assert.AreEqual(363, keyterm.TermId);
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);
			Assert.AreEqual(1, keyterm.OccurrencesOS.Count);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[0].Status);
			Assert.AreEqual(0, keyterm.OccurrencesOS[0].RenderingRAHvo);
		}
		public void SimpleUpgradeWhenExistingListHasNoRenderings()
		{
			CheckDisposed();

			ILangProject lp = m_fdoCache.LangProject;
			ICmPossibilityList oldKeyTermsList = new CmPossibilityList();
			lp.CheckListsOC.Add(oldKeyTermsList);
			ChkTerm term = new ChkTerm();
			oldKeyTermsList.PossibilitiesOS.Append(term);
			term.Name.SetAlternative("Abba", m_wsEn);
			term.Description.SetAlternative("Daddy", m_wsEn);
			AddOccurrenceToOldStyleSense(term, 41014036, null, "abba");

			term = new ChkTerm();
			oldKeyTermsList.PossibilitiesOS.Append(term);
			term.Name.SetAlternative("Angel", m_wsEn);
			ChkTerm subsense = new ChkTerm();
			term.SubPossibilitiesOS.Append(subsense);
			subsense.Name.SetAlternative("Heavenly being", m_wsEn);
			subsense.Description.SetAlternative("Supernatural being sent as a messenger from God", m_wsEn);
			AddOccurrenceToOldStyleSense(subsense, 040001020, null, "aggelos");

			subsense = new ChkTerm();
			term.SubPossibilitiesOS.Append(subsense);
			subsense.Name.SetAlternative("Demon", m_wsEn);
			subsense.Description.SetAlternative("A fallen angel", m_wsEn);
			AddOccurrenceToOldStyleSense(subsense, 040007022, null, "daimonion");

			BiblicalTermsList terms = new BiblicalTermsList();
			terms.Version = Guid.NewGuid();
			terms.KeyTerms = new List<Term>();
			terms.KeyTerms.Add(new Term(3, "KT", "\u03b1\u03b2\u03b2\u03b1", "Greek",
				"abba; father", null, null, 4101403603, 4500801516, 4800400618));
			terms.KeyTerms.Add(new Term(21, "KT", "\u1F04\u03B3\u03B3\u03B5\u03BB\u03BF\u03C2-1", "Greek",
				"angel", null, null, 040001020));
			terms.KeyTerms.Add(new Term(363, "KT", "\u03B4\u03B1\u03B9\u03BC\u1F79\u03BD\u03B9\u03BF\u03BD",
				"Greek", "demon", "\u1F04\u03B3\u03B3\u03B5\u03BB\u03BF\u03C2",
				"\u03B4\u03B1\u03B9\u03BC\u03BF\u03BD\u1F77\u03B6\u03BF\u03BC\u03B1\u03B9, \u03B4\u03B1\u03B9\u03BC\u03BF\u03BD\u03B9\u1F7D\u03B4\u03B7\u03C2, \u03B4\u03B1\u1F77\u03BC\u03C9\u03BD",
				040007022));

			List<BiblicalTermsLocalization> localizations = new List<BiblicalTermsLocalization>(1);
			BiblicalTermsLocalization loc = new BiblicalTermsLocalization(1);
			loc.WritingSystemHvo = m_wsEn;
			loc.Categories.Add(new CategoryLocalization("KT", "Key terms"));
			loc.Terms.Add(new TermLocalization(3, "abba; father", "title for God, literally dad"));
			localizations.Add(loc);

			// Load the terms
			ICmPossibilityList newChkTermsList = new CmPossibilityList();
			lp.CheckListsOC.Add(newChkTermsList);
			DummyTeKeyTermsInit.CallLoadKeyTerms(oldKeyTermsList, newChkTermsList, terms, localizations);

			int wsGreek = m_wsf.GetWsFromStr("grc");

			// Make sure the old list has been blown away
			// We can't do this now because we delete the list asynchronously
			// Assert.IsFalse(oldKeyTermsList.IsValidObject());
			oldKeyTermsList = null;

			// Make sure there is one category (possibility) in the new list
			Assert.AreEqual(1, newChkTermsList.PossibilitiesOS.Count);
			ICmPossibility ktCategory = newChkTermsList.PossibilitiesOS[0];
			Assert.AreEqual("KT", ktCategory.Abbreviation.GetAlternative(m_wsEn));

			// Make sure there are three keyterms in that category
			Assert.AreEqual(3, ktCategory.SubPossibilitiesOS.Count);

			// Look at the contents of the first ChkTerm
			IChkTerm keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(3, keyterm.TermId);
			Assert.AreEqual("\u03b1\u03b2\u03b2\u03b1", keyterm.Name.GetAlternative(wsGreek));
			Assert.AreEqual("abba", keyterm.Name.GetAlternative(m_wsEn));
			Assert.AreEqual("title for God, literally dad",
				keyterm.Description.GetAlternative(m_wsEn).Text);
			Assert.AreEqual("father", keyterm.SeeAlso.GetAlternative(m_wsEn));
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);
			Assert.AreEqual(3, keyterm.OccurrencesOS.Count, "There should be 3 references for abba");
			Assert.AreEqual(0, keyterm.OccurrencesOS[0].RenderingRAHvo);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[0].Status);
			Assert.AreEqual(0, keyterm.OccurrencesOS[1].RenderingRAHvo);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[1].Status);
			Assert.AreEqual(0, keyterm.OccurrencesOS[2].RenderingRAHvo);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[2].Status);

			// Briefly check the other two ChkTerms
			keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[1];
			Assert.AreEqual(21, keyterm.TermId);
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);
			Assert.AreEqual(1, keyterm.OccurrencesOS.Count);
			Assert.AreEqual(0, keyterm.OccurrencesOS[0].RenderingRAHvo);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[0].Status);

			keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[2];
			Assert.AreEqual(363, keyterm.TermId);
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);
			Assert.AreEqual(1, keyterm.OccurrencesOS.Count);
			Assert.AreEqual(0, keyterm.OccurrencesOS[0].RenderingRAHvo);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[0].Status);

			bool fFoundResource = false;
			foreach (CmResource resource in lp.TranslatedScriptureOA.ResourcesOC)
			{
				if (resource.Name == "BiblicalTerms")
				{
					Assert.AreEqual(terms.Version, resource.Version);
					fFoundResource = true;
				}
			}
			Assert.IsTrue(fFoundResource);
		}
		public void MultipleLocalizations()
		{
			CheckDisposed();

			BiblicalTermsList terms = new BiblicalTermsList();
			terms.Version = Guid.NewGuid();
			terms.KeyTerms = new List<Term>();
			terms.KeyTerms.Add(new Term(3, "KT", "\u03b1\u03b2\u03b2\u03b1", "Greek",
				"abba; father", null, null, 4101403603));

			List<BiblicalTermsLocalization> localizations = new List<BiblicalTermsLocalization>(2);
			BiblicalTermsLocalization loc = new BiblicalTermsLocalization(1);
			loc.WritingSystemHvo = m_wsEn;
			loc.Categories.Add(new CategoryLocalization("KT", "Key terms"));
			loc.Terms.Add(new TermLocalization(3, "abba; father", "title for God, literally dad"));
			localizations.Add(loc);
			loc = new BiblicalTermsLocalization(1);
			int wsEs = m_wsf.GetWsFromStr("es");
			loc.WritingSystemHvo = wsEs;
			loc.Categories.Add(new CategoryLocalization("KT", "Palabras claves"));
			loc.Terms.Add(new TermLocalization(3, "abba; padre", "t\u00EDtulo de Dios, literalmente pap\u00E1"));
			localizations.Add(loc);

			ILangProject lp = m_fdoCache.LangProject;
			ICmPossibilityList chkTermsList = new CmPossibilityList();
			lp.CheckListsOC.Add(chkTermsList);

			// Load the term
			DummyTeKeyTermsInit.CallLoadKeyTerms(chkTermsList, terms, localizations);

			// Make sure there is one category (possibility)
			Assert.AreEqual(1, chkTermsList.PossibilitiesOS.Count);
			ICmPossibility ktCategory = chkTermsList.PossibilitiesOS[0];
			Assert.AreEqual("KT", ktCategory.Abbreviation.GetAlternative(m_wsEn));
			Assert.AreEqual("Key terms", ktCategory.Name.GetAlternative(m_wsEn));
			Assert.AreEqual("Palabras claves", ktCategory.Name.GetAlternative(wsEs));

			// Make sure there is one keyterm in that category
			Assert.AreEqual(1, ktCategory.SubPossibilitiesOS.Count);

			// Look at the contents of the ChkTerm
			IChkTerm keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(3, keyterm.TermId);
			// Check the English localization
			Assert.AreEqual("abba", keyterm.Name.GetAlternative(m_wsEn));
			Assert.AreEqual("title for God, literally dad",
				keyterm.Description.GetAlternative(m_wsEn).Text);
			Assert.AreEqual("father", keyterm.SeeAlso.GetAlternative(m_wsEn));

			// Check the Spanish localization
			Assert.AreEqual("abba", keyterm.Name.GetAlternative(wsEs));
			Assert.AreEqual("t\u00EDtulo de Dios, literalmente pap\u00E1",
				keyterm.Description.GetAlternative(wsEs).Text);
			Assert.AreEqual("padre", keyterm.SeeAlso.GetAlternative(wsEs));
		}
		public void TwoCategoriesChkTermInit()
		{
			CheckDisposed();

			BiblicalTermsList terms = new BiblicalTermsList();
			terms.Version = Guid.NewGuid();
			terms.KeyTerms = new List<Term>();
			// Using asterisks to ensure that localizations are coming from localizations, not from
			// base key terms list.
			terms.KeyTerms.Add(new Term(1, "PN", "\u1F08\u03B1\u03C1\u1F7D\u03BD", "Greek",
				"Aaron***", null, null, 4200100522, 4400704003));
			terms.KeyTerms.Add(new Term(3, "KT", "\u03b1\u03b2\u03b2\u03b1", "Greek",
				"abba***; father***", null, null, 4101403603));
			terms.KeyTerms.Add(new Term(7325, "PN",
				"\u05DB\u05BC\u05B7\u05D1\u05BC\u05D5\u05B9\u05DF", "Hebrew",
				"Cabbon***", null, null, 601504001));

			ILangProject lp = m_fdoCache.LangProject;
			ICmPossibilityList chkTermsList = new CmPossibilityList();
			lp.CheckListsOC.Add(chkTermsList);

			List<BiblicalTermsLocalization> localizations = new List<BiblicalTermsLocalization>(1);
			BiblicalTermsLocalization loc = new BiblicalTermsLocalization(3);
			loc.WritingSystemHvo = m_wsEn;
			loc.Categories.Add(new CategoryLocalization("KT", "Key terms"));
			loc.Categories.Add(new CategoryLocalization("PN", "Proper names"));
			loc.Terms.Add(new TermLocalization(1, "Aaron", "the elder brother of Moses"));
			loc.Terms.Add(new TermLocalization(3, "abba; father", "title for God, literally dad"));
			loc.Terms.Add(new TermLocalization(7325, "Cabbon", "town; territory of Judah"));
			localizations.Add(loc);

			// Load the terms
			DummyTeKeyTermsInit.CallLoadKeyTerms(chkTermsList, terms, localizations);

			int wsGreek = m_wsf.GetWsFromStr("grc");
			int wsHebrew = m_wsf.GetWsFromStr("hbo");

			// Make sure there are two categories (possibilities)
			Assert.AreEqual(2, chkTermsList.PossibilitiesOS.Count);
			ICmPossibility ktCategory = null, pnCategory = null;
			foreach (ICmPossibility cat in chkTermsList.PossibilitiesOS)
			{
				string catNameEn = cat.Name.GetAlternative(m_wsEn);
				switch (catNameEn)
				{
					case "Key terms": ktCategory = cat; break;
					case "Proper names": pnCategory = cat; break;
					default: Assert.Fail("Unexpected category in the list: " + catNameEn); break;
				}
			}

			// ********* Key Term Category **********
			Assert.IsNotNull(ktCategory);
			// Make sure there is one keyterm (possibility)
			Assert.AreEqual(1, ktCategory.SubPossibilitiesOS.Count);

			// Look at the contents of the ChkTerm
			IChkTerm keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(3, keyterm.TermId);
			Assert.AreEqual("\u03b1\u03b2\u03b2\u03b1", keyterm.Name.GetAlternative(wsGreek));
			Assert.AreEqual("abba", keyterm.Name.GetAlternative(m_wsEn));
			Assert.AreEqual("father", keyterm.SeeAlso.GetAlternative(m_wsEn));
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);

			// There should be 1 reference for this key term
			Assert.AreEqual(1, keyterm.OccurrencesOS.Count);

			IChkRef reference = keyterm.OccurrencesOS[0];
			Assert.AreEqual(41014036, reference.Ref);
			Assert.AreEqual("\u03b1\u03b2\u03b2\u03b1", reference.KeyWord.Text);
			Assert.AreEqual(3, reference.Location);

			// ********* Proper Names Category **********
			Assert.IsNotNull(pnCategory);
			Assert.AreEqual("PN", pnCategory.Abbreviation.GetAlternative(m_wsEn));

			// Make sure there are two terms (possibilities)
			Assert.AreEqual(2, pnCategory.SubPossibilitiesOS.Count);

			// Look at the contents of the first Proper Name
			IChkTerm pnAaron = (IChkTerm)pnCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(1, pnAaron.TermId);
			Assert.AreEqual("\u1F08\u03B1\u03C1\u1F7D\u03BD", pnAaron.Name.GetAlternative(wsGreek));
			Assert.AreEqual("Aaron", pnAaron.Name.GetAlternative(m_wsEn));
			Assert.IsNull(pnAaron.SeeAlso.GetAlternative(m_wsEn));
			Assert.AreEqual(0, pnAaron.RenderingsOC.Count);

			// There should be 2 references for this key term
			Assert.AreEqual(2, pnAaron.OccurrencesOS.Count);

			reference = pnAaron.OccurrencesOS[0];
			Assert.AreEqual(42001005, reference.Ref);
			Assert.AreEqual("\u1F08\u03B1\u03C1\u1F7D\u03BD", reference.KeyWord.Text);
			Assert.AreEqual(22, reference.Location);

			reference = pnAaron.OccurrencesOS[1];
			Assert.AreEqual(44007040, reference.Ref);
			Assert.AreEqual("\u1F08\u03B1\u03C1\u1F7D\u03BD", reference.KeyWord.Text);
			Assert.AreEqual(3, reference.Location);

			// Look at the contents of the second Proper Name
			IChkTerm pnCabbon = (IChkTerm)pnCategory.SubPossibilitiesOS[1];
			Assert.AreEqual(7325, pnCabbon.TermId);
			Assert.AreEqual("\u05DB\u05BC\u05B7\u05D1\u05BC\u05D5\u05B9\u05DF",
				pnCabbon.Name.GetAlternative(wsHebrew));
			Assert.AreEqual("Cabbon", pnCabbon.Name.GetAlternative(m_wsEn));
			Assert.IsNull(pnCabbon.SeeAlso.GetAlternative(m_wsEn));
			Assert.AreEqual(0, pnCabbon.RenderingsOC.Count);

			// There should be 1 reference for this key term
			Assert.AreEqual(1, pnCabbon.OccurrencesOS.Count);

			reference = pnCabbon.OccurrencesOS[0];
			Assert.AreEqual(6015040, reference.Ref);
			Assert.AreEqual("\u05DB\u05BC\u05B7\u05D1\u05BC\u05D5\u05B9\u05DF",
				reference.KeyWord.Text);
			Assert.AreEqual(1, reference.Location);
		}
		public void KeyTermInit_NullDescription()
		{
			CheckDisposed();

			BiblicalTermsList terms = new BiblicalTermsList();
			terms.Version = Guid.NewGuid();
			terms.KeyTerms = new List<Term>();
			terms.KeyTerms.Add(new Term(56, "FA", "\u1F00\u03B5\u03C4\u1F79\u03C2", "Greek",
				"eagle; vulture", null, null,
				4002402809, 4201703717, 6600400728, 6600801306, 6601201409));

			List<BiblicalTermsLocalization> localizations = new List<BiblicalTermsLocalization>(1);
			BiblicalTermsLocalization loc = new BiblicalTermsLocalization(1);
			loc.WritingSystemHvo = m_wsEn;
			loc.Categories.Add(new CategoryLocalization("FA", "Fauna"));
			loc.Terms.Add(new TermLocalization(56, "eagle; vulture", null));
			localizations.Add(loc);

			ILangProject lp = m_fdoCache.LangProject;
			ICmPossibilityList chkTermsList = new CmPossibilityList();
			lp.CheckListsOC.Add(chkTermsList);

			// Load the term
			DummyTeKeyTermsInit.CallLoadKeyTerms(chkTermsList, terms, localizations);

			int wsGreek = m_wsf.GetWsFromStr("grc");

			// Make sure there is one category (possibility)
			Assert.AreEqual(1, chkTermsList.PossibilitiesOS.Count);
			ICmPossibility faCategory = chkTermsList.PossibilitiesOS[0];
			Assert.AreEqual("FA", faCategory.Abbreviation.GetAlternative(m_wsEn));

			// Make sure there is one entry in the Fauna category
			Assert.AreEqual(1, faCategory.SubPossibilitiesOS.Count);

			// Look at the contents of the ChkTerm
			IChkTerm keyterm = (IChkTerm)faCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(56, keyterm.TermId);
			Assert.AreEqual("\u1F00\u03B5\u03C4\u1F79\u03C2", keyterm.Name.GetAlternative(wsGreek));
			Assert.AreEqual("eagle", keyterm.Name.GetAlternative(m_wsEn));
			Assert.IsNull(keyterm.Description.GetAlternative(m_wsEn).Text);
			Assert.AreEqual("vulture", keyterm.SeeAlso.GetAlternative(m_wsEn));
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);

			// There should be 5 references for this key term
			Assert.AreEqual(5, keyterm.OccurrencesOS.Count);

			IChkRef reference = keyterm.OccurrencesOS[0];
			Assert.AreEqual(40024028, reference.Ref);
			Assert.AreEqual("\u1F00\u03B5\u03C4\u1F79\u03C2", reference.KeyWord.Text);
			Assert.AreEqual(9, reference.Location);

			reference = keyterm.OccurrencesOS[1];
			Assert.AreEqual(42017037, reference.Ref);
			Assert.AreEqual("\u1F00\u03B5\u03C4\u1F79\u03C2", reference.KeyWord.Text);
			Assert.AreEqual(17, reference.Location);

			reference = keyterm.OccurrencesOS[2];
			Assert.AreEqual(66004007, reference.Ref);
			Assert.AreEqual("\u1F00\u03B5\u03C4\u1F79\u03C2", reference.KeyWord.Text);
			Assert.AreEqual(28, reference.Location);

			reference = keyterm.OccurrencesOS[3];
			Assert.AreEqual(66008013, reference.Ref);
			Assert.AreEqual("\u1F00\u03B5\u03C4\u1F79\u03C2", reference.KeyWord.Text);
			Assert.AreEqual(6, reference.Location);

			reference = keyterm.OccurrencesOS[4];
			Assert.AreEqual(66012014, reference.Ref);
			Assert.AreEqual("\u1F00\u03B5\u03C4\u1F79\u03C2", reference.KeyWord.Text);
			Assert.AreEqual(9, reference.Location);

			bool fFoundResource = false;
			foreach (CmResource resource in lp.TranslatedScriptureOA.ResourcesOC)
			{
				if (resource.Name == "BiblicalTerms")
				{
					Assert.AreEqual(terms.Version, resource.Version);
					fFoundResource = true;
				}
			}
			Assert.IsTrue(fFoundResource);
		}
		public void StripOffSenseNumbers()
		{
			CheckDisposed();

			BiblicalTermsList terms = new BiblicalTermsList();
			terms.Version = Guid.NewGuid();
			terms.KeyTerms = new List<Term>();
			terms.KeyTerms.Add(new Term(13, "KT", "\u1F00\u03B3\u03B1\u03B8\u03BF\u03C2-1", "Greek",
				"good; goodness; good act",
				"\u1F00\u03B3\u03B1\u03B8\u03BF\u03C2, \u1F00\u03B3\u03B1\u03B8\u03C9\u03C3\u1F7B\u03BD\u03B7",
				"\u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u1F73\u03C9, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u03B9\u03B1, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u1F79\u03C2, \u1F00\u03B3\u03B1\u03B8\u03C9\u03C3\u1F7B\u03BD\u03B7, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C5\u03C1\u03B3\u03B5\u03C9",
				04000504518, 04001203405, 04001203502));
			terms.KeyTerms.Add(new Term(14, "KT", "\u1F00\u03B3\u03B1\u03B8\u03BF\u03C2-2", "Greek",
				"do good; perform good deeds; good works",
				"\u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u03B9\u03B1, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u1F73\u03C9, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C5\u03C1\u03B3\u03B5\u03C9",
				"\u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u1F73\u03C9, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u03B9\u03B1, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u1F79\u03C2, \u1F00\u03B3\u03B1\u03B8\u03C9\u03C3\u1F7B\u03BD\u03B7, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C5\u03C1\u03B3\u03B5\u03C9",
				04200600913, 04200603304));
			terms.KeyTerms.Add(new Term(15, "KT", "\u1F00\u03B3\u03B1\u03B8\u03BF\u03C2-3", "Greek",
				"one who does good; one who benefits others",
				"\u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u1F79\u03C2",
				"\u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u1F73\u03C9, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u03B9\u03B1, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u1F79\u03C2, \u1F00\u03B3\u03B1\u03B8\u03C9\u03C3\u1F7B\u03BD\u03B7, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C5\u03C1\u03B3\u03B5\u03C9",
				06000201412));
			terms.KeyTerms.Add(new Term(98, "PN", "\u1F08\u03BB\u1F73\u03BE\u03B1\u03BD\u03B4\u03C1\u03BF\u03C2-1",
				"Greek", "Alexander", null, null, 04101502112));

			List<BiblicalTermsLocalization> localizations = new List<BiblicalTermsLocalization>(1);
			BiblicalTermsLocalization loc = new BiblicalTermsLocalization(3);
			loc.WritingSystemHvo = m_wsEn;
			loc.Categories.Add(new CategoryLocalization("KT", "Key terms"));
			loc.Terms.Add(new TermLocalization(13, "good; goodness; good act", "positive moral qualities of the most general nature"));
			loc.Terms.Add(new TermLocalization(14, "do good; perform good deeds; good works", "to engage in doing what is good"));
			loc.Terms.Add(new TermLocalization(15, "one who does good; one who benefits others", "one who customarily does good"));
			localizations.Add(loc);

			ILangProject lp = m_fdoCache.LangProject;
			ICmPossibilityList chkTermsList = new CmPossibilityList();
			lp.CheckListsOC.Add(chkTermsList);

			// Load the term
			DummyTeKeyTermsInit.CallLoadKeyTerms(chkTermsList, terms, localizations);

			int wsGreek = m_wsf.GetWsFromStr("grc");

			// Make sure there are two categories (possibilities)
			Assert.AreEqual(2, chkTermsList.PossibilitiesOS.Count);
			ICmPossibility ktCategory = null, pnCategory = null;
			foreach (ICmPossibility cat in chkTermsList.PossibilitiesOS)
			{
				string catNameEn = cat.Abbreviation.GetAlternative(m_wsEn);
				switch (catNameEn)
				{
					case "KT": ktCategory = cat; break;
					case "PN": pnCategory = cat; break;
					default: Assert.Fail("Unexpected category in the list: " + catNameEn); break;
				}
			}

			// Make sure there are three key terms in the KT category
			Assert.AreEqual(3, ktCategory.SubPossibilitiesOS.Count);

			// Look at the contents of each ChkTerm
			IChkTerm keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(13, keyterm.TermId);
			Assert.AreEqual("\u1F00\u03B3\u03B1\u03B8\u03BF\u03C2", keyterm.Name.GetAlternative(wsGreek));
			Assert.AreEqual("good", keyterm.Name.GetAlternative(m_wsEn));
			Assert.AreEqual("positive moral qualities of the most general nature",
				keyterm.Description.GetAlternative(m_wsEn).Text);
			Assert.AreEqual("goodness; good act", keyterm.SeeAlso.GetAlternative(m_wsEn));
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);
			Assert.AreEqual(3, keyterm.OccurrencesOS.Count);
			Assert.AreEqual("\u1F00\u03B3\u03B1\u03B8\u03BF\u03C2, \u1F00\u03B3\u03B1\u03B8\u03C9\u03C3\u1F7B\u03BD\u03B7",
				keyterm.OccurrencesOS[0].KeyWord.Text);

			keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[1];
			Assert.AreEqual(14, keyterm.TermId);
			Assert.AreEqual("\u1F00\u03B3\u03B1\u03B8\u03BF\u03C2", keyterm.Name.GetAlternative(wsGreek));
			Assert.AreEqual("do good", keyterm.Name.GetAlternative(m_wsEn));
			Assert.AreEqual(2, keyterm.OccurrencesOS.Count);
			Assert.AreEqual("\u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u03B9\u03B1, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u1F73\u03C9, \u1F00\u03B3\u03B1\u03B8\u03BF\u03C5\u03C1\u03B3\u03B5\u03C9",
				keyterm.OccurrencesOS[0].KeyWord.Text);

			keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[2];
			Assert.AreEqual(15, keyterm.TermId);
			Assert.AreEqual("\u1F00\u03B3\u03B1\u03B8\u03BF\u03C2", keyterm.Name.GetAlternative(wsGreek));
			Assert.AreEqual("one who does good", keyterm.Name.GetAlternative(m_wsEn));
			Assert.AreEqual(1, keyterm.OccurrencesOS.Count);
			Assert.AreEqual("\u1F00\u03B3\u03B1\u03B8\u03BF\u03C0\u03BF\u03B9\u1F79\u03C2",
				keyterm.OccurrencesOS[0].KeyWord.Text);

			// Make sure there is one term in the PN category
			Assert.AreEqual(1, pnCategory.SubPossibilitiesOS.Count);

			// Check the contents and occurrences of the ChkTerm
			IChkTerm pnTerm = (IChkTerm)pnCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(98, pnTerm.TermId);
			Assert.AreEqual("\u1F08\u03BB\u1F73\u03BE\u03B1\u03BD\u03B4\u03C1\u03BF\u03C2", pnTerm.Name.GetAlternative(wsGreek));
			Assert.AreEqual(1, pnTerm.OccurrencesOS.Count);
			Assert.AreEqual("\u1F08\u03BB\u1F73\u03BE\u03B1\u03BD\u03B4\u03C1\u03BF\u03C2",
				pnTerm.OccurrencesOS[0].KeyWord.Text);
		}
		public void SimpleKeyTermInit()
		{
			CheckDisposed();

			BiblicalTermsList terms = new BiblicalTermsList();
			terms.Version = Guid.NewGuid();
			terms.KeyTerms = new List<Term>();
			terms.KeyTerms.Add(new Term(3, "KT", "\u03b1\u03b2\u03b2\u03b1", "Greek",
				"abba; father", null, null,
				4101403603, 4500801516, 4800400618));

			List<BiblicalTermsLocalization> localizations = new List<BiblicalTermsLocalization>(1);
			BiblicalTermsLocalization loc = new BiblicalTermsLocalization(1);
			loc.WritingSystemHvo = m_wsEn;
			loc.Categories.Add(new CategoryLocalization("KT", "Key terms"));
			loc.Terms.Add(new TermLocalization(3, "abba; father", "title for God, literally dad"));
			localizations.Add(loc);

			ILangProject lp = m_fdoCache.LangProject;
			ICmPossibilityList chkTermsList = new CmPossibilityList();
			lp.CheckListsOC.Add(chkTermsList);

			// Load the term
			DummyTeKeyTermsInit.CallLoadKeyTerms(chkTermsList, terms, localizations);

			int wsGreek = m_wsf.GetWsFromStr("grc");

			// Make sure there is one category (possibility)
			Assert.AreEqual(1, chkTermsList.PossibilitiesOS.Count);
			ICmPossibility ktCategory = chkTermsList.PossibilitiesOS[0];
			Assert.AreEqual("KT", ktCategory.Abbreviation.GetAlternative(m_wsEn));

			// Make sure there is one keyterm in that category
			Assert.AreEqual(1, ktCategory.SubPossibilitiesOS.Count);

			// Look at the contents of the ChkTerm
			IChkTerm keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(3, keyterm.TermId);
			Assert.AreEqual("\u03b1\u03b2\u03b2\u03b1", keyterm.Name.GetAlternative(wsGreek));
			Assert.AreEqual("abba", keyterm.Name.GetAlternative(m_wsEn));
			Assert.AreEqual("title for God, literally dad",
				keyterm.Description.GetAlternative(m_wsEn).Text);
			Assert.AreEqual("father", keyterm.SeeAlso.GetAlternative(m_wsEn));
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);

			// There should be 3 references for this key term
			Assert.AreEqual(3, keyterm.OccurrencesOS.Count);

			IChkRef reference = keyterm.OccurrencesOS[0];
			Assert.AreEqual(41014036, reference.Ref);
			Assert.AreEqual("\u03b1\u03b2\u03b2\u03b1", reference.KeyWord.Text);
			Assert.AreEqual(3, reference.Location);

			reference = keyterm.OccurrencesOS[1];
			Assert.AreEqual(45008015, reference.Ref);
			Assert.AreEqual("\u03b1\u03b2\u03b2\u03b1", reference.KeyWord.Text);
			Assert.AreEqual(16, reference.Location);

			reference = keyterm.OccurrencesOS[2];
			Assert.AreEqual(48004006, reference.Ref);
			Assert.AreEqual("\u03b1\u03b2\u03b2\u03b1", reference.KeyWord.Text);
			Assert.AreEqual(18, reference.Location);

			bool fFoundResource = false;
			foreach (CmResource resource in lp.TranslatedScriptureOA.ResourcesOC)
			{
				if (resource.Name == "BiblicalTerms")
				{
					Assert.AreEqual(terms.Version, resource.Version);
					fFoundResource = true;
				}
			}
			Assert.IsTrue(fFoundResource);
		}
		public void SimpleUpgradeWhenExistingListHasNoRenderings()
		{
			ICmPossibilityList oldKeyTermsList = Cache.LangProject.KeyTermsList;
			IChkTerm term = Cache.ServiceLocator.GetInstance<IChkTermFactory>().Create();
			oldKeyTermsList.PossibilitiesOS.Add(term);
			term.Name.set_String(m_wsEn, "Abba");
			term.Description.set_String(m_wsEn, "Daddy");
			AddOccurrenceToOldStyleSense(term, 41014036, null, "abba");

			term = Cache.ServiceLocator.GetInstance<IChkTermFactory>().Create();
			oldKeyTermsList.PossibilitiesOS.Add(term);
			term.Name.set_String(m_wsEn, "Angel");
			IChkTerm subsense = Cache.ServiceLocator.GetInstance<IChkTermFactory>().Create();
			term.SubPossibilitiesOS.Add(subsense);
			subsense.Name.set_String(m_wsEn, "Heavenly being");
			subsense.Description.set_String(m_wsEn, "Supernatural being sent as a messenger from God");
			AddOccurrenceToOldStyleSense(subsense, 040001020, null, "aggelos");

			subsense = Cache.ServiceLocator.GetInstance<IChkTermFactory>().Create();
			term.SubPossibilitiesOS.Add(subsense);
			subsense.Name.set_String(m_wsEn, "Demon");
			subsense.Description.set_String(m_wsEn, "A fallen angel");
			AddOccurrenceToOldStyleSense(subsense, 040007022, null, "daimonion");

			Assert.AreEqual(2, Cache.LangProject.KeyTermsList.PossibilitiesOS.Count);

			BiblicalTermsList terms = new BiblicalTermsList();
			terms.Version = new Guid("00FEA689-3B63-4bd4-B640-7262A274D1A8");
			terms.KeyTerms = new List<Term>();
			terms.KeyTerms.Add(new Term(3, "KT", "\u03b1\u03b2\u03b2\u03b1", "Greek",
				"abba; father", null, null, 4101403603, 4500801516, 4800400618));
			terms.KeyTerms.Add(new Term(21, "KT", "\u1F04\u03B3\u03B3\u03B5\u03BB\u03BF\u03C2-1", "Greek",
				"angel", null, null, 040001020));
			terms.KeyTerms.Add(new Term(363, "KT", "\u03B4\u03B1\u03B9\u03BC\u1F79\u03BD\u03B9\u03BF\u03BD",
				"Greek", "demon", "\u1F04\u03B3\u03B3\u03B5\u03BB\u03BF\u03C2",
				"\u03B4\u03B1\u03B9\u03BC\u03BF\u03BD\u1F77\u03B6\u03BF\u03BC\u03B1\u03B9, \u03B4\u03B1\u03B9\u03BC\u03BF\u03BD\u03B9\u1F7D\u03B4\u03B7\u03C2, \u03B4\u03B1\u1F77\u03BC\u03C9\u03BD",
				040007022));

			List<BiblicalTermsLocalization> localizations = new List<BiblicalTermsLocalization>(1);
			BiblicalTermsLocalization loc = new BiblicalTermsLocalization(1);
			loc.WritingSystemHvo = m_wsEn;
			loc.Categories.Add(new CategoryLocalization("KT", "Key terms"));
			loc.Terms.Add(new TermLocalization(3, "abba; father", "title for God, literally dad"));
			localizations.Add(loc);

			// Load the terms
			var ktInitializer =	new DummyTeKeyTermsInit(m_scr);
			ktInitializer.m_localizations = localizations;
			var mockProgressDlg = MockRepository.GenerateMock<IProgress>();

			ktInitializer.CallCreateKeyTerms(mockProgressDlg, terms);
			ICmPossibilityList newChkTermsList = Cache.LangProject.KeyTermsList;

			int wsGreek = m_wsf.GetWsFromStr("grc");

			// Make sure there is one category (possibility) in the new list
			Assert.AreEqual(1, newChkTermsList.PossibilitiesOS.Count);
			ICmPossibility ktCategory = newChkTermsList.PossibilitiesOS[0];
			Assert.AreEqual("KT", ktCategory.Abbreviation.get_String(m_wsEn).Text);

			// Make sure there are three keyterms in that category
			Assert.AreEqual(3, ktCategory.SubPossibilitiesOS.Count);

			// Look at the contents of the first ChkTerm ("abba")
			IChkTerm keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(3, keyterm.TermId);
			Assert.AreEqual("\u03b1\u03b2\u03b2\u03b1", keyterm.Name.get_String(wsGreek).Text);
			Assert.AreEqual("abba", keyterm.Name.get_String(m_wsEn).Text);
			Assert.AreEqual("title for God, literally dad",
				keyterm.Description.get_String(m_wsEn).Text);
			Assert.AreEqual("father", keyterm.SeeAlso.get_String(m_wsEn).Text);
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);
			Assert.AreEqual(3, keyterm.OccurrencesOS.Count, "There should be 3 references for abba");
			Assert.IsNull(keyterm.OccurrencesOS[0].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[0].Status);
			Assert.IsNull(keyterm.OccurrencesOS[1].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[1].Status);
			Assert.IsNull(keyterm.OccurrencesOS[2].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[2].Status);

			// Briefly check the other two ChkTerms
			keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[1];
			Assert.AreEqual(21, keyterm.TermId);
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);
			Assert.AreEqual(1, keyterm.OccurrencesOS.Count);
			Assert.IsNull(keyterm.OccurrencesOS[0].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[0].Status);

			keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[2];
			Assert.AreEqual(363, keyterm.TermId);
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);
			Assert.AreEqual(1, keyterm.OccurrencesOS.Count);
			Assert.IsNull(keyterm.OccurrencesOS[0].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[0].Status);

			bool fFoundResource = false;
			foreach (ICmResource resource in m_lp.TranslatedScriptureOA.ResourcesOC)
			{
				if (resource.Name == "BiblicalTerms")
				{
					Assert.AreEqual(terms.Version, resource.Version);
					fFoundResource = true;
				}
			}
			Assert.IsTrue(fFoundResource);
		}
		public void KeyTermInit_DashDescription()
		{
			BiblicalTermsList terms = new BiblicalTermsList();
			terms.Version = Guid.NewGuid();
			terms.KeyTerms = new List<Term>();
			terms.KeyTerms.Add(new Term(56, "FA", "\u1F00\u03B5\u03C4\u1F79\u03C2", "Greek",
				"eagle; vulture", null, null,
				4002402809, 4201703717, 6600400728, 6600801306, 6601201409));

			List<BiblicalTermsLocalization> localizations = new List<BiblicalTermsLocalization>(1);
			BiblicalTermsLocalization loc = new BiblicalTermsLocalization(1);
			loc.WritingSystemHvo = m_wsEn;
			loc.Categories.Add(new CategoryLocalization("FA", "Fauna"));
			loc.Terms.Add(new TermLocalization(56, "eagle; vulture", "\t-"));
			localizations.Add(loc);

			ICmPossibilityList chkTermsList = Cache.ServiceLocator.GetInstance<ICmPossibilityListFactory>().Create();
			m_lp.CheckListsOC.Add(chkTermsList);

			// Load the term
			m_actionHandler.EndUndoTask();
			try
			{
				using (NonUndoableUnitOfWorkHelper undoHelper = new NonUndoableUnitOfWorkHelper(m_actionHandler))
				{
					DummyTeKeyTermsInit.CallLoadKeyTerms(chkTermsList, terms, localizations);

					undoHelper.RollBack = false;
				}
			}
			finally
			{
				m_actionHandler.BeginUndoTask("bla", "bla");
			}

			int wsGreek = m_wsf.GetWsFromStr("grc");

			// Make sure there is one category (possibility)
			Assert.AreEqual(1, chkTermsList.PossibilitiesOS.Count);
			ICmPossibility faCategory = chkTermsList.PossibilitiesOS[0];
			Assert.AreEqual("FA", faCategory.Abbreviation.get_String(m_wsEn).Text);

			// Make sure there is one entry in the Fauna category
			Assert.AreEqual(1, faCategory.SubPossibilitiesOS.Count);

			// Look at the contents of the ChkTerm
			IChkTerm keyterm = (IChkTerm)faCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(56, keyterm.TermId);
			Assert.AreEqual("\u1F00\u03B5\u03C4\u1F79\u03C2".Normalize(NormalizationForm.FormD), keyterm.Name.get_String(wsGreek).Text);
			Assert.AreEqual("eagle", keyterm.Name.get_String(m_wsEn).Text);
			Assert.IsNull(keyterm.Description.get_String(m_wsEn).Text);
			Assert.AreEqual("vulture", keyterm.SeeAlso.get_String(m_wsEn).Text);
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);

			// There should be 5 references for this key term
			Assert.AreEqual(5, keyterm.OccurrencesOS.Count);

			IChkRef reference = keyterm.OccurrencesOS[0];
			Assert.AreEqual(40024028, reference.Ref);
			Assert.AreEqual("\u1F00\u03B5\u03C4\u1F79\u03C2".Normalize(NormalizationForm.FormD), reference.KeyWord.Text);
			Assert.AreEqual(9, reference.Location);

			reference = keyterm.OccurrencesOS[1];
			Assert.AreEqual(42017037, reference.Ref);
			Assert.AreEqual("\u1F00\u03B5\u03C4\u1F79\u03C2".Normalize(NormalizationForm.FormD), reference.KeyWord.Text);
			Assert.AreEqual(17, reference.Location);

			reference = keyterm.OccurrencesOS[2];
			Assert.AreEqual(66004007, reference.Ref);
			Assert.AreEqual("\u1F00\u03B5\u03C4\u1F79\u03C2".Normalize(NormalizationForm.FormD), reference.KeyWord.Text);
			Assert.AreEqual(28, reference.Location);

			reference = keyterm.OccurrencesOS[3];
			Assert.AreEqual(66008013, reference.Ref);
			Assert.AreEqual("\u1F00\u03B5\u03C4\u1F79\u03C2".Normalize(NormalizationForm.FormD), reference.KeyWord.Text);
			Assert.AreEqual(6, reference.Location);

			reference = keyterm.OccurrencesOS[4];
			Assert.AreEqual(66012014, reference.Ref);
			Assert.AreEqual("\u1F00\u03B5\u03C4\u1F79\u03C2".Normalize(NormalizationForm.FormD), reference.KeyWord.Text);
			Assert.AreEqual(9, reference.Location);

			bool fFoundResource = false;
			foreach (ICmResource resource in m_lp.TranslatedScriptureOA.ResourcesOC)
			{
				if (resource.Name == "BiblicalTerms")
				{
					Assert.AreEqual(terms.Version, resource.Version);
					fFoundResource = true;
				}
			}
			Assert.IsTrue(fFoundResource);
		}
		public void UpgradeWhenExistingListHasRenderings_NewStyleList()
		{
			IWfiWordform abc = Cache.ServiceLocator.GetInstance<IWfiWordformFactory>().Create();
			abc.Form.SetVernacularDefaultWritingSystem("abc");
			IWfiWordform def = Cache.ServiceLocator.GetInstance<IWfiWordformFactory>().Create();
			def.Form.SetVernacularDefaultWritingSystem("def");
			IWfiWordform ghi = Cache.ServiceLocator.GetInstance<IWfiWordformFactory>().Create();
			ghi.Form.SetVernacularDefaultWritingSystem("ghi");

			// Create key terms under a key term possibility list (the new style of list).
			ICmPossibilityList oldKeyTermsList = Cache.LangProject.KeyTermsList;
			ICmPossibility keyTermPoss = Cache.ServiceLocator.GetInstance<ICmPossibilityFactory>().Create();
			oldKeyTermsList.PossibilitiesOS.Add(keyTermPoss);
			IChkTerm term = Cache.ServiceLocator.GetInstance<IChkTermFactory>().Create();
			keyTermPoss.SubPossibilitiesOS.Add(term);
			term.Name.set_String(m_wsEn, "Abba");
			term.Description.set_String(m_wsEn, "Daddy");
			AddOccurrenceToOldStyleSense(term, 41014036, abc, "abba", KeyTermRenderingStatus.Assigned);
			AddOccurrenceToOldStyleSense(term, 45008015, abc, "abba", KeyTermRenderingStatus.AutoAssigned);
			AddOccurrenceToOldStyleSense(term, 48004006, null, "abba"); // Not rendered
			AddOccurrenceToOldStyleSense(term, 48004007, abc, "abba"); // This one is not in new list

			term = Cache.ServiceLocator.GetInstance<IChkTermFactory>().Create();
			keyTermPoss.SubPossibilitiesOS.Add(term);
			term.Name.set_String(m_wsEn, "Angel");
			IChkTerm subsense = Cache.ServiceLocator.GetInstance<IChkTermFactory>().Create();
			term.SubPossibilitiesOS.Add(subsense);
			subsense.Name.set_String(m_wsEn, "Heavenly being");
			subsense.Description.set_String(m_wsEn, "Supernatural being sent as a messenger from God");
			AddOccurrenceToOldStyleSense(subsense, 040001020, def, "aggelos");
			AddOccurrenceToOldStyleSense(subsense, 040001024, ghi, "aggelos");
			AddOccurrenceToOldStyleSense(subsense, 040002013, null, "aggelos", KeyTermRenderingStatus.Ignored);

			subsense = Cache.ServiceLocator.GetInstance<IChkTermFactory>().Create();
			term.SubPossibilitiesOS.Add(subsense);
			subsense.Name.set_String(m_wsEn, "Demon");
			subsense.Description.set_String(m_wsEn, "A fallen angel");
			AddOccurrenceToOldStyleSense(subsense, 040007022, null, "daimonion");

			int iKeyTermPoss = Cache.LangProject.KeyTermsList.PossibilitiesOS.IndexOf(keyTermPoss);
			Assert.GreaterOrEqual(0, iKeyTermPoss, "We expect the key term list to be added as a node under the Biblical Terms list");
			Assert.AreEqual(2, Cache.LangProject.KeyTermsList.PossibilitiesOS[iKeyTermPoss].SubPossibilitiesOS.Count);

			BiblicalTermsList terms = new BiblicalTermsList();
			terms.Version = new Guid("00FEA689-3B63-4bd4-B640-7262A274D1A8");
			terms.KeyTerms = new List<Term>();
			terms.KeyTerms.Add(new Term(3, "KT", "\u03b1\u03b2\u03b2\u03b1", "Greek",
				"abba; father", null, null, 4101403603, 4500801516, 4800400618));
			terms.KeyTerms.Add(new Term(21, "KT", "\u1F04\u03B3\u03B3\u03B5\u03BB\u03BF\u03C2", "Greek",
				"angel", null, null, 04000102006, 04000102413, 04000201305));
			terms.KeyTerms.Add(new Term(363, "KT", "\u03B4\u03B1\u03B9\u03BC\u1F79\u03BD\u03B9\u03BF\u03BD-1",
				"Greek", "demon", "\u03B4\u03B1\u03B9\u03BC\u1F79\u03BD\u03B9\u03BF\u03BD",
				"\u03B4\u03B1\u03B9\u03BC\u03BF\u03BD\u1F77\u03B6\u03BF\u03BC\u03B1\u03B9, \u03B4\u03B1\u03B9\u03BC\u03BF\u03BD\u03B9\u1F7D\u03B4\u03B7\u03C2, \u03B4\u03B1\u1F77\u03BC\u03C9\u03BD",
				04000702219));

			List<BiblicalTermsLocalization> localizations = new List<BiblicalTermsLocalization>(1);
			BiblicalTermsLocalization loc = new BiblicalTermsLocalization(1);
			loc.WritingSystemHvo = m_wsEn;
			loc.Categories.Add(new CategoryLocalization("KT", "Key terms"));
			loc.Terms.Add(new TermLocalization(3, "abba; father", "title for God, literally dad"));
			localizations.Add(loc);

			// Load the terms
			var ktInitializer = new DummyTeKeyTermsInit(m_scr);
			ktInitializer.m_localizations = localizations;
			var mockProgressDlg = MockRepository.GenerateMock<IProgress>();
			ktInitializer.CallCreateKeyTerms(mockProgressDlg, terms);
			ICmPossibilityList newChkTermsList = Cache.LangProject.KeyTermsList;

			int wsGreek = m_wsf.GetWsFromStr("grc");

			// Make sure there is one category (possibility) in the new list
			ICmPossibility ktCategory = newChkTermsList.PossibilitiesOS[iKeyTermPoss];
			Assert.AreEqual("KT", ktCategory.Abbreviation.get_String(m_wsEn).Text);

			// Make sure there are three keyterms in that category
			Assert.AreEqual(3, ktCategory.SubPossibilitiesOS.Count);

			// Check the ChkTerm and ChkRefs for "abba"
			IChkTerm keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[0];
			Assert.AreEqual(3, keyterm.TermId);
			Assert.AreEqual("\u03b1\u03b2\u03b2\u03b1", keyterm.Name.get_String(wsGreek).Text);
			Assert.AreEqual("abba", keyterm.Name.get_String(m_wsEn).Text);
			Assert.AreEqual("title for God, literally dad",
				keyterm.Description.get_String(m_wsEn).Text);
			Assert.AreEqual("father", keyterm.SeeAlso.get_String(m_wsEn).Text);
			Assert.AreEqual(1, keyterm.RenderingsOC.Count);
			IChkRendering abbaRendering = keyterm.RenderingsOC.ToArray()[0];
			Assert.AreEqual(abc, abbaRendering.SurfaceFormRA);
			Assert.AreEqual(3, keyterm.OccurrencesOS.Count, "There should be 3 references for abba");
			Assert.AreEqual(KeyTermRenderingStatus.Assigned, keyterm.OccurrencesOS[0].Status);
			Assert.AreEqual(abc, keyterm.OccurrencesOS[0].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.AutoAssigned, keyterm.OccurrencesOS[1].Status);
			Assert.AreEqual(abc, keyterm.OccurrencesOS[1].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[2].Status);
			Assert.IsNull(keyterm.OccurrencesOS[2].RenderingRA);

			// Check the ChkRefs for "angel"
			keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[1];
			Assert.AreEqual(21, keyterm.TermId);
			Assert.AreEqual(2, keyterm.RenderingsOC.Count);
			bool fFoundDEF = false;
			bool fFoundGHI = false;
			foreach (IChkRendering rendering in keyterm.RenderingsOC)
			{
				fFoundDEF |= (rendering.SurfaceFormRA == def);
				fFoundGHI |= (rendering.SurfaceFormRA == ghi);
			}
			Assert.IsTrue(fFoundDEF);
			Assert.IsTrue(fFoundGHI);
			Assert.AreEqual(3, keyterm.OccurrencesOS.Count);
			Assert.AreEqual(KeyTermRenderingStatus.Assigned, keyterm.OccurrencesOS[0].Status);
			Assert.AreEqual(def, keyterm.OccurrencesOS[0].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Assigned, keyterm.OccurrencesOS[1].Status);
			Assert.AreEqual(ghi, keyterm.OccurrencesOS[1].RenderingRA);
			Assert.AreEqual(KeyTermRenderingStatus.Ignored, keyterm.OccurrencesOS[2].Status);
			Assert.IsNull(keyterm.OccurrencesOS[2].RenderingRA);

			// Check the ChkRefs for "demon"
			keyterm = (IChkTerm)ktCategory.SubPossibilitiesOS[2];
			Assert.AreEqual(363, keyterm.TermId);
			Assert.AreEqual(0, keyterm.RenderingsOC.Count);
			Assert.AreEqual(1, keyterm.OccurrencesOS.Count);
			Assert.AreEqual(KeyTermRenderingStatus.Unassigned, keyterm.OccurrencesOS[0].Status);
			Assert.IsNull(keyterm.OccurrencesOS[0].RenderingRA);
		}