public void FdoReferenceCollection() { CheckDisposed(); ILexDb ldb = Cache.LangProject.LexDbOA; ldb.EntriesOC.Add(new LexEntry()); ldb.EntriesOC.Add(new LexEntry()); // Gather up all entries in the DB. int iLESize = Cache.GetVectorSize(ldb.Hvo, (int)LexDb.LexDbTags.kflidEntries); FdoOwningCollection <ILexEntry> ocvLexEntriesOC = ldb.EntriesOC; int[] ahvoLexEntriesOC = ocvLexEntriesOC.HvoArray; // Check sizes. They should be the same. Assert.AreEqual(iLESize, ahvoLexEntriesOC.Length, "Mis-matched number of entries."); FdoReferenceCollection <ILexEntry> rcLexEntriesRCBefore = ldb.LexicalFormIndexRC; int[] ahvoLexEntriesRCBefore = rcLexEntriesRCBefore.HvoArray; int iOldRCSize = ahvoLexEntriesRCBefore.Length; // Add all entries to reference collection. rcLexEntriesRCBefore.Add(ahvoLexEntriesOC); // Make sure they are there now. FdoReferenceCollection <ILexEntry> rcLexEntriesRCAfter = ldb.LexicalFormIndexRC; int[] ahvoLexEntriesRCAfter = rcLexEntriesRCAfter.HvoArray; Assert.AreEqual((ahvoLexEntriesOC.Length + iOldRCSize), ahvoLexEntriesRCAfter.Length, "Mis-matched number of entries in reference collection."); // Size of ahvoLexEntriesRCAfter is right, so quit. // Note: One could check the IDs, but it probably isn't needed, // as long as nobody else was messing with database at the same time. // Try adding a duplicate item to reference collection. // The size should be the same before as after. rcLexEntriesRCAfter.Add(ahvoLexEntriesOC[0]); Assert.AreEqual(ahvoLexEntriesRCAfter.Length, rcLexEntriesRCAfter.HvoArray.Length, "Mis-matched number of entries in reference collection."); }
public override void AddItem(int hvoNew) { CheckDisposed(); ILexSense selectedSense = LexSense.CreateFromDBObject(m_cache, hvoNew); FdoReferenceCollection <IReversalIndexEntry> col = selectedSense.ReversalEntriesRC; int hvoCurrentObj = m_obj.Hvo; int h1 = m_vectorRefView.RootBox.Height; if (!col.Contains(hvoCurrentObj)) { int oldCount = col.Count; m_cache.BeginUndoTask(LexEdStrings.ksUndoAddRevToSense, LexEdStrings.ksRedoAddRevToSense); // Does a PropChanged on the sense's ReversalEntries property. col.Add(hvoCurrentObj); // Update the ReferringSenses property, and do PropChanged on it. ReversalIndexEntry.ResetReferringSenses(m_cache, m_obj.Hvo); m_cache.EndUndoTask(); int h2 = m_vectorRefView.RootBox.Height; CheckViewSizeChanged(h1, h2); } }