Exemplo n.º 1
0
        public static bool TrySelectCase(string text, out List <int> result)
        {
            var success = false;

            result = new List <int>();

            List <int> casesId;

            if (FactoryIndexer <CasesWrapper> .TrySelectIds(s => s.MatchAll(text), out casesId))
            {
                result.AddRange(casesId);
                success = true;
            }

            IReadOnlyCollection <FieldsWrapper> casesCustom;

            if (FactoryIndexer <FieldsWrapper> .TrySelect(s => s.MatchAll(text).Where(r => r.EntityType, 7), out casesCustom))
            {
                result.AddRange(casesCustom.Select(r => r.EntityId).ToList());
                success = true;
            }

            IReadOnlyCollection <EventsWrapper> events;

            if (!FactoryIndexer <EventsWrapper> .TrySelect(s => s.MatchAll(text).Where(r => r.EntityType, 7).Gt(r => r.EntityId, 0), out events))
            {
                result.AddRange(events.Select(r => r.EntityId).ToList());
                success = true;
            }

            return(success);
        }
Exemplo n.º 2
0
        private static Exp GetWhere(string s, FeedType feedType, Guid userId)
        {
            var where = Exp.Empty;

            if (!string.IsNullOrEmpty(s))
            {
                List <int> news;
                if (FactoryIndexer <NewsWrapper> .TrySelectIds(r => r.MatchAll(s), out news))
                {
                    where = where & Exp.In("Id", news);
                }
                else
                {
                    where = where & (Exp.Like("lower(Caption)", s.ToLower()) | Exp.Like("lower(Text)", s.ToLower()));
                }
            }
            if (feedType == FeedType.AllNews)
            {
                where = where & !Exp.Eq("FeedType", FeedType.Poll);
            }
            else if (feedType != FeedType.All)
            {
                where = where & Exp.Eq("FeedType", feedType);
            }
            if (userId != Guid.Empty)
            {
                where = where & Exp.Eq("Creator", userId.ToString());
            }
            return(where);
        }
Exemplo n.º 3
0
        public void ProjectUpdateByQuery()
        {
            var searchText = "ABCDEF";
            var proj1      = CreateProject(searchText, "Description");
            var proj2      = CreateProject(searchText, "Description");
            var proj3      = CreateProject(searchText, "Description");

            List <int> result;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText), out result);

            Assert.AreEqual(result.Count, 3);

            var newTitle = "QWERTY";

            FactoryIndexer <ProjectsWrapper> .Update(new ProjectsWrapper { Title = "QWERTY" }, r => r.In(t => t.Id, new[] { proj1.ID, proj2.ID }), true, r => r.Title);

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(newTitle), out result);

            Assert.AreEqual(result.Count, 2);

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText), out result);

            Assert.AreEqual(result[0], proj3.ID);

            DeleteProject(proj1);
            DeleteProject(proj2);
            DeleteProject(proj3);
        }
Exemplo n.º 4
0
        public void ProjectUpdate()
        {
            var searchText = "ABCDEF";
            var proj       = CreateProject(searchText, "Description");

            List <int> result;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText), out result);

            Assert.AreEqual(result[0], proj.ID);

            FactoryIndexer <ProjectsWrapper> .Update(new ProjectsWrapper { Id = proj.ID, Title = "QWERTY" }, true, r => r.Title);

            FactoryIndexer <ProjectsWrapper> .Update(new ProjectsWrapper { Id = proj.ID, LastModifiedOn = DateTime.UtcNow }, true, r => r.LastModifiedOn);

            FactoryIndexer <ProjectsWrapper> .Update(new ProjectsWrapper { Id = proj.ID, TenantId = 10 }, true, r => r.TenantId);

            FactoryIndexer <ProjectsWrapper> .Update(new ProjectsWrapper { Id = proj.ID, TenantId = 5, Title = "Tenant" }, true, r => r.TenantId, r => r.Title);

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText), out result);

            CollectionAssert.IsEmpty(result);

            DeleteProject(proj);
        }
Exemplo n.º 5
0
        public List <File> GetFilesFiltered(IEnumerable <object> fileIds, FilterType filterType, bool subjectGroup, Guid subjectID, string searchText, bool searchInContent)
        {
            if (fileIds == null || !fileIds.Any() || filterType == FilterType.FoldersOnly)
            {
                return(new List <File>());
            }

            var q = GetFileQuery(Exp.In("id", fileIds) & Exp.Eq("current_version", true), false);

            if (!string.IsNullOrEmpty(searchText))
            {
                List <int> searchIds;
                var        func = GetFuncForSearch(null, null, filterType, subjectGroup, subjectID, searchText, searchInContent, false);

                if (FactoryIndexer <FilesWrapper> .TrySelectIds(s => func(s).In(r => r.Id, fileIds.ToArray()), out searchIds))
                {
                    q.Where(Exp.In("id", searchIds));
                }
                else
                {
                    q.Where(BuildSearch("title", searchText));
                }
            }

            if (subjectID != Guid.Empty)
            {
                if (subjectGroup)
                {
                    var users = CoreContext.UserManager.GetUsersByGroup(subjectID).Select(u => u.ID.ToString()).ToArray();
                    q.Where(Exp.In("create_by", users));
                }
                else
                {
                    q.Where("create_by", subjectID.ToString());
                }
            }

            switch (filterType)
            {
            case FilterType.DocumentsOnly:
            case FilterType.ImagesOnly:
            case FilterType.PresentationsOnly:
            case FilterType.SpreadsheetsOnly:
            case FilterType.ArchiveOnly:
            case FilterType.MediaOnly:
                q.Where("category", (int)filterType);
                break;

            case FilterType.ByExtension:
                if (!string.IsNullOrEmpty(searchText))
                {
                    q.Where(BuildSearch("title", searchText, SqlLike.EndWith));
                }
                break;
            }

            return(dbManager
                   .ExecuteList(q)
                   .ConvertAll(ToFile));
        }
Exemplo n.º 6
0
        public IEnumerable <File> Search(String searchText, bool bunch)
        {
            List <int> ids;

            if (FactoryIndexer <FilesWrapper> .TrySelectIds(s => s.MatchAll(searchText), out ids))
            {
                return(dbManager
                       .ExecuteList(GetFileQuery(Exp.In("id", ids) & Exp.Eq("current_version", true)))
                       .ConvertAll(ToFile)
                       .Where(
                           f =>
                           bunch
                            ? f.RootFolderType == FolderType.BUNCH
                            : f.RootFolderType == FolderType.USER || f.RootFolderType == FolderType.COMMON)
                       .ToList());
            }
            else
            {
                var q = GetFileQuery(Exp.Eq("current_version", true) & BuildSearch("title", searchText));
                return(dbManager
                       .ExecuteList(q)
                       .ConvertAll(ToFile)
                       .Where(f =>
                              bunch
                                ? f.RootFolderType == FolderType.BUNCH
                                : f.RootFolderType == FolderType.USER || f.RootFolderType == FolderType.COMMON)
                       .ToList());
            }
        }
Exemplo n.º 7
0
        public Message[] GetMessages(Jid from, Jid to, DateTime start, DateTime end, string text, int count, int startindex = 0)
        {
            if (from == null)
            {
                throw new ArgumentNullException("from");
            }
            if (to == null)
            {
                throw new ArgumentNullException("to");
            }

            var q = new SqlQuery("jabber_archive")
                    .Select("message")
                    .Where("jid", GetKey(from, to))
                    .OrderBy("id", false);

            if (start != DateTime.MinValue)
            {
                q.Where(Exp.Ge("stamp", start));
            }
            if (end != DateTime.MaxValue)
            {
                q.Where(Exp.Le("stamp", end));
            }
            if (startindex < int.MaxValue)
            {
                q.SetFirstResult(startindex);
            }
            if (0 < count && count < int.MaxValue)
            {
                q.SetMaxResults(count);
            }

            if (!string.IsNullOrEmpty(text))
            {
                try
                {
                    List <int> ids;
                    CallContext.SetData(TenantManager.CURRENT_TENANT, CoreContext.TenantManager.GetTenant(from.Server));
                    if (FactoryIndexer <Web.Talk.JabberWrapper> .TrySelectIds(r => r.MatchAll(HttpUtility.HtmlDecode(text)), out ids))
                    {
                        q.Where(Exp.In("id", ids));
                    }
                }
                finally
                {
                    CallContext.SetData(TenantManager.CURRENT_TENANT, null);
                }
            }

            var messages = ExecuteList(q).ConvertAll(r => ElementSerializer.DeSerializeElement <Message>((string)r[0]));

            messages.Reverse();
            return(messages.ToArray());
        }
Exemplo n.º 8
0
        public void ProjectMulti(string searchText)
        {
            List <int> result;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.Match(r => new object[] { r.Title, r.Description }, searchText), out result);

            foreach (var prj in Projects)
            {
                CollectionAssert.Contains(result, prj.ID);
            }
        }
Exemplo n.º 9
0
        public void ProjectOr(string searchText)
        {
            List <int> result;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.Or(r => r.Match(k => k.Title, searchText), r => r.Match(k => k.Description, searchText)), out result);

            foreach (var prj in Projects)
            {
                CollectionAssert.Contains(result, prj.ID);
            }
        }
Exemplo n.º 10
0
        public void ProjectAll(string searchText)
        {
            List <int> result;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText), out result);

            foreach (var prj in Projects)
            {
                CollectionAssert.Contains(result, prj.ID);
            }
        }
Exemplo n.º 11
0
        public void ProjectMultiProps()
        {
            List <int> result;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.Match(r => r.Title, "Project").Match(r => r.Description, "Description"), out result);

            foreach (var prj in Projects)
            {
                CollectionAssert.Contains(result, prj.ID);
            }
        }
Exemplo n.º 12
0
        public void ProjectSort(string searchText)
        {
            List <int> result;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText).Sort(a => a.Id, false), out result);

            Assert.Greater(result[0], result[1]);

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText).Sort(a => a.LastModifiedOn, true), out result);

            Assert.Greater(result[1], result[0]);
        }
Exemplo n.º 13
0
        public List <Folder> GetFolders(IEnumerable <object> folderIds, FilterType filterType = FilterType.None, bool subjectGroup = false, Guid?subjectID = null, string searchText = "", bool searchSubfolders = false, bool checkShare = true)
        {
            if (filterType == FilterType.FilesOnly || filterType == FilterType.ByExtension ||
                filterType == FilterType.DocumentsOnly || filterType == FilterType.ImagesOnly ||
                filterType == FilterType.PresentationsOnly || filterType == FilterType.SpreadsheetsOnly ||
                filterType == FilterType.ArchiveOnly || filterType == FilterType.MediaOnly)
            {
                return(new List <Folder>());
            }

            var q = GetFolderQuery(Exp.In("id", folderIds), checkShare);

            if (searchSubfolders)
            {
                q = GetFolderQuery(Exp.In("fft.parent_id", folderIds))
                    .InnerJoin("files_folder_tree fft", Exp.EqColumns("fft.folder_id", "f.id"));
            }

            if (!string.IsNullOrEmpty(searchText))
            {
                List <int> searchIds;
                if (FactoryIndexer <FoldersWrapper> .TrySelectIds(s =>
                                                                  searchSubfolders
                                                                    ? s.MatchAll(searchText)
                                                                    : s.MatchAll(searchText).In(r => r.Id, folderIds.ToArray()),
                                                                  out searchIds))
                {
                    q.Where(Exp.In("id", searchIds));
                }
                else
                {
                    q.Where(BuildSearch("title", searchText));
                }
            }

            if (subjectID.HasValue && subjectID != Guid.Empty)
            {
                if (subjectGroup)
                {
                    var users = CoreContext.UserManager.GetUsersByGroup(subjectID.Value).Select(u => u.ID.ToString()).ToArray();
                    q.Where(Exp.In("f.create_by", users));
                }
                else
                {
                    q.Where(Exp.Eq("f.create_by", subjectID.ToString()));
                }
            }

            return(dbManager
                   .ExecuteList(q)
                   .ConvertAll(ToFolder));
        }
Exemplo n.º 14
0
        public void ProjectSpec(string spec)
        {
            var searchText = "ABC" + spec + "BCD";
            var proj       = CreateProject(searchText, "Description");

            List <int> result;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText), out result);

            CollectionAssert.IsNotEmpty(result);
            Assert.AreEqual(proj.ID, result[0]);

            DeleteProject(proj);
        }
Exemplo n.º 15
0
        private List <Task> GetCrudeTasks(
            String searchText,
            Guid responsibleID,
            int categoryID,
            bool?isClosed,
            DateTime fromDate,
            DateTime toDate,
            EntityType entityType,
            int entityID,
            int from,
            int count,
            OrderBy orderBy)
        {
            var taskTableAlias = "t";
            var sqlQuery       = WhereConditional(GetTaskQuery(null, taskTableAlias), taskTableAlias, responsibleID,
                                                  categoryID, isClosed, fromDate, toDate, entityType, entityID, from, count,
                                                  orderBy);

            if (!String.IsNullOrEmpty(searchText))
            {
                searchText = searchText.Trim();


                var keywords = searchText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                               .ToArray();

                if (keywords.Length > 0)
                {
                    List <int> tasksIds;
                    if (!FactoryIndexer <TasksWrapper> .TrySelectIds(s => s.MatchAll(searchText), out tasksIds))
                    {
                        sqlQuery.Where(BuildLike(new[] { taskTableAlias + ".title", taskTableAlias + ".description" }, keywords));
                    }
                    else
                    {
                        if (tasksIds.Any())
                        {
                            sqlQuery.Where(Exp.In(taskTableAlias + ".id", tasksIds));
                        }
                        else
                        {
                            return(new List <Task>());
                        }
                    }
                }
            }

            return(Db.ExecuteList(sqlQuery)
                   .ConvertAll(row => ToTask(row)));
        }
Exemplo n.º 16
0
        public void ProjectAllIn(string searchText)
        {
            List <int> result;
            var        prj = Projects[0].ID;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText).In(r => r.Id, new[] { prj }), out result);

            Assert.AreEqual(result[0], prj);

            var prj2 = Projects[1].ID;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText).In(r => r.Id, new[] { prj, prj2 }), out result);

            Assert.AreEqual(result.Count, 2);
        }
Exemplo n.º 17
0
        public void ProjectDelete()
        {
            var searchText = "WERTYU";
            var proj       = CreateProject(searchText, "Description");

            List <int> result;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText), out result);

            CollectionAssert.IsNotEmpty(result);

            DeleteProject(proj);

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText), out result);

            CollectionAssert.IsEmpty(result);
        }
        private IEnumerable <DomainObject <int> > GetMilestones(String text, int projectId)
        {
            Exp mileWhere;

            List <int> mileIds;

            if (FactoryIndexer <MilestonesWrapper> .TrySelectIds(s => s.MatchAll(text), out mileIds))
            {
                mileWhere = Exp.In("t.id", mileIds);
            }
            else
            {
                mileWhere = BuildLike(new[] { "t.title" }, text, projectId);
            }

            return(MilestoneDao.GetMilestones(mileWhere));
        }
        private IEnumerable <DomainObject <int> > GetSubtasks(String text)
        {
            Exp subtasksWhere;

            List <int> subtaskIds;

            if (FactoryIndexer <SubtasksWrapper> .TrySelectIds(s => s.MatchAll(text), out subtaskIds))
            {
                subtasksWhere = Exp.In("id", subtaskIds);
            }
            else
            {
                subtasksWhere = BuildLike(new[] { "title" }, text);
            }

            return(SubtaskDao.GetSubtasks(subtasksWhere));
        }
        private IEnumerable <DomainObject <int> > GetProjects(String text, int projectId)
        {
            Exp projWhere;

            List <int> projIds;

            if (FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(text), out projIds))
            {
                projWhere = Exp.In("id", projIds);
            }
            else
            {
                projWhere = BuildLike(new[] { "title", "description" }, text, projectId);
            }

            return(ProjectDao.GetProjects(projWhere));
        }
        private IEnumerable <DomainObject <int> > GetMessages(String text, int projectId)
        {
            Exp messWhere;

            List <int> messIds;

            if (FactoryIndexer <DiscussionsWrapper> .TrySelectIds(s => s.MatchAll(text), out messIds))
            {
                messWhere = Exp.In("t.id", messIds);
            }
            else
            {
                messWhere = BuildLike(new[] { "t.title", "t.content" }, text, projectId);
            }

            return(MessageDao.GetMessages(messWhere));
        }
        private IEnumerable <DomainObject <int> > GetComments(String text)
        {
            Exp commentsWhere;

            List <int> commentIds;

            if (FactoryIndexer <CommentsWrapper> .TrySelectIds(s => s.MatchAll(text).Where(r => r.InActive, false), out commentIds))
            {
                commentsWhere = Exp.In("comment_id", commentIds);
            }
            else
            {
                commentsWhere = BuildLike(new[] { "content" }, text);
            }

            return(CommentDao.GetComments(commentsWhere));
        }
        private IEnumerable <DomainObject <int> > GetTasks(String text, int projectId)
        {
            Exp taskWhere;

            List <int> taskIds;

            if (FactoryIndexer <TasksWrapper> .TrySelectIds(s => s.MatchAll(text), out taskIds))
            {
                taskWhere = Exp.In("t.id", taskIds);
            }
            else
            {
                taskWhere = BuildLike(new[] { "t.title", "t.description" }, text, projectId);
            }

            return(TaskDao.GetTasks(taskWhere));
        }
Exemplo n.º 24
0
        public void ProjectExactly(string searchText)
        {
            List <int> result;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.Or(r => r.Match(a => a.Title, "\"" + searchText + "\""), r => r.Match(a => a.Description, "\"" + searchText + "\"")), out result);

            foreach (var prj in Projects)
            {
                CollectionAssert.Contains(result, prj.ID);
            }

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll("\"" + searchText + "\""), out result);

            foreach (var prj in Projects)
            {
                CollectionAssert.Contains(result, prj.ID);
            }
        }
Exemplo n.º 25
0
        private IEnumerable <Folder> Search(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(new List <Folder>());
            }
            List <int> ids;

            if (FactoryIndexer <FoldersWrapper> .TrySelectIds(s => s.MatchAll(text), out ids))
            {
                return(dbManager
                       .ExecuteList(GetFolderQuery(Exp.In("id", ids)))
                       .ConvertAll(ToFolder));
            }

            return(dbManager
                   .ExecuteList(GetFolderQuery(BuildSearch("title", text)))
                   .ConvertAll(ToFolder));
        }
Exemplo n.º 26
0
        public static bool TrySelectContact(string text, out List <int> result)
        {
            var success = false;

            result = new List <int>();

            List <int> contactsId;

            if (FactoryIndexer <ContactsWrapper> .TrySelectIds(s => s.MatchAll(text), out contactsId))
            {
                result.AddRange(contactsId);
                success = true;
            }

            IReadOnlyCollection <InfoWrapper> infos;

            if (FactoryIndexer <InfoWrapper> .TrySelect(s => s.MatchAll(text), out infos))
            {
                result.AddRange(infos.Select(r => r.ContactId).ToList());
                success = true;
            }

            IReadOnlyCollection <FieldsWrapper> personCustom;

            if (FactoryIndexer <FieldsWrapper> .TrySelect(s => s.MatchAll(text).In(r => r.EntityType, new[] { 0, 4, 5 }), out personCustom))
            {
                result.AddRange(personCustom.Select(r => r.EntityId).ToList());
                success = true;
            }

            IReadOnlyCollection <EventsWrapper> events;

            if (FactoryIndexer <EventsWrapper> .TrySelect(s => s.MatchAll(text).Gt(r => r.ContactId, 0), out events))
            {
                result.AddRange(events.Select(r => r.ContactId).ToList());
                success = true;
            }

            return(success);
        }
Exemplo n.º 27
0
        public void ProjectPhrase()
        {
            List <int> result;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.Match(r => r.Title, "\"Project for\""), out result);

            foreach (var prj in Projects)
            {
                CollectionAssert.Contains(result, prj.ID);
            }

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.Match(r => r.Title, "\"for search\""), out result);

            CollectionAssert.IsEmpty(result);

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.Match(r => r.Title, "for search"), out result);

            foreach (var prj in Projects)
            {
                CollectionAssert.Contains(result, prj.ID);
            }
        }
Exemplo n.º 28
0
        public List <Page> SearchPagesByContent(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                return(new List <Page>());
            }

            IEnumerable <string> pagenames = null;

            List <int> pages;

            if (FactoryIndexer <WikiWrapper> .TrySelectIds(r => r.MatchAll(content), out pages))
            {
                return(GetPagesById(pages));
            }

            var keys = content.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                       .Select(k => k.Trim())
                       .Where(k => 3 <= k.Length);

            var where = Exp.Empty;
            foreach (var k in keys)
            {
                @where &= Exp.Like("h.pagename", k) | Exp.Like("h.body", k);
            }

            var q = Query("wiki_pages p")
                    .Select("p.pagename")
                    .InnerJoin("wiki_pages_history h", Exp.EqColumns("p.tenant", "h.tenant") & Exp.EqColumns("p.pagename", "h.pagename") & Exp.EqColumns("p.version", "h.version"))
                    .Where(@where)
                    .OrderBy("p.modified_on", false)
                    .SetMaxResults(MAX_FIND);

            pagenames = db
                        .ExecuteList(q)
                        .ConvertAll(r => (string)r[0]);

            return(GetPages(pagenames));
        }
Exemplo n.º 29
0
        private List <int> SearchPostsInternal(string searchText)
        {
            List <int> blogs;

            if (FactoryIndexer <BlogsWrapper> .TrySelectIds(r => r.MatchAll(searchText), out blogs))
            {
                return(blogs);
            }

            var keyWords = new List <string>(searchText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));

            keyWords.RemoveAll(kw => kw.Length < 3);

            var wordResults = new Dictionary <string, int>(keyWords.Count);
            var counts      = new Dictionary <int, int>();
            var wordsCount  = 0;

            foreach (var word in keyWords.Where(word => !wordResults.ContainsKey(word)))
            {
                wordsCount++;
                var wordResult = _storage.GetPostDao().SearchPostsByWord(word);
                wordResults.Add(word, wordResult.Count);

                wordResult.ForEach(
                    pid =>
                {
                    if (counts.ContainsKey(pid))
                    {
                        counts[pid] = counts[pid] + 1;
                    }
                    else
                    {
                        counts.Add(pid, 1);
                    }
                });
            }

            return((from kw in counts where kw.Value == wordsCount select kw.Key).ToList());
        }
Exemplo n.º 30
0
        public void ProjectDeleteByQuery()
        {
            var searchText = "QAZWSX";
            var proj       = CreateProject(searchText, "Description");

            List <int> result;
            var        tenant = CoreContext.TenantManager.GetCurrentTenant();

            FactoryIndexer <ProjectsWrapper> .Delete(r => r.Match(a => a.Title, searchText));

            CoreContext.TenantManager.SetCurrentTenant(tenant.TenantId);
            SecurityContext.CurrentUser = tenant.OwnerId;;

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(searchText), out result);

            CollectionAssert.IsEmpty(result);

            Delete(proj);

            FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll("Another"), out result);

            CollectionAssert.IsNotEmpty(result);
        }