private static IResourceList ConvertResultList(Entry[] entries, bool isSingleTerm, int[] inDocIDs, out SimplePropertyProvider provider) { List <int> IDs = new List <int>(); provider = new SimplePropertyProvider(); if (entries != null) { for (int i = 0; i < entries.Length; i++) { if ((inDocIDs == null) || (Array.IndexOf(inDocIDs, entries[i].DocIndex) != -1)) { IDs.Add(entries[i].DocIndex); provider.SetProp(entries[i].DocIndex, FullTextIndexer.SearchRankPropId, entries[i].TfIdf); if (!isSingleTerm) { provider.SetProp(entries[i].DocIndex, FullTextIndexer.ProximityPropId, entries[i].Proximity); } } } } IResourceList result = Core.ResourceStore.ListFromIds(IDs, true); result.AttachPropertyProvider(provider); return(result); }
[Test] public void ResourceDeletedTest() { IResource email = _storage.NewResource("Email"); int emailID = email.Id; IResourceList allEmails = _storage.GetAllResourcesLive("Email"); allEmails.AttachPropertyProvider(_provider); email.Delete(); _provider.SetProp(emailID, _propSize, 100); }
[Test] public void TestChangeNotification() { IResource email = _storage.NewResource("Email"); IResourceList allEmails = _storage.GetAllResourcesLive("Email"); allEmails.AttachPropertyProvider(_provider); allEmails.ResourceChanged += new ResourcePropIndexEventHandler(OnResourceChanged); _provider.SetProp(email.Id, _propSize, 100); Assert.IsTrue(_lastChangeArgs != null, "ResourceChanged event must have been fired"); Assert.AreEqual(_lastChangeArgs.Resource, email); Assert.IsTrue(_lastChangeArgs.ChangeSet.IsPropertyChanged(_propSize)); }
[Test] public void SimpleTest() { IResource email = _storage.NewResource("Email"); _provider.SetProp(email.Id, _propSize, 100); IResourceList allEmails = _storage.GetAllResourcesLive("Email"); allEmails.AttachPropertyProvider(_provider); Assert.IsTrue(allEmails.HasProp(_propSize)); Assert.IsTrue(!allEmails.HasProp(_propSubject)); Assert.AreEqual("100", allEmails.GetPropText(0, _propSize)); }
[Test] public void UnionTest() { IResource email = _storage.NewResource("Email"); _provider.SetProp(email.Id, _propSize, 100); IResourceList allEmails = _storage.GetAllResourcesLive("Email"); allEmails.AttachPropertyProvider(_provider); IResourceList allPersons = _storage.GetAllResourcesLive("Person"); IResourceList unionList = allPersons.Union(allEmails); Assert.IsTrue(unionList.HasProp(_propSize)); Assert.AreEqual("100", unionList.GetPropText(0, _propSize)); }