Ejemplo n.º 1
0
        public virtual void Test15_by_oid_2()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            DeleteBase(baseName);
            odb = Open(baseName);
            Function f1 = new Function(
                "function1");
            Function f2 = new Function(
                "function2");

            NeoDatis.Odb.OID oid1 = odb.Store(f1);
            NeoDatis.Odb.OID oid2 = odb.Store(f2);
            AssertEquals(2, odb.Count(new CriteriaQuery
                                          (typeof(Function))));
            odb.Close();
            odb = Open(baseName);
            odb.DeleteObjectWithId(oid1);
            odb.DeleteObjectWithId(oid2);
            AssertEquals(0, odb.Count(new CriteriaQuery
                                          (typeof(Function))));
            odb.Store(f1);
            odb.Store(f2);
            AssertEquals(2, odb.Count(new CriteriaQuery
                                          (typeof(Function))));
            odb.Close();
            odb = Open(baseName);
            AssertEquals(2, odb.GetObjects <Function>().Count
                         );
            odb.Close();
            DeleteBase(baseName);
        }
Ejemplo n.º 2
0
        /// <summary>creates 2 objects.</summary>
        /// <remarks>creates 2 objects. Delete them by oid. And create 2 new objects</remarks>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test15_by_oid()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function1");
            NeoDatis.Odb.Test.VO.Login.Function f2 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function2");
            NeoDatis.Odb.OID oid1 = odb.Store(f1);
            NeoDatis.Odb.OID oid2 = odb.Store(f2);
            AssertEquals(2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                          (typeof(NeoDatis.Odb.Test.VO.Login.Function))));
            odb.DeleteObjectWithId(oid1);
            odb.DeleteObjectWithId(oid2);
            AssertEquals(0, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                          (typeof(NeoDatis.Odb.Test.VO.Login.Function))));
            odb.Store(f1);
            odb.Store(f2);
            AssertEquals(2, odb.Count(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                          (typeof(NeoDatis.Odb.Test.VO.Login.Function))));
            odb.Close();
            odb = Open(baseName);
            AssertEquals(2, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count
                         );
            odb.Close();
            DeleteBase(baseName);
        }
Ejemplo n.º 3
0
        /// <exception cref="System.Exception"></exception>
        public virtual void T1estE1()
        {
            test.DeleteBase("acid1");
            NeoDatis.Odb.ODB odb = test.Open("acid1");
            int size             = 1000;

            NeoDatis.Odb.OID[] oids = new NeoDatis.Odb.OID[size];
            for (int i = 0; i < size; i++)
            {
                oids[i] = odb.Store(GetInstance("f" + i));
                if (simpleObject)
                {
                    NeoDatis.Odb.Test.VO.Login.Function f = (NeoDatis.Odb.Test.VO.Login.Function)odb.
                                                            GetObjectFromId(oids[i]);
                    f.SetName("function " + i);
                    odb.Store(f);
                }
                else
                {
                    NeoDatis.Odb.Test.VO.Login.User f = (NeoDatis.Odb.Test.VO.Login.User)odb.GetObjectFromId
                                                            (oids[i]);
                    f.SetName("function " + i);
                    odb.Store(f);
                }
                odb.DeleteObjectWithId(oids[i]);
            }
        }
Ejemplo n.º 4
0
        public virtual void Test20()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            odb = Open(baseName);
            Function f0 = new Function(
                "1function0");

            odb.Store(f0);
            odb.Close();
            odb = Open(baseName);
            Function f1 = new Function(
                "function1");

            odb.Store(f1);
            odb.Commit();
            NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>(new CriteriaQuery(Where.Like("name", "func%")));
            AssertEquals(1, objects.Count);
            Function f2 = (Function)objects
                          .GetFirst();

            NeoDatis.Odb.OID oid = odb.GetObjectId(f2);
            odb.DeleteObjectWithId(oid);
            AssertEquals(1, odb.GetObjects <Function>().Count
                         );
            odb.Close();
            odb     = Open(baseName);
            objects = odb.GetObjects <Function>();
            AssertEquals(1, objects.Count);
        }
Ejemplo n.º 5
0
        public virtual void Test19()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            odb = Open(baseName);
            Function f1 = new Function(
                "function1");

            odb.Store(f1);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Objects <Function> objects = odb.GetObjects <Function>();
            AssertEquals(1, objects.Count);
            Function f2 = (Function)objects
                          .GetFirst();

            NeoDatis.Odb.OID oid = odb.GetObjectId(f2);
            odb.DeleteObjectWithId(oid);
            AssertEquals(0, odb.GetObjects <Function>().Count
                         );
            odb.Close();
            odb     = Open(baseName);
            objects = odb.GetObjects <Function>();
            AssertEquals(0, objects.Count);
        }
Ejemplo n.º 6
0
        public virtual void Test16()
        {
            string baseName = GetBaseName();
            int    size     = isLocal ? 10000 : 100;

            NeoDatis.Odb.ODB odb = null;
            DeleteBase(baseName);
            odb = Open(baseName);
            NeoDatis.Odb.OID[] oids = new NeoDatis.Odb.OID[size];
            for (int i = 0; i < size; i++)
            {
                oids[i] = odb.Store(new Function("function" + i));
            }
            AssertEquals(size, odb.Count(new CriteriaQuery
                                             (typeof(Function))));
            for (int i = 0; i < size; i++)
            {
                odb.DeleteObjectWithId(oids[i]);
            }
            AssertEquals(0, odb.Count(new CriteriaQuery
                                          (typeof(Function))));
            for (int i = 0; i < size; i++)
            {
                oids[i] = odb.Store(new Function("function" + i));
            }
            AssertEquals(size, odb.Count(new CriteriaQuery
                                             (typeof(Function))));
            odb.Close();
            odb = Open(baseName);
            AssertEquals(size, odb.GetObjects <Function>().Count
                         );
            odb.Close();
            DeleteBase(baseName);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Stores on object and close database then Stores another object, commits
        /// without closing.
        /// </summary>
        /// <remarks>
        /// Stores on object and close database then Stores another object, commits
        /// without closing. Loads the object, gets its oid and delete by oid. In the
        /// case the commit has no write actions. And there was a bug : when there is
        /// no write actions, the commit process is much more simple! but in this the
        /// cache was not calling the transaction.clear and this was a reason for
        /// some connected/unconnected zone problem! (step14 of the turotial.)
        /// </remarks>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual void Test20()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f0 = new NeoDatis.Odb.Test.VO.Login.Function(
                "1function0");
            odb.Store(f0);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f1 = new NeoDatis.Odb.Test.VO.Login.Function(
                "function1");
            odb.Store(f1);
            odb.Commit();
            NeoDatis.Odb.Objects objects = odb.GetObjects(new NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                              (typeof(NeoDatis.Odb.Test.VO.Login.Function), NeoDatis.Odb.Core.Query.Criteria.Where
                                                              .Like("name", "func%")));
            AssertEquals(1, objects.Count);
            NeoDatis.Odb.Test.VO.Login.Function f2 = (NeoDatis.Odb.Test.VO.Login.Function)objects
                                                     .GetFirst();
            NeoDatis.Odb.OID oid = odb.GetObjectId(f2);
            odb.DeleteObjectWithId(oid);
            AssertEquals(1, odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function)).Count
                         );
            odb.Close();
            odb     = Open(baseName);
            objects = odb.GetObjects(typeof(NeoDatis.Odb.Test.VO.Login.Function));
            AssertEquals(1, objects.Count);
        }
Ejemplo n.º 8
0
        public virtual void Test12()
        {
            if (!isLocal)
            {
                return;
            }
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = null;
            odb = Open(baseName);
            Function f1 = new Function(
                "function1");
            Function f2 = new Function(
                "function2");
            Function f3 = new Function(
                "function3");

            odb.Store(f1);
            odb.Store(f2);
            odb.Store(f3);
            NeoDatis.Odb.OID idf1 = odb.GetObjectId(f1);
            NeoDatis.Odb.OID idf2 = odb.GetObjectId(f2);
            NeoDatis.Odb.OID idf3 = odb.GetObjectId(f3);
            odb.Close();
            try
            {
                odb = Open(baseName);
                odb.DeleteObjectWithId(idf3);
                odb.DeleteObjectWithId(idf2);
                odb.Close();
                odb = Open(baseName);
                NeoDatis.Odb.Objects <Function> l = odb.GetObjects <Function>();
                odb.Close();
                AssertEquals(1, l.Count);
            }
            catch (NeoDatis.Odb.ODBRuntimeException e)
            {
                DeleteBase(baseName);
                throw;
            }
        }
Ejemplo n.º 9
0
        /// <exception cref="System.Exception"></exception>
        public virtual void T1estC1()
        {
            test.DeleteBase("acid1");
            NeoDatis.Odb.ODB odb = test.Open("acid1");
            int size             = 1;

            NeoDatis.Odb.OID[] oids = new NeoDatis.Odb.OID[size];
            for (int i = 0; i < size; i++)
            {
                oids[i] = odb.Store(GetInstance("f" + i));
            }
            for (int i = 0; i < size; i++)
            {
                odb.DeleteObjectWithId(oids[i]);
            }
        }
Ejemplo n.º 10
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test5_byOid()
        {
            NeoDatis.Odb.ODB odb      = null;
            string           baseName = GetBaseName();

            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Function f = new NeoDatis.Odb.Test.VO.Login.Function("function1"
                                                                                            );
            odb.Store(f);
            NeoDatis.Odb.OID oid = odb.GetObjectId(f);
            try
            {
                odb.DeleteObjectWithId(oid);
                NeoDatis.Odb.OID id2 = odb.GetObjectId(f);
                Fail("The object has been deleted, the id should have been marked as deleted");
            }
            catch (NeoDatis.Odb.ODBRuntimeException)
            {
                odb.Close();
                DeleteBase(baseName);
            }
        }