Exemplo n.º 1
0
        public virtual void Test1()
        {
            Println("************START OF TEST1***************");

            DeleteBase("index-object");
            IndexedObject2 o1;

            using (var odb = Open("index-object"))
            {
                var fields = new[] { "object" };
                odb.IndexManagerFor <IndexedObject2>().AddUniqueIndexOn("index1", fields);
                o1 = new IndexedObject2("Object1", new IndexedObject("Inner Object 1", 10, new DateTime()));
                odb.Store(o1);

                Assert.That(odb.IndexManagerFor <IndexedObject2>().ExistIndex("index1"), Is.True);

                var indexes = odb.QueryAndExecute <ClassInfoIndex>().ToList();
                Assert.That(indexes.Count, Is.EqualTo(1));
            }

            using (var odb = Open("index-object"))
            {
                var indexes = odb.QueryAndExecute <ClassInfoIndex>().ToList();
                Assert.That(indexes.Count, Is.EqualTo(1));

                Assert.That(odb.IndexManagerFor <IndexedObject2>().ExistIndex("index1"), Is.True);

                var query   = odb.Query <IndexedObject>();
                var objects = query.Execute <IndexedObject>();
                var io      = objects.GetFirst();

                IQuery q = odb.Query <IndexedObject2>();
                q.Descend("object").Constrain(io).Identity();

                var            objects2 = q.Execute <IndexedObject2>();
                IndexedObject2 o2       = objects2.GetFirst();

                AssertEquals(o1.GetName(), o2.GetName());
                Println(((IInternalQuery)q).GetExecutionPlan().GetDetails());
                AssertFalse(((IInternalQuery)q).GetExecutionPlan().GetDetails().IndexOf("index1") == -1);
            }

            DeleteBase("index-object");
            Println("************END OF TEST1***************");
        }
Exemplo n.º 2
0
        public virtual void Test1()
        {
            Println("************START OF TEST1***************");
            
            DeleteBase("index-object");
            IndexedObject2 o1;
            using (var odb = Open("index-object"))
            {
                var fields = new[] {"object"};
                odb.IndexManagerFor<IndexedObject2>().AddUniqueIndexOn("index1", fields);
                o1 = new IndexedObject2("Object1", new IndexedObject("Inner Object 1", 10, new DateTime()));
                odb.Store(o1);

                Assert.That(odb.IndexManagerFor<IndexedObject2>().ExistIndex("index1"), Is.True);

                var indexes = odb.QueryAndExecute<ClassInfoIndex>().ToList();
                Assert.That(indexes.Count, Is.EqualTo(1));
            }

            using (var odb = Open("index-object"))
            {
                var indexes = odb.QueryAndExecute<ClassInfoIndex>().ToList();
                Assert.That(indexes.Count, Is.EqualTo(1));

                Assert.That(odb.IndexManagerFor<IndexedObject2>().ExistIndex("index1"), Is.True);

                var query = odb.Query<IndexedObject>();
                var objects = query.Execute<IndexedObject>();
                var io = objects.GetFirst();

                IQuery q = odb.Query<IndexedObject2>();
                q.Descend("object").Constrain(io).Identity();

                var objects2 = q.Execute<IndexedObject2>();
                IndexedObject2 o2 = objects2.GetFirst();

                AssertEquals(o1.GetName(), o2.GetName());
                Println(((IInternalQuery)q).GetExecutionPlan().GetDetails());
                AssertFalse(((IInternalQuery)q).GetExecutionPlan().GetDetails().IndexOf("index1") == -1);
            }

            DeleteBase("index-object");
            Println("************END OF TEST1***************");
        }