Пример #1
0
        public virtual void Test2UpdateTriggers()
        {
            if (!testNewFeature)
            {
                return;
            }
            IOdb odb      = null;
            var  baseName = GetBaseName();

            DeleteBase(baseName);
            var myTrigger = new MyUpdateTriggerBefore();

            try
            {
                odb = Open(baseName);
                var so  = new SimpleObject(5);
                var oid = odb.Store(so);
                AssertEquals(5, so.GetId());
                odb.Close();
                odb = Open(baseName);
                odb.TriggerManagerFor <SimpleObject>().AddUpdateTrigger(myTrigger);
                var so2 = (SimpleObject)odb.GetObjectFromId(oid);
                AssertEquals(5, so2.GetId());
                odb.Store(so2);
                odb.Close();
                AssertEquals(6, so2.GetId());
                odb = Open(baseName);
                so2 = (SimpleObject)odb.GetObjectFromId(oid);
                AssertEquals(6, so2.GetId());
            }
            finally
            {
                if (odb != null && !odb.IsClosed())
                {
                    odb.Close();
                }
            }
            DeleteBase(baseName);
        }