Example #1
0
        public void Search_SearchOptions_Set_Properties()
        {
            var searchValue = new Search.Search
            {
                SearchInput   = "Hello World",
                SearchOptions = new SearchOptions
                {
                    IsAllSelected            = false,
                    IsWorkflowNameSelected   = true,
                    IsMatchCaseSelected      = false,
                    IsMatchWholeWordSelected = true,
                    IsTestNameSelected       = true,
                    IsScalarNameSelected     = false,
                    IsObjectNameSelected     = false,
                    IsRecSetNameSelected     = false,
                    IsToolTitleSelected      = false,
                    IsOutputVariableSelected = false,
                    IsInputVariableSelected  = true
                }
            };

            Assert.IsTrue(searchValue.SearchOptions.IsVariableSelected);
            Assert.IsFalse(searchValue.SearchOptions.IsAllSelected);
            Assert.IsTrue(searchValue.SearchOptions.IsWorkflowNameSelected);
            Assert.IsFalse(searchValue.SearchOptions.IsMatchCaseSelected);
            Assert.IsTrue(searchValue.SearchOptions.IsMatchWholeWordSelected);
            Assert.IsTrue(searchValue.SearchOptions.IsTestNameSelected);
            Assert.IsFalse(searchValue.SearchOptions.IsScalarNameSelected);
            Assert.IsFalse(searchValue.SearchOptions.IsObjectNameSelected);
            Assert.IsFalse(searchValue.SearchOptions.IsRecSetNameSelected);
            Assert.IsFalse(searchValue.SearchOptions.IsToolTitleSelected);
            Assert.IsFalse(searchValue.SearchOptions.IsOutputVariableSelected);
            Assert.IsTrue(searchValue.SearchOptions.IsInputVariableSelected);
        }
Example #2
0
        public void Search_GetSearchResults()
        {
            var searchValue = new Search.Search
            {
                SearchInput   = "Set",
                SearchOptions = new SearchOptions
                {
                    IsAllSelected      = false,
                    IsTestNameSelected = true
                }
            };
            var mockResourceCatalog = new Mock <IResourceCatalog>();
            var mockResource        = new Mock <IResource>();

            mockResource.Setup(r => r.ResourceID).Returns(Guid.Empty);
            mockResource.Setup(r => r.ResourceName).Returns("Test Resource");
            mockResource.Setup(r => r.GetResourcePath(It.IsAny <Guid>())).Returns("Folder");
            mockResourceCatalog.Setup(res => res.GetResource(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(mockResource.Object);
            var mockTestCatalog = new Mock <ITestCatalog>();

            mockTestCatalog.Setup(t => t.FetchAllTests()).Returns(new List <IServiceTestModelTO>
            {
                new ServiceTestModelTO
                {
                    TestName = "Bob Test"
                },
                new ServiceTestModelTO
                {
                    TestName = "Set Test"
                }
                ,
                new ServiceTestModelTO
                {
                    TestName = "Test set value"
                }
            });

            var searchers = new List <ISearcher>
            {
                new TestSearcher(mockResourceCatalog.Object, mockTestCatalog.Object)
            };

            var searchResults = searchValue.GetSearchResults(searchers);

            Assert.AreEqual(2, searchResults.Count);
            var searchResult = searchResults[0];

            Assert.AreEqual(Guid.Empty, searchResult.ResourceId);
            Assert.AreEqual("Set Test", searchResult.Match);
            Assert.AreEqual("Test Resource", searchResult.Name);
            Assert.AreEqual("Folder", searchResult.Path);

            searchResult = searchResults[1];
            Assert.AreEqual(Guid.Empty, searchResult.ResourceId);
            Assert.AreEqual("Test set value", searchResult.Match);
            Assert.AreEqual("Test Resource", searchResult.Name);
            Assert.AreEqual("Folder", searchResult.Path);
        }
Example #3
0
        /// <summary>
        /// Construct the nexus
        /// </summary>
        public Nexus()
        {
            _Protocol = new Protocol.Protocol(Configuration.ProtocolPort(), this);
            _Search = new Search.Search();
            _Peers = new PeerList();
            _Multicast = new Multicast.Multicast(this, true, true);

            _UsedPorts.Add(8000);
        }
Example #4
0
        public void Search_Ctor()
        {
            var searchValue = new Search.Search
            {
                SearchInput   = "Set",
                SearchOptions = new SearchOptions()
            };

            Assert.IsNotNull(searchValue);
            Assert.IsFalse(searchValue.SearchOptions.IsAllSelected);
            Assert.AreEqual("Set", searchValue.SearchInput);
        }
Example #5
0
        public void SearchUtils_FilterText_MatchingWord2_ShouldReturnTrue()
        {
            var searchValue = new Search.Search
            {
                SearchInput   = "Set",
                SearchOptions = new SearchOptions
                {
                    IsAllSelected       = false,
                    IsToolTitleSelected = true
                }
            };
            var result = SearchUtils.FilterText("this Setasdf", searchValue);

            Assert.IsTrue(result);
        }
Example #6
0
        public void SearchUtils_FilterText_MatchingWholeWord_RegexShouldReturnTrue()
        {
            var searchValue = new Search.Search
            {
                SearchInput   = "Hello World",
                SearchOptions = new SearchOptions
                {
                    IsAllSelected            = false,
                    IsWorkflowNameSelected   = true,
                    IsMatchCaseSelected      = false,
                    IsMatchWholeWordSelected = true
                }
            };
            var result = SearchUtils.FilterText("Hello World", searchValue);

            Assert.IsTrue(result);
        }
Example #7
0
        public void Search_SearchOptions_IsVariableSelected_ExpectFalse()
        {
            var searchValue = new Search.Search
            {
                SearchInput   = "Hello World",
                SearchOptions = new SearchOptions
                {
                    IsScalarNameSelected     = false,
                    IsObjectNameSelected     = false,
                    IsRecSetNameSelected     = false,
                    IsToolTitleSelected      = false,
                    IsOutputVariableSelected = false,
                    IsInputVariableSelected  = false
                }
            };

            Assert.IsFalse(searchValue.SearchOptions.IsVariableSelected);
        }
Example #8
0
        protected void _GetSearchResults(CMSPageRequest pageRequest)
        {
            int  pagesize, page;
            bool all;

            Search.SiteSearch siteSearch;
            SearchInstruction instructions = getSearchInstructions(pageRequest,
                                                                   out page,
                                                                   out pagesize,
                                                                   out all,
                                                                   out siteSearch);

            Search.Search search = new Search.Search(Request);

            int count = 0;

            //use the SearchInstruction based overload method to achieve maxt flexibility
            pageRequest.Tag = search.QueryFinal(siteSearch, out count, instructions,
                                                200, all, page, pagesize);
        }
Example #9
0
 // Constructor.
 public Board()
 {
     Searcher      = new Search.Search(this);
     pieces        = new int[Variables.BRD_SQ_NUM];
     Pawns         = new ulong[3];
     KingSq        = new int[2];
     EnPas         = 99; // NO_SQ
     Side          = -1;
     FiftyMoves    = -1;
     Ply           = 0;
     HistoryPly    = 0;
     PceNum        = new int[13];
     Material      = new int[2];
     BigPieces     = new int[2];
     MajPieces     = new int[2];
     MinPieces     = new int[2];
     CastlePerm    = -1;
     PList         = new int[13, 10];
     SearchHistory = new int[13, Variables.BRD_SQ_NUM];
     SearchKillers = new int[2, Variables.MAX_DEPTH];
     HistoryInit();
     PvTable = new PvTable(20000);
     PvArray = new int[Variables.MAX_DEPTH];
 }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchIq"/> class.
 /// </summary>
 public SearchIq()
 {
     GenerateId();
     Search = new Search.Search();
 }
        protected void _GetSearchResults(CMSPageRequest pageRequest)
        {
            int  pagesize, page;
            bool all;

            Search.SiteSearch siteSearch;
            SearchInstruction instructions = getSearchInstructions(pageRequest,
                                                                   out page,
                                                                   out pagesize,
                                                                   out all,
                                                                   out siteSearch);

            //override pagesize from Schema
            var pgSize = pageRequest.GetElementValue("ResultsPageSize");

            if (pgSize != null)
            {
                pagesize = pgSize.ToInt() ?? 10;
            }

            Search.Search search = new Search.Search(Request);

            int count = 0;

            if (search != null)
            {
                //use the SearchInstruction based overload method to achieve max flexibility (non-paginated results)
                var pageResults = search.QueryFinal(siteSearch, out count, instructions, 200, true);

                //find matches for both member records and pages
                var    M           = new MembersWrapper();
                string termsString = pageRequest.QueryString["terms"] ?? "";
                //var memDic = M.Search(termsString);
                var memDic       = new List <KeyValuePair <string, Member> >();
                var pgCollection = pageResults
                                   .Select(r => new KeyValuePair <float, SearchResultItem>(r.Score, r));

                //apply sourceFilter and merge the two dictionaries
                string sourceFilter = pageRequest.QueryString["sourceFilter"] ?? "";
                IEnumerable <KeyValuePair <float, object> > mergedCollection = new KeyValuePair <float, object> [0];
                if (sourceFilter == "" || sourceFilter != "members")
                {
                    mergedCollection = pgCollection
                                       .Where(x =>
                    {
                        bool externalItem = (x.Value.Type == "ingeniux.search.htmlsitesource");
                        return(sourceFilter == "" ||
                               (sourceFilter == "local" && !externalItem) ||
                               (sourceFilter == "bni.com" && externalItem));
                    })
                                       .Select(x =>
                                               new KeyValuePair <float, object>(x.Key, x.Value));
                }

                if (sourceFilter == "" || sourceFilter == "members")
                {
                    mergedCollection = mergedCollection
                                       .Concat(memDic
                                               .Select(x => new KeyValuePair <float, object>(float.Parse(x.Key.SubstringBefore("_")), x.Value)));
                }

                //sort results
                var returnResults = mergedCollection.OrderByDescending(x => x.Key).Select(x => x.Value).ToList();

                //apply pagination
                ViewBag.totalResults = returnResults.Count;
                ViewBag.pageSize     = pagesize;
                pageRequest.Tag      = returnResults.Skip((page - 1) * pagesize).Take(pagesize).ToList();
                //pageRequest.Tag = mergedDic;  //no pagination
            }
        }