コード例 #1
0
ファイル: TableTests.cs プロジェクト: zumten/dotnet-mindex
        public void Search_FilteringBySiteRankingSearchTopDomainByComOrgNet_ShouldBeEquivalentToLinq()
        {
            var       topLevelDomains    = new[] { "com", "net", "org " };
            const int topLevelDomainRank = 1000;

            var expected = _rows.Where(x => topLevelDomains.Contains(x.TopLevelDomain) && x.TopLevelDomainRank <= topLevelDomainRank).ToList();
            var search   = new SiteRankingSearch
            {
                TopLevelDomain     = topLevelDomains,
                TopLevelDomainRank = SearchCriteria.ByRange(1, topLevelDomainRank)
            };
            var actual      = _table.Search(search);
            var indexScores = _table.EvaluateIndexes(search);

            CollectionAssert.AreEquivalent(expected, actual);

            var searchWithPredicate = new SiteRankingSearch
            {
                TopLevelDomain     = topLevelDomains,
                TopLevelDomainRank = SearchCriteria.ByPredicate((int x) => x <= topLevelDomainRank)
            };
            var actualWithPredicate     = _table.Search(searchWithPredicate);
            var indexScoreWithPredicate = _table.EvaluateIndexes(searchWithPredicate);

            CollectionAssert.AreEquivalent(expected, actualWithPredicate);

            Assert.IsTrue(indexScores[0].Score < indexScoreWithPredicate[0].Score, "Search without predicate should have a better score");
        }
コード例 #2
0
        public void GetScore_CriteriaByPredicate_ShouldReturnScoreOf_1()
        {
            var rows   = SiteRankingCollections.First10000Rows;
            var search = new SiteRankingSearch {
                TopLevelDomain = SearchCriteria.ByPredicate((string x) => x.StartsWith("c"))
            };
            var expectedScore = new TableCriteriaScore(1, false);

            TestGetScores(rows, search, expectedScore);
        }
コード例 #3
0
        public void Reduce_CriteriaByPredicate_ShouldReturnNull()
        {
            var rows   = SiteRankingCollections.First10000Rows;
            var search = new SiteRankingSearch {
                TopLevelDomain = SearchCriteria.ByPredicate((string x) => x == "ca")
            };
            var criteria = BuildCriteria(rows, search);
            var actual   = criteria.Reduce(new BinarySearchTable <SiteRanking>(rows));

            Assert.IsNull(actual);
        }