Esempio n. 1
0
 public void Should_return_first_result_with_number()
 {
     using (var documentDb = new DocSharp(DbName))
     {
         var insertedDoc = documentDb.Store(new Company { Name = "Company Name ", Phone= 123 });
         documentDb.Store(new Company { Name = "Company Name" });
         var result = documentDb.Query<Company>().First(q => q.Data.Phone == 123);
         Assert.AreEqual(insertedDoc.Id, result.Id);
     }
 }
Esempio n. 2
0
 public void Should_find_any_entites_that_match_any_query()
 {
     using (var documentDb = new DocSharp(DbName))
     {
         documentDb.Store(new Company { Name = "Company Name ", Phone = 123 });
         documentDb.Store(new Company { Name = "Company Name " });
         documentDb.Store(new Company { Name = "Company Name " });
         Assert.IsTrue(documentDb.Query<Company>().Any(q => q.Data.Name == "Company Name "));
     }
 }
Esempio n. 3
0
 public void Should_return_count_of_companies()
 {
     using (var documentDb = new DocSharp(DbName))
     {
         documentDb.Store(new Company { Name = "Company Name ", Phone = 123 });
         documentDb.Store(new Company { Name = "Company Name " });
         documentDb.Store(new Company { Name = "Company Name " });
         var result = documentDb.Query<Company>().Count(q => q.Data.Name == "Company Name ");
         Assert.AreEqual(result, 3);
     }
 }
Esempio n. 4
0
        public void Should_query_for_object()
        {
            using (var documentDb = new DocSharp(DbName))
            {
                documentDb.Store(new Company { Name = "My Company 1" });
                documentDb.Store(new Company { Name = "My Company 2" });
                documentDb.Store(new Company { Name = "My Company 3" });
                documentDb.Store(new Contact { FirstName = "Bob", Surname = "Smith"});
            }

            using (var documentDb = new DocSharp(DbName))
            {
                var documentsFound = documentDb.Query<Company>(q => q.Name.Contains("3"));
                Assert.AreEqual(1, documentsFound.Count);
            }
        }
Esempio n. 5
0
        public void Test_speed_of_query_with_index()
        {
            using (var documentDb = new DocSharp(DbName))
            {
                documentDb.Index<Company>(q => q.Name);

                for (int i = 0; i < 1000; i++)
                {
                    documentDb.Store(new Company { Name = "Company Name " + i});
                }

                for (int i = 0; i < 1000; i++)
                {
                    documentDb.Store(new Contact { FirstName = "Andrew", Surname = "Stewart"});
                }

                for (int i = 0; i < 500; i++)
                {
                    documentDb.Store(new Company { Name = "Company Name World" + i });
                }

                for (int i = 0; i < 1000; i++)
                {
                    documentDb.Store(new Contact { FirstName = "Bob", Surname = "Smith" });
                }

                for (int i = 0; i < 1000; i++)
                {
                    documentDb.Store(new Company { Name = "Company Name " + i });
                }

                var startTime = DateTime.Now;
                var documentsFound = documentDb.Query<Company>(q => q.Name.Contains("World"));
                var timeQueryTaken = DateTime.Now.Subtract(startTime);
                Console.WriteLine("Query Time (ms)- " + DateTime.Now.Subtract(startTime).TotalMilliseconds);
                Assert.AreEqual(500, documentsFound.Count);
                Assert.IsTrue(timeQueryTaken.TotalMilliseconds <= 500);
            }
        }