/// <exception cref="System.Exception"></exception>
 public virtual void Test2Objects()
 {
     if (!isLocal)
     {
         return;
     }
     NeoDatis.Odb.ODB odb = null;
     DeleteBase(Base);
     try
     {
         odb = Open(Base);
         odb.AddInsertTrigger(typeof(NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId),
                              new NeoDatis.Odb.Test.Trigger.LocalAutoIncrementTrigger());
         NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId o = new NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId
                                                                     ("Object 1");
         odb.Store(o);
         AssertEquals(1, o.GetId());
         odb.Close();
         odb = Open(Base);
         odb.AddInsertTrigger(typeof(NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId),
                              new NeoDatis.Odb.Test.Trigger.LocalAutoIncrementTrigger());
         o = new NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId("Object 2");
         odb.Store(o);
         AssertEquals(2, o.GetId());
     }
     finally
     {
         if (odb != null)
         {
             odb.Close();
         }
     }
 }
Beispiel #2
0
        public virtual void Test1()
        {
            if (!isLocal && !testNewFeature)
            {
                return;
            }
            NeoDatis.Odb.ODB odb      = null;
            string           baseName = GetBaseName();

            DeleteBase(baseName);
            NeoDatis.Odb.Test.Trigger.MyTriggerBefore myTrigger = new NeoDatis.Odb.Test.Trigger.MyTriggerBefore
                                                                      ();
            try
            {
                odb = Open(baseName);
                odb.AddInsertTrigger(typeof(NeoDatis.Odb.Test.Trigger.SimpleObject), myTrigger);
                NeoDatis.Odb.Test.Trigger.SimpleObject so = new NeoDatis.Odb.Test.Trigger.SimpleObject
                                                                (5);
                NeoDatis.Odb.OID oid = odb.Store(so);
                AssertEquals(6, so.GetId());
                odb.Close();
                odb = Open(baseName);
                NeoDatis.Odb.Test.Trigger.SimpleObject so2 = (NeoDatis.Odb.Test.Trigger.SimpleObject
                                                              )odb.GetObjectFromId(oid);
                AssertEquals(6, so2.GetId());
            }
            finally
            {
                if (odb != null)
                {
                    odb.Close();
                }
            }
            DeleteBase(baseName);
        }
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1000Objects()
 {
     if (!isLocal)
     {
         return;
     }
     NeoDatis.Odb.ODB odb = null;
     DeleteBase(Base);
     try
     {
         odb = Open(Base);
         odb.AddInsertTrigger(typeof(NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId),
                              new NeoDatis.Odb.Test.Trigger.LocalAutoIncrementTrigger());
         for (int i = 0; i < 1000; i++)
         {
             NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId o = new NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId
                                                                         ("Object " + (i + 1));
             odb.Store(o);
             AssertEquals(i + 1, o.GetId());
         }
         odb.Close();
         odb = Open(Base);
         odb.AddInsertTrigger(typeof(NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId),
                              new NeoDatis.Odb.Test.Trigger.LocalAutoIncrementTrigger());
         for (int i = 0; i < 1000; i++)
         {
             NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId o = new NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId
                                                                         ("Object - bis - " + (i + 1));
             odb.Store(o);
             AssertEquals(1000 + i + 1, o.GetId());
         }
         odb.Close();
     }
     finally
     {
     }
 }
Beispiel #4
0
 // To test if triggers are called on recursive objects
 /// <exception cref="System.Exception"></exception>
 public virtual void Test2()
 {
     if (!isLocal)
     {
         return;
     }
     NeoDatis.Odb.ODB odb = null;
     DeleteBase("trigger.neodatis");
     NeoDatis.Odb.Test.Trigger.MyTrigger myTrigger = new NeoDatis.Odb.Test.Trigger.MyTrigger
                                                         ();
     try
     {
         odb = Open("trigger.neodatis");
         odb.AddInsertTrigger(typeof(Function), myTrigger);
         Function f1 = new Function(
             "function1");
         Function f2 = new Function(
             "function2");
         Profile profile = new Profile
                               ("profile1", f1);
         User user = new User("oli",
                              "*****@*****.**", profile);
         odb.Store(user);
         odb.Store(f2);
     }
     finally
     {
         if (odb != null)
         {
             odb.Close();
         }
     }
     odb = Open("trigger.neodatis");
     odb.Close();
     DeleteBase("trigger.neodatis");
     AssertEquals(2, myTrigger.nbInsertsBefore);
     AssertEquals(2, myTrigger.nbInsertsAfter);
 }