public void SetAndAccessMultiStrings() { ITsStrFactory tsf = TsStrFactoryClass.Create(); int kflid = XMLViewsDataCache.ktagEditColumnBase; int hvoRoot = 10578; int wsEng = Cache.WritingSystemFactory.GetWsFromStr("en"); XMLViewsDataCache xmlCache = new XMLViewsDataCache(Cache.MainCacheAccessor as ISilDataAccessManaged, true, new Dictionary <int, int>()); Notifiee recorder = new Notifiee(); xmlCache.AddNotification(recorder); Assert.AreEqual(0, xmlCache.get_MultiStringAlt(hvoRoot, kflid, wsEng).Length); Assert.AreEqual(0, recorder.Changes.Count); ITsString test1 = tsf.MakeString("test1", wsEng); xmlCache.CacheMultiString(hvoRoot, kflid, wsEng, test1); Assert.AreEqual(0, recorder.Changes.Count); Assert.AreEqual(test1, xmlCache.get_MultiStringAlt(hvoRoot, kflid, wsEng)); ITsString test2 = tsf.MakeString("blah", wsEng); xmlCache.SetMultiStringAlt(hvoRoot, kflid, wsEng, test2); Assert.AreEqual(test2, xmlCache.get_MultiStringAlt(hvoRoot, kflid, wsEng)); recorder.CheckChanges(new ChangeInformationTest[] { new ChangeInformationTest(hvoRoot, kflid, wsEng, 0, 0) }, "expected PropChanged from setting string"); xmlCache.RemoveNotification(recorder); // Enhance JohnT: a better test would verify that it doesn't intefere with other multistrings, // and that it can store stuff independently for different HVOs, tags, and WSs. }
public void SetAndAccessDummyList() { ILexDb lexDb = Cache.LangProject.LexDbOA; ILexEntry entry1 = null; ICmResource res1 = null; NonUndoableUnitOfWorkHelper.Do(m_actionHandler, () => { var leFactory = Cache.ServiceLocator.GetInstance <ILexEntryFactory>(); entry1 = leFactory.Create(); ILexEntry entry2 = leFactory.Create(); res1 = Cache.ServiceLocator.GetInstance <ICmResourceFactory>().Create(); lexDb.ResourcesOC.Add(res1); }); int hvoRoot = 10578; ObjectListPublisher publisher = new ObjectListPublisher(Cache.MainCacheAccessor as ISilDataAccessManaged, ObjectListFlid); var values = new int[] { 23, 56, 2048 }; Notifiee recorder = new Notifiee(); publisher.AddNotification(recorder); publisher.CacheVecProp(hvoRoot, values); Assert.AreEqual(values.Length, publisher.get_VecSize(hvoRoot, ObjectListFlid), "override of vec size"); //Assert.AreEqual(Cache.LangProject.Texts.Count, publisher.get_VecSize(Cache.LangProject.Hvo, LangProjectTags.kflidTexts), "base vec size"); Assert.AreEqual(23, publisher.get_VecItem(hvoRoot, ObjectListFlid, 0), "override of vec item"); Assert.AreEqual(res1.Hvo, publisher.get_VecItem(lexDb.Hvo, LexDbTags.kflidResources, 0), "base vec item"); Assert.AreEqual(56, publisher.get_VecItem(hvoRoot, ObjectListFlid, 1), "override of vec item, non-zero index"); VerifyCurrentValue(hvoRoot, publisher, values, "original value"); Assert.AreEqual(lexDb.ResourcesOC.Count(), publisher.VecProp(lexDb.Hvo, LexDbTags.kflidResources).Length, "base VecProp"); recorder.CheckChanges(new ChangeInformationTest[] { new ChangeInformationTest(hvoRoot, ObjectListFlid, 0, values.Length, 0) }, "expected PropChanged from caching HVOs"); publisher.RemoveNotification(recorder); recorder = new Notifiee(); publisher.AddNotification(recorder); publisher.Replace(hvoRoot, 1, new int[] { 97, 98 }, 0); VerifyCurrentValue(hvoRoot, publisher, new int[] { 23, 97, 98, 56, 2048 }, "after inserting 97, 98"); recorder.CheckChanges(new ChangeInformationTest[] { new ChangeInformationTest(hvoRoot, ObjectListFlid, 1, 2, 0) }, "expected PropChanged from caching HVOs"); publisher.RemoveNotification(recorder); recorder = new Notifiee(); publisher.AddNotification(recorder); publisher.Replace(hvoRoot, 1, new int[0], 2); VerifyCurrentValue(hvoRoot, publisher, new int[] { 23, 56, 2048 }, "after deleting 97, 98"); recorder.CheckChanges(new ChangeInformationTest[] { new ChangeInformationTest(hvoRoot, ObjectListFlid, 1, 0, 2) }, "expected PropChanged from caching HVOs"); publisher.RemoveNotification(recorder); }