Inheritance: IRecordQueryer
示例#1
0
        public void should_return_correct_result_count_for_keywords(string keyword, int expected)
        {
            var input = EmptyQuery().With(q => q.K = new [] { keyword });
            var output = new RecordQueryer(Db).Search(input);

            output.Total.Should().Be(expected);
        }
        public void ShouldGetRightResults()
        {
            var documentStore = DatabaseFactory.InMemory(8889);

            new RecordIndex().Execute(documentStore);

            using (var db = documentStore.OpenSession())
            {
                new[] { "foo", "foo (bar)" }.Select(MakeRecord).ForEach(db.Store);

                db.SaveChanges();
            }

            RavenUtility.WaitForIndexing(documentStore);

            using (var db = documentStore.OpenSession())
            {
                Action<string, int> testCase = (k, n) =>
                {
            //                    var query = db.Query<MyIndex.Result, MyIndex>()
            //                        .Where(r => r.Keywords.Contains(k));
            //                    var results = query.As<Record>().Take(10).ToList();
            //                    results.Count.Should().Be(n);

                    var input = EmptyQuery().With(q => q.K = new[] { k });
                    var output = new RecordQueryer(db).Search(input);
                    output.Total.Should().Be(n);
                };

                // todo how to deal with empty keyword?
            //                testCase("", 0);
                testCase("http://vocab/xxx", 0);
            //                testCase("http://vocab/foo", 1);
            //                testCase("http://vocab/foo (xxx)", 0);
            //                testCase("http://vocab/foo (bar)", 1);
            //                testCase("http://vocab/foo - (xxx)", 0);
            }
        }
示例#3
0
文件: SearchTest.cs 项目: jncc/topcat
 public void setUp()
 {
     _recordQueryer = new RecordQueryer(Db);
 }
示例#4
0
文件: Program.cs 项目: jncc/topcat
        static List<Record> GetRecords(IDocumentSession db, string keyword)
        {
            var recordQueryer = new RecordQueryer(db);
            var query = new RecordQueryInputModel
            {
                K = new[] { keyword },
                N = 1024,
            };

            int count = recordQueryer.Query(query).Count();

            var records = recordQueryer.Query(query).ToList();

            if (records.Count != count)
                throw new Exception("Too many records.");

            return records;
        }