public override void TestTearDown() { base.TestTearDown(); m_reversalSlice.DummyControl.Dispose(); m_reversalSlice.Dispose(); m_reversalSlice = null; NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor, () => m_lexEntry?.Delete()); m_lexEntry = null; }
public void DummyReversalCreatedOnFocusLost() { NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor, () => { m_lexEntry = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create(); ILexSense sense = Cache.ServiceLocator.GetInstance <ILexSenseFactory>().Create(); m_lexEntry.SensesOS.Add(sense); }); int engWsId = Cache.DefaultAnalWs; m_reversalSlice = new DummyReversalIndexEntrySlice(m_lexEntry.SensesOS[0]); m_reversalSlice.Cache = Cache; // Creating the reversal index before the slice is fully initialized ensures the reversal index gets loaded into the dummy cache IReversalIndex ri = m_revIndexRepo.FindOrCreateIndexForWs(engWsId); m_reversalSlice.FinishInit(); DummyReversalIndexEntrySliceView reversalView = m_reversalSlice.DummyControl; int indexFirstEntry = 0; reversalView.CacheNewDummyEntry(ri.Hvo, engWsId); // Create an additional dummy reversal entry before we edit one reversalView.EditRevIndexEntryInCache(ri.Hvo, indexFirstEntry, engWsId, TsStringUtils.MakeString("first", engWsId)); // The dummy cache will have two dummy reversal index entries, but non exists in the real data yet. // The reversal index entry control must maintain a dummy entry at the end to allow a place to click to add new entries. Assert.AreEqual(0, m_revIndexEntryRepo.Count); Assert.AreEqual(2, reversalView.GetIndexSize(ri.Hvo)); // The second dummy entry will remain a dummy reversalView.KillFocus(new Control()); Assert.AreEqual(1, m_revIndexEntryRepo.Count); Assert.AreEqual(2, reversalView.GetIndexSize(ri.Hvo)); IReversalIndexEntry rie = m_revIndexEntryRepo.AllInstances().First(); Assert.AreEqual("first", rie.ShortName); Assert.AreEqual(1, m_lexEntry.SensesOS[0].ReferringReversalIndexEntries.Count()); Assert.True(m_lexEntry.SensesOS[0].ReferringReversalIndexEntries.Contains(rie)); }