public void MergeReferenceAtomic() { CheckDisposed(); // 24 LexSense.MorphoSyntaxAnalysis (refers to MSA) ILexEntry lme = m_entriesCol.Add(new LexEntry()); ILexSense lsKeeper = lme.SensesOS.Append(new LexSense()); ILexSense lsSrc = lme.SensesOS.Append(new LexSense()); IMoStemMsa msa1 = (IMoStemMsa)lme.MorphoSyntaxAnalysesOC.Add(new MoStemMsa()); IMoStemMsa msa2 = (IMoStemMsa)lme.MorphoSyntaxAnalysesOC.Add(new MoStemMsa()); // Merge content into null. lsSrc.MorphoSyntaxAnalysisRAHvo = msa1.Hvo; lsKeeper.MergeObject(lsSrc); Assert.AreEqual(msa1.Hvo, lsKeeper.MorphoSyntaxAnalysisRAHvo); // Merge content into content. lsKeeper.MorphoSyntaxAnalysisRAHvo = msa1.Hvo; lsSrc = lme.SensesOS.Append(new LexSense()); lsSrc.MorphoSyntaxAnalysisRAHvo = msa2.Hvo; lsKeeper.MergeObject(lsSrc); Assert.AreEqual(msa1.Hvo, lsKeeper.MorphoSyntaxAnalysisRAHvo); // Merge null into content. lsKeeper.MorphoSyntaxAnalysisRAHvo = msa1.Hvo; lsSrc = lme.SensesOS.Append(new LexSense()); lsSrc.MorphoSyntaxAnalysisRA = null; lsKeeper.MergeObject(lsSrc); Assert.AreEqual(msa1.Hvo, lsKeeper.MorphoSyntaxAnalysisRAHvo); }
public void MergeReferenceCollection() { CheckDisposed(); // 26 LexSense.UsageTypes(refers to CmPossibility) ILexEntry lme = m_entriesCol.Add(new LexEntry()); ILexSense lsKeeper = lme.SensesOS.Append(new LexSense()); ILexSense lsSrc = lme.SensesOS.Append(new LexSense()); FdoOwningSequence<ICmPossibility> usageSeq = m_ldb.UsageTypesOA.PossibilitiesOS; usageSeq.Append(new CmPossibility()); usageSeq.Append(new CmPossibility()); usageSeq.Append(new CmPossibility()); int[] srcTypes = new int[2]; // Merge content into null. srcTypes[0] = usageSeq[0].Hvo; srcTypes[1] = usageSeq[1].Hvo; lsSrc.UsageTypesRC.Add(srcTypes); lsKeeper.MergeObject(lsSrc); Assert.AreEqual(2, lsKeeper.UsageTypesRC.Count); // Merge content into content. lsSrc = lme.SensesOS.Append(new LexSense()); lsSrc.UsageTypesRC.Add(usageSeq[2].Hvo); lsKeeper.MergeObject(lsSrc); Assert.AreEqual(3, lsKeeper.UsageTypesRC.Count); // Merge duplicate content into content. lsSrc = lme.SensesOS.Append(new LexSense()); lsSrc.UsageTypesRC.Add(usageSeq[2].Hvo); Assert.AreEqual(1, lsSrc.UsageTypesRC.Count); lsKeeper.MergeObject(lsSrc); Assert.AreEqual(3, lsKeeper.UsageTypesRC.Count); // Merge null into content. lsSrc = lme.SensesOS.Append(new LexSense()); Assert.AreEqual(0, lsSrc.UsageTypesRC.Count); lsKeeper.MergeObject(lsSrc); Assert.AreEqual(3, lsKeeper.UsageTypesRC.Count); }
public void MergeSenses() { CheckDisposed(); ILexEntry lmeKeeper = m_entriesCol.Add(new LexEntry()); ILexSense lsKeeper = lmeKeeper.SensesOS.Append(new LexSense()); ILexEntry lmeSrc = m_entriesCol.Add(new LexEntry()); ILexSense lsSrc = lmeSrc.SensesOS.Append(new LexSense()); lsKeeper.Definition.SetAnalysisDefaultWritingSystem("English defn keep"); lsKeeper.Gloss.AnalysisDefaultWritingSystem = "English gloss keep"; lsSrc.Definition.SetAnalysisDefaultWritingSystem("English defn src"); lsSrc.Gloss.AnalysisDefaultWritingSystem = "English gloss src"; lsKeeper.MergeObject(lsSrc, true); Assert.AreEqual("English defn keep; English defn src", lsKeeper.Definition.AnalysisDefaultWritingSystem.Text); Assert.AreEqual("English gloss keep; English gloss src", lsKeeper.Gloss.AnalysisDefaultWritingSystem); }
public void MergeStrings() { CheckDisposed(); int engWs = Cache.LanguageEncodings.GetWsFromIcuLocale("en"); string virginiaCreeper = "Vitaceae Parthenocissus quinquefolia"; string whiteOak = "Quercus alba"; ILexEntry lmeKeeper = m_entriesCol.Add(new LexEntry()); ILexSense lsKeeper = lmeKeeper.SensesOS.Append(new LexSense()); ILexEntry lmeSrc = m_entriesCol.Add(new LexEntry()); ILexSense lsSrc = lmeSrc.SensesOS.Append(new LexSense()); ITsPropsBldr propsBldr = TsPropsBldrClass.Create(); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, engWs); ITsTextProps ttpEng = propsBldr.GetTextProps(); ITsStrBldr tsb = TsStrBldrClass.Create(); ITsString tssEmpty = tsb.GetString(); tsb.Replace(0, 0, virginiaCreeper, ttpEng); tsb.SetIntPropValues(10, 20, (int) FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault, 50); ITsString tssVirginiaCreeper = tsb.GetString(); ITsStrBldr tsb2 = TsStrBldrClass.Create(); tsb2.Replace(0, 0, whiteOak, ttpEng); tsb2.SetIntPropValues(5, 10, (int) FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault, 500); ITsString tssWhiteOak = tsb2.GetString(); tsb2.Replace(tsb2.Length, tsb2.Length, " ", null); tsb2.ReplaceTsString(tsb2.Length, tsb2.Length, tssVirginiaCreeper); ITsString tssConcat = tsb2.GetString(); lsSrc.ScientificName.UnderlyingTsString = tssVirginiaCreeper; lsKeeper.MergeObject(lsSrc); AssertEqualTss(lsKeeper.ScientificName.UnderlyingTsString, tssVirginiaCreeper); lsKeeper.ScientificName.UnderlyingTsString = tssWhiteOak; lsSrc = lmeSrc.SensesOS.Append(new LexSense()); lsSrc.ScientificName.UnderlyingTsString = tssVirginiaCreeper; lsKeeper.MergeObject(lsSrc); Assert.AreEqual(lsKeeper.ScientificName.UnderlyingTsString, tssWhiteOak); lsKeeper.ScientificName.UnderlyingTsString = tssWhiteOak; lsSrc = lmeSrc.SensesOS.Append(new LexSense()); lsSrc.ScientificName.UnderlyingTsString = tssEmpty; lsKeeper.MergeObject(lsSrc); Assert.AreEqual(lsKeeper.ScientificName.UnderlyingTsString, tssWhiteOak); lsKeeper.ScientificName.UnderlyingTsString = tssEmpty; lsSrc = lmeSrc.SensesOS.Append(new LexSense()); lsSrc.ScientificName.UnderlyingTsString = tssVirginiaCreeper; lsKeeper.MergeObject(lsSrc); Assert.AreEqual(lsKeeper.ScientificName.UnderlyingTsString, tssVirginiaCreeper); lsKeeper.ScientificName.UnderlyingTsString = tssVirginiaCreeper; lsSrc = lmeSrc.SensesOS.Append(new LexSense()); lsSrc.ScientificName.UnderlyingTsString = tssEmpty; lsKeeper.MergeObject(lsSrc); Assert.AreEqual(lsKeeper.ScientificName.UnderlyingTsString, tssVirginiaCreeper); // Now test the append case. lsKeeper.ScientificName.UnderlyingTsString = tssWhiteOak; lsSrc = lmeSrc.SensesOS.Append(new LexSense()); lsSrc.ScientificName.UnderlyingTsString = tssVirginiaCreeper; lsKeeper.MergeObject(lsSrc, true); AssertEqualTss(lsKeeper.ScientificName.UnderlyingTsString, tssConcat); // But don't append if equal lsKeeper.ScientificName.UnderlyingTsString = tssWhiteOak; lsSrc = lmeSrc.SensesOS.Append(new LexSense()); lsSrc.ScientificName.UnderlyingTsString = tssWhiteOak; lsKeeper.MergeObject(lsSrc, true); Assert.AreEqual(lsKeeper.ScientificName.UnderlyingTsString, tssWhiteOak); }