Exemplo n.º 1
0
 public virtual void TestDeleteReaddFromOtherClient()
 {
     if (!PrepareTest())
     {
         return;
     }
     DeleteReaddChildReferenceTestSuite.DeleteReaddChildReferenceTestUnit.ItemParent parent1
         = ((DeleteReaddChildReferenceTestSuite.DeleteReaddChildReferenceTestUnit.ItemParent
             )RetrieveOnlyInstance(client1, typeof(DeleteReaddChildReferenceTestSuite.DeleteReaddChildReferenceTestUnit.ItemParent
                                                   )));
     DeleteReaddChildReferenceTestSuite.DeleteReaddChildReferenceTestUnit.ItemParent parent2
         = ((DeleteReaddChildReferenceTestSuite.DeleteReaddChildReferenceTestUnit.ItemParent
             )RetrieveOnlyInstance(client2, typeof(DeleteReaddChildReferenceTestSuite.DeleteReaddChildReferenceTestUnit.ItemParent
                                                   )));
     client1.Delete(parent1.child);
     AssertQueries(0, 1);
     client1.Commit();
     AssertQueries(0, 0);
     client2.Store(parent2.child);
     AssertQueries(0, 1);
     client2.Commit();
     AssertQueries(1, 1);
     client2.Close();
     AssertRestoredState();
 }
        private void TTwoRef(IExtObjectContainer oc, string name)
        {
            bool   commit = name.IndexOf("commit") > 1;
            bool   delete = name.IndexOf("delete") > 1;
            IQuery q      = oc.Query();

            q.Constrain(typeof(CascadeDeleteDeletedTestCase.Item));
            q.Descend("name").Constrain(name);
            IObjectSet objectSet = q.Execute();

            CascadeDeleteDeletedTestCase.Item item1 = (CascadeDeleteDeletedTestCase.Item)objectSet
                                                      .Next();
            CascadeDeleteDeletedTestCase.Item item2 = (CascadeDeleteDeletedTestCase.Item)objectSet
                                                      .Next();
            if (delete)
            {
                oc.Delete(item1.untypedMember);
                oc.Delete(item1.typedMember);
            }
            oc.Delete(item1);
            if (commit)
            {
                oc.Commit();
            }
            oc.Delete(item2);
            if (!commit)
            {
                oc.Commit();
            }
        }
Exemplo n.º 3
0
        private void TTwoRef(IExtObjectContainer oc, string name)
        {
            var commit = name.IndexOf("commit") > 1;
            var delete = name.IndexOf("delete") > 1;
            var q      = oc.Query();

            q.Constrain(typeof(Item));
            q.Descend("name").Constrain(name);
            var objectSet = q.Execute();
            var item1     = (Item)objectSet
                            .Next();
            var item2 = (Item)objectSet
                        .Next();

            if (delete)
            {
                oc.Delete(item1.untypedMember);
                oc.Delete(item1.typedMember);
            }
            oc.Delete(item1);
            if (commit)
            {
                oc.Commit();
            }
            oc.Delete(item2);
            if (!commit)
            {
                oc.Commit();
            }
        }
Exemplo n.º 4
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Conc(IExtObjectContainer oc)
		{
			IObjectSet os = oc.Query(typeof(InvalidUUIDTestCase));
			if (os.Count == 0)
			{
				// already deleted by other threads
				return;
			}
			Assert.AreEqual(1, os.Count);
			InvalidUUIDTestCase iu = (InvalidUUIDTestCase)os.Next();
			Db4oUUID myUuid = oc.GetObjectInfo(iu).GetUUID();
			Assert.IsNotNull(myUuid);
			byte[] mySignature = myUuid.GetSignaturePart();
			long myLong = myUuid.GetLongPart();
			long unknownLong = long.MaxValue - 100;
			byte[] unknownSignature = new byte[] { 1, 2, 4, 99, 33, 22 };
			Db4oUUID unknownLongPart = new Db4oUUID(unknownLong, mySignature);
			Db4oUUID unknownSignaturePart = new Db4oUUID(myLong, unknownSignature);
			Db4oUUID unknownBoth = new Db4oUUID(unknownLong, unknownSignature);
			Assert.IsNull(oc.GetByUUID(unknownLongPart));
			Assert.IsNull(oc.GetByUUID(unknownSignaturePart));
			Assert.IsNull(oc.GetByUUID(unknownBoth));
			Assert.IsNull(oc.GetByUUID(unknownLongPart));
			Thread.Sleep(500);
			oc.Delete(iu);
			oc.Commit();
			Assert.IsNull(oc.GetByUUID(myUuid));
		}
Exemplo n.º 5
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Conc(IExtObjectContainer oc)
        {
            var os = oc.Query(typeof(InvalidUUIDTestCase));

            if (os.Count == 0)
            {
                // already deleted by other threads
                return;
            }
            Assert.AreEqual(1, os.Count);
            var iu     = (InvalidUUIDTestCase)os.Next();
            var myUuid = oc.GetObjectInfo(iu).GetUUID();

            Assert.IsNotNull(myUuid);
            var mySignature = myUuid.GetSignaturePart();
            var myLong      = myUuid.GetLongPart();
            var unknownLong = long.MaxValue - 100;

            byte[] unknownSignature     = { 1, 2, 4, 99, 33, 22 };
            var    unknownLongPart      = new Db4oUUID(unknownLong, mySignature);
            var    unknownSignaturePart = new Db4oUUID(myLong, unknownSignature);
            var    unknownBoth          = new Db4oUUID(unknownLong, unknownSignature);

            Assert.IsNull(oc.GetByUUID(unknownLongPart));
            Assert.IsNull(oc.GetByUUID(unknownSignaturePart));
            Assert.IsNull(oc.GetByUUID(unknownBoth));
            Assert.IsNull(oc.GetByUUID(unknownLongPart));
            Thread.Sleep(500);
            oc.Delete(iu);
            oc.Commit();
            Assert.IsNull(oc.GetByUUID(myUuid));
        }
        public virtual void TestDelete()
        {
            IExtObjectContainer oc = Fixture().Db();

            InitGenericObjects();
            IReflectClass rc = GetReflectClass(oc, PersonClassname);

            Assert.IsNotNull(rc);
            IQuery q = oc.Query();

            q.Constrain(rc);
            IObjectSet results = q.Execute();

            while (results.HasNext())
            {
                object o = results.Next();
                oc.Delete(o);
            }
            oc.Commit();
            // now query to make sure there are none left
            q = oc.Query();
            q.Constrain(rc);
            q.Descend("surname").Constrain("John");
            results = q.Execute();
            Assert.IsTrue(results.Count == 0);
        }
Exemplo n.º 7
0
		public virtual void Conc(IExtObjectContainer oc)
		{
			IsStoredTestCase isStored = new IsStoredTestCase();
			isStored.myString = "isStored";
			oc.Store(isStored);
			Assert.IsTrue(oc.IsStored(isStored));
			oc.Commit();
			oc.Delete(isStored);
			Assert.IsFalse(oc.IsStored(isStored));
			oc.Rollback();
			Assert.IsTrue(oc.IsStored(isStored));
			oc.Delete(isStored);
			Assert.IsFalse(oc.IsStored(isStored));
			oc.Commit();
			Assert.IsFalse(oc.IsStored(isStored));
		}
Exemplo n.º 8
0
 public virtual void TestDelete()
 {
     EmbeddedClientObjectContainerTestCase.Item item = StoreItemToClient1AndCommit();
     Assert.IsTrue(_client1.IsStored(item));
     _client1.Delete(item);
     Assert.IsFalse(_client1.IsStored(item));
 }
Exemplo n.º 9
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Conc(IExtObjectContainer oc)
        {
            var q = oc.Query();

            q.Constrain(typeof(MultiDeleteTestCase));
            q.Descend("name").Constrain("killmefirst");
            var objectSet = q.Execute();

            if (objectSet.Count == 0)
            {
                // already deleted by other threads
                return;
            }
            Assert.AreEqual(1, objectSet.Count);
            Thread.Sleep(1000);
            if (!objectSet.HasNext())
            {
                return;
            }
            var md = (MultiDeleteTestCase)objectSet.Next();

            oc.Delete(md);
            oc.Commit();
            AssertOccurrences(oc, typeof(MultiDeleteTestCase), 0);
        }
        public virtual void TestSD()
        {
            IExtObjectContainer oc1 = OpenNewSession();
            IExtObjectContainer oc2 = OpenNewSession();
            IExtObjectContainer oc3 = OpenNewSession();

            try
            {
                SimpleObject o1 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc1, typeof(SimpleObject
                                                                                                )));
                oc1.Delete(o1);
                SimpleObject o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject
                                                                                                )));
                Assert.AreEqual("hello", o2.GetS());
                o2.SetS("o2");
                oc2.Store(o2);
                oc2.Commit();
                oc1.Commit();
                AssertOccurrences(oc1, typeof(SimpleObject), 0);
                AssertOccurrences(oc2, typeof(SimpleObject), 0);
                AssertOccurrences(oc3, typeof(SimpleObject), 0);
            }
            finally
            {
                oc1.Close();
                oc2.Close();
                oc3.Close();
            }
        }
Exemplo n.º 11
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Conc(IExtObjectContainer oc)
        {
            IQuery q = oc.Query();

            q.Constrain(typeof(DeleteDeepTestCase));
            q.Descend("name").Constrain("root");
            IObjectSet os = q.Execute();

            if (os.Count == 0)
            {
                // already deleted
                return;
            }
            Assert.AreEqual(1, os.Count);
            if (!os.HasNext())
            {
                return;
            }
            DeleteDeepTestCase root = (DeleteDeepTestCase)os.Next();

            // wait for other threads
            // Thread.sleep(500);
            oc.Delete(root);
            oc.Commit();
            AssertOccurrences(oc, typeof(DeleteDeepTestCase), 0);
        }
Exemplo n.º 12
0
        public virtual void Conc(IExtObjectContainer oc)
        {
            IsStoredTestCase isStored = new IsStoredTestCase();

            isStored.myString = "isStored";
            oc.Store(isStored);
            Assert.IsTrue(oc.IsStored(isStored));
            oc.Commit();
            oc.Delete(isStored);
            Assert.IsFalse(oc.IsStored(isStored));
            oc.Rollback();
            Assert.IsTrue(oc.IsStored(isStored));
            oc.Delete(isStored);
            Assert.IsFalse(oc.IsStored(isStored));
            oc.Commit();
            Assert.IsFalse(oc.IsStored(isStored));
        }
 protected override void AssertObjectDeletion(IExtObjectContainer objectContainer)
 {
     DeletionUponFormatMigrationTestCase.Item item = ItemById(objectContainer, IdToBeDeleted
                                                              );
     Assert.IsNotNull(item._child);
     Assert.IsNotNull(item._array[0]);
     objectContainer.Delete(item);
 }
        protected override void AssertObjectDeletion(IExtObjectContainer objectContainer)
        {
            var item = ItemById(objectContainer, IdToBeDeleted
                                );

            Assert.IsNotNull(item._child);
            Assert.IsNotNull(item._array[0]);
            objectContainer.Delete(item);
        }
		protected override void AssertObjectsAreReadable(IExtObjectContainer objectContainer
			)
		{
			CascadedDeleteFileFormatUpdateTestCase.ParentItem parentItem = (CascadedDeleteFileFormatUpdateTestCase.ParentItem
				)RetrieveInstance(objectContainer, typeof(CascadedDeleteFileFormatUpdateTestCase.ParentItem
				));
			Assert.IsNotNull(parentItem._children);
			Assert.IsNotNull(parentItem._children[0]);
			Assert.IsNotNull(parentItem._children[1]);
			objectContainer.Delete(parentItem);
			Assert.IsFalse(_failed);
			objectContainer.Store(CascadedDeleteFileFormatUpdateTestCase.ParentItem.NewTestInstance
				());
		}
Exemplo n.º 16
0
        private void TMembersFirst(IExtObjectContainer oc, string name)
        {
            bool   commit = name.IndexOf("commit") > 1;
            IQuery q      = oc.Query();

            q.Constrain(typeof(CascadeDeleteDeletedTestCase.Item));
            q.Descend("name").Constrain(name);
            IObjectSet objectSet = q.Execute();

            CascadeDeleteDeletedTestCase.Item cdd = (CascadeDeleteDeletedTestCase.Item)objectSet
                                                    .Next();
            oc.Delete(cdd.untypedMember);
            oc.Delete(cdd.typedMember);
            if (commit)
            {
                oc.Commit();
            }
            oc.Delete(cdd);
            if (!commit)
            {
                oc.Commit();
            }
        }
 protected override void AssertObjectsAreReadable(IExtObjectContainer objectContainer
     )
 {
     var parentItem = (ParentItem
         ) RetrieveInstance(objectContainer, typeof (ParentItem
             ));
     Assert.IsNotNull(parentItem._children);
     Assert.IsNotNull(parentItem._children[0]);
     Assert.IsNotNull(parentItem._children[1]);
     objectContainer.Delete(parentItem);
     Assert.IsFalse(_failed);
     objectContainer.Store(ParentItem.NewTestInstance
         ());
 }
Exemplo n.º 18
0
        private void TMembersFirst(IExtObjectContainer oc, string name)
        {
            var commit = name.IndexOf("commit") > 1;
            var q      = oc.Query();

            q.Constrain(typeof(Item));
            q.Descend("name").Constrain(name);
            var objectSet = q.Execute();
            var cdd       = (Item)objectSet
                            .Next();

            oc.Delete(cdd.untypedMember);
            oc.Delete(cdd.typedMember);
            if (commit)
            {
                oc.Commit();
            }
            oc.Delete(cdd);
            if (!commit)
            {
                oc.Commit();
            }
        }
 protected override void AssertObjectsAreReadable(IExtObjectContainer objectContainer
                                                  )
 {
     CascadedDeleteFileFormatUpdateTestCase.ParentItem parentItem = (CascadedDeleteFileFormatUpdateTestCase.ParentItem
                                                                     )RetrieveInstance(objectContainer, typeof(CascadedDeleteFileFormatUpdateTestCase.ParentItem
                                                                                                               ));
     Assert.IsNotNull(parentItem._children);
     Assert.IsNotNull(parentItem._children[0]);
     Assert.IsNotNull(parentItem._children[1]);
     objectContainer.Delete(parentItem);
     Assert.IsFalse(_failed);
     objectContainer.Store(CascadedDeleteFileFormatUpdateTestCase.ParentItem.NewTestInstance
                               ());
 }
Exemplo n.º 20
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestDeleteAll()
        {
            IExtObjectContainer oc = Fixture().Db();
            IObjectSet          os = oc.QueryByExample(null);

            while (os.HasNext())
            {
                oc.Delete(os.Next());
            }
            Db().Commit();
            Fixture().Reopen(this);
            oc = Fixture().Db();
            os = oc.QueryByExample(null);
            Assert.AreEqual(0, os.Count);
        }
Exemplo n.º 21
0
        public virtual void TestDRDC()
        {
            IExtObjectContainer oc1 = OpenNewSession();
            IExtObjectContainer oc2 = OpenNewSession();
            IExtObjectContainer oc3 = OpenNewSession();

            try
            {
                SimpleObject o1 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc1, typeof(SimpleObject
                                                                                                )));
                oc1.Delete(o1);
                SimpleObject o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject
                                                                                                )));
                Assert.AreEqual("hello", o2.GetS());
                oc1.Rollback();
                o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject))
                                    );
                oc2.Refresh(o2, int.MaxValue);
                Assert.AreEqual("hello", o2.GetS());
                oc1.Commit();
                o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject))
                                    );
                oc2.Refresh(o2, int.MaxValue);
                Assert.AreEqual("hello", o2.GetS());
                oc1.Delete(o1);
                oc1.Commit();
                AssertOccurrences(oc3, typeof(SimpleObject), 0);
                AssertOccurrences(oc2, typeof(SimpleObject), 0);
            }
            finally
            {
                oc1.Close();
                oc2.Close();
                oc3.Close();
            }
        }
Exemplo n.º 22
0
        protected override void AssertObjectsAreReadable(IExtObjectContainer objectContainer
                                                         )
        {
            var parentItem = (ParentItem
                              )RetrieveInstance(objectContainer, typeof(ParentItem
                                                                        ));

            Assert.IsNotNull(parentItem._children);
            Assert.IsNotNull(parentItem._children[0]);
            Assert.IsNotNull(parentItem._children[1]);
            objectContainer.Delete(parentItem);
            Assert.IsFalse(_failed);
            objectContainer.Store(ParentItem.NewTestInstance
                                      ());
        }
Exemplo n.º 23
0
        /// <exception cref="System.Exception"></exception>
        public virtual void ConcDelete(IExtObjectContainer oc, int seq)
        {
            IObjectSet os = oc.Query(typeof(CascadeToVectorTestCase));

            if (os.Count == 0)
            {
                // already deleted
                return;
            }
            Assert.AreEqual(1, os.Count);
            CascadeToVectorTestCase ctv = (CascadeToVectorTestCase)os.Next();

            // wait for other threads
            Thread.Sleep(500);
            oc.Delete(ctv);
        }
        public virtual void TestDeleteReadd()
        {
            IExtObjectContainer client1 = Db();
            IExtObjectContainer client2 = OpenNewSession();

            CsCascadedDeleteReaddChildReferenceTestCase.ItemParent parent1 = ((CsCascadedDeleteReaddChildReferenceTestCase.ItemParent
                                                                               )RetrieveOnlyInstance(client1, typeof(CsCascadedDeleteReaddChildReferenceTestCase.ItemParent
                                                                                                                     )));
            CsCascadedDeleteReaddChildReferenceTestCase.ItemParent parent2 = ((CsCascadedDeleteReaddChildReferenceTestCase.ItemParent
                                                                               )RetrieveOnlyInstance(client2, typeof(CsCascadedDeleteReaddChildReferenceTestCase.ItemParent
                                                                                                                     )));
            client1.Delete(parent1);
            client1.Commit();
            client2.Ext().Store(parent2, int.MaxValue);
            client2.Commit();
            client2.Close();
            AssertInstanceCountAndFieldIndexes(client1);
        }
Exemplo n.º 25
0
        public virtual void Conc(IExtObjectContainer oc)
        {
            var em = new ExtMethodsTestCase();

            oc.Store(em);
            Assert.IsFalse(oc.IsClosed());
            Assert.IsTrue(oc.IsActive(em));
            Assert.IsTrue(oc.IsStored(em));
            oc.Deactivate(em, 1);
            Assert.IsTrue(!oc.IsActive(em));
            oc.Activate(em, 1);
            Assert.IsTrue(oc.IsActive(em));
            var id = oc.GetID(em);

            Assert.IsTrue(oc.IsCached(id));
            oc.Purge(em);
            Assert.IsFalse(oc.IsCached(id));
            Assert.IsFalse(oc.IsStored(em));
            Assert.IsFalse(oc.IsActive(em));
            oc.Bind(em, id);
            Assert.IsTrue(oc.IsCached(id));
            Assert.IsTrue(oc.IsStored(em));
            Assert.IsTrue(oc.IsActive(em));
            var em2 = (ExtMethodsTestCase)oc.GetByID(id);

            Assert.AreSame(em, em2);
            // Purge all and try again
            oc.Purge();
            Assert.IsTrue(oc.IsCached(id));
            Assert.IsTrue(oc.IsStored(em));
            Assert.IsTrue(oc.IsActive(em));
            em2 = (ExtMethodsTestCase)oc.GetByID(id);
            Assert.AreSame(em, em2);
            oc.Delete(em2);
            oc.Commit();
            Assert.IsFalse(oc.IsCached(id));
            Assert.IsFalse(oc.IsStored(em2));
            Assert.IsFalse(oc.IsActive(em2));
            // Null checks
            Assert.IsFalse(oc.IsStored(null));
            Assert.IsFalse(oc.IsActive(null));
            Assert.IsFalse(oc.IsCached(0));
        }
        protected override void AssertObjectsAreReadable(IExtObjectContainer objectContainer
                                                         )
        {
            var objectSet = objectContainer.Query(typeof(StClass
                                                         ));

            for (var i = 0; i < 2; i++)
            {
                var cls = (StClass
                           )objectSet.Next();
                var v        = cls.GetVect();
                var intArray = (int[][])v[0];
                ArrayAssert.AreEqual(IntArrayData[0], intArray[0]);
                ArrayAssert.AreEqual(IntArrayData[1], intArray[1]);
                var stringArray = (string[][])v[1];
                ArrayAssert.AreEqual(StringArrayData[0], stringArray[0]);
                ArrayAssert.AreEqual(StringArrayData[1], stringArray[1]);
                objectContainer.Delete(cls);
            }
        }
        protected override void AssertObjectsAreReadable(IExtObjectContainer objectContainer
                                                         )
        {
            IObjectSet objectSet = objectContainer.Query(typeof(FreespaceManagerMigrationTestCase.StClass
                                                                ));

            for (int i = 0; i < 2; i++)
            {
                FreespaceManagerMigrationTestCase.StClass cls = (FreespaceManagerMigrationTestCase.StClass
                                                                 )objectSet.Next();
                ArrayList v        = cls.GetVect();
                int[][]   intArray = (int[][])v[0];
                ArrayAssert.AreEqual(IntArrayData[0], intArray[0]);
                ArrayAssert.AreEqual(IntArrayData[1], intArray[1]);
                string[][] stringArray = (string[][])v[1];
                ArrayAssert.AreEqual(StringArrayData[0], stringArray[0]);
                ArrayAssert.AreEqual(StringArrayData[1], stringArray[1]);
                objectContainer.Delete(cls);
            }
        }
Exemplo n.º 28
0
		public virtual void Conc(IExtObjectContainer oc)
		{
			ExtMethodsTestCase em = new ExtMethodsTestCase();
			oc.Store(em);
			Assert.IsFalse(oc.IsClosed());
			Assert.IsTrue(oc.IsActive(em));
			Assert.IsTrue(oc.IsStored(em));
			oc.Deactivate(em, 1);
			Assert.IsTrue(!oc.IsActive(em));
			oc.Activate(em, 1);
			Assert.IsTrue(oc.IsActive(em));
			long id = oc.GetID(em);
			Assert.IsTrue(oc.IsCached(id));
			oc.Purge(em);
			Assert.IsFalse(oc.IsCached(id));
			Assert.IsFalse(oc.IsStored(em));
			Assert.IsFalse(oc.IsActive(em));
			oc.Bind(em, id);
			Assert.IsTrue(oc.IsCached(id));
			Assert.IsTrue(oc.IsStored(em));
			Assert.IsTrue(oc.IsActive(em));
			ExtMethodsTestCase em2 = (ExtMethodsTestCase)oc.GetByID(id);
			Assert.AreSame(em, em2);
			// Purge all and try again
			oc.Purge();
			Assert.IsTrue(oc.IsCached(id));
			Assert.IsTrue(oc.IsStored(em));
			Assert.IsTrue(oc.IsActive(em));
			em2 = (ExtMethodsTestCase)oc.GetByID(id);
			Assert.AreSame(em, em2);
			oc.Delete(em2);
			oc.Commit();
			Assert.IsFalse(oc.IsCached(id));
			Assert.IsFalse(oc.IsStored(em2));
			Assert.IsFalse(oc.IsActive(em2));
			// Null checks
			Assert.IsFalse(oc.IsStored(null));
			Assert.IsFalse(oc.IsActive(null));
			Assert.IsFalse(oc.IsCached(0));
		}
Exemplo n.º 29
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Conc(IExtObjectContainer oc)
		{
			IQuery q = oc.Query();
			q.Constrain(typeof(MultiDeleteTestCase));
			q.Descend("name").Constrain("killmefirst");
			IObjectSet objectSet = q.Execute();
			if (objectSet.Count == 0)
			{
				// already deleted by other threads
				return;
			}
			Assert.AreEqual(1, objectSet.Count);
			Thread.Sleep(1000);
			if (!objectSet.HasNext())
			{
				return;
			}
			MultiDeleteTestCase md = (MultiDeleteTestCase)objectSet.Next();
			oc.Delete(md);
			oc.Commit();
			AssertOccurrences(oc, typeof(MultiDeleteTestCase), 0);
		}
Exemplo n.º 30
0
 /// <exception cref="System.Exception"></exception>
 public virtual void ConcDelete(IExtObjectContainer oc)
 {
     var os = oc.Query(typeof (Item));
     if (os.Count == 0)
     {
         // the object has been deleted
         return;
     }
     if (!os.HasNext())
     {
         // object can be deleted after query 
         return;
     }
     var cdf = (Item) os.Next();
     // sleep 1000 ms, waiting for other threads.
     // Thread.sleep(500);
     oc.Delete(cdf);
     oc.Commit();
     AssertOccurrences(oc, typeof (Item), 0);
     AssertOccurrences(oc, typeof (CascadeDeleteFalseHelper)
         , 1);
 }
        public virtual void _testDS()
        {
            IExtObjectContainer oc1 = OpenNewSession();
            IExtObjectContainer oc2 = OpenNewSession();
            IExtObjectContainer oc3 = OpenNewSession();

            try
            {
                SimpleObject o1 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc1, typeof(SimpleObject
                                                                                                )));
                oc1.Delete(o1);
                SimpleObject o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject
                                                                                                )));
                Assert.AreEqual("hello", o2.GetS());
                o2.SetS("o2");
                oc2.Store(o2);
                oc1.Commit();
                oc2.Commit();
                o1 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc1, typeof(SimpleObject))
                                    );
                oc1.Refresh(o1, int.MaxValue);
                Assert.AreEqual("o2", o1.GetS());
                o2 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc2, typeof(SimpleObject))
                                    );
                oc2.Refresh(o2, int.MaxValue);
                Assert.AreEqual("o2", o2.GetS());
                SimpleObject o3 = (SimpleObject)((SimpleObject)RetrieveOnlyInstance(oc3, typeof(SimpleObject
                                                                                                )));
                oc1.Refresh(o1, int.MaxValue);
                Assert.AreEqual("o2", o3.GetS());
            }
            finally
            {
                oc1.Close();
                oc2.Close();
                oc3.Close();
            }
        }
Exemplo n.º 32
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Conc(IExtObjectContainer oc)
		{
			IQuery q = oc.Query();
			q.Constrain(typeof(DeleteDeepTestCase));
			q.Descend("name").Constrain("root");
			IObjectSet os = q.Execute();
			if (os.Count == 0)
			{
				// already deleted
				return;
			}
			Assert.AreEqual(1, os.Count);
			if (!os.HasNext())
			{
				return;
			}
			DeleteDeepTestCase root = (DeleteDeepTestCase)os.Next();
			// wait for other threads
			// Thread.sleep(500);
			oc.Delete(root);
			oc.Commit();
			AssertOccurrences(oc, typeof(DeleteDeepTestCase), 0);
		}
Exemplo n.º 33
0
        /// <exception cref="System.Exception"></exception>
        public virtual void ConcDelete(IExtObjectContainer oc)
        {
            IObjectSet os = oc.Query(typeof(CascadeDeleteFalseTestCase.Item));

            if (os.Count == 0)
            {
                // the object has been deleted
                return;
            }
            if (!os.HasNext())
            {
                // object can be deleted after query
                return;
            }
            CascadeDeleteFalseTestCase.Item cdf = (CascadeDeleteFalseTestCase.Item)os.Next();
            // sleep 1000 ms, waiting for other threads.
            // Thread.sleep(500);
            oc.Delete(cdf);
            oc.Commit();
            AssertOccurrences(oc, typeof(CascadeDeleteFalseTestCase.Item), 0);
            AssertOccurrences(oc, typeof(CascadeDeleteFalseTestCase.CascadeDeleteFalseHelper)
                              , 1);
        }
        public virtual void TestDeleteReadd()
        {
            IExtObjectContainer client1 = Db();
            IExtObjectContainer client2 = OpenNewSession();

            CsDeleteReaddTestCase.Item item1 = (CsDeleteReaddTestCase.Item)((CsDeleteReaddTestCase.Item
                                                                             )RetrieveOnlyInstance(client1, typeof(CsDeleteReaddTestCase.Item)));
            CsDeleteReaddTestCase.Item item2 = (CsDeleteReaddTestCase.Item)((CsDeleteReaddTestCase.Item
                                                                             )RetrieveOnlyInstance(client2, typeof(CsDeleteReaddTestCase.Item)));
            long idBeforeDelete = client1.GetID(item1);

            client1.Delete(item1);
            client1.Commit();
            client2.Store(item2);
            client2.Commit();
            client2.Close();
            CsDeleteReaddTestCase.Item item3 = ((CsDeleteReaddTestCase.Item)RetrieveOnlyInstance
                                                    (client1, typeof(CsDeleteReaddTestCase.Item)));
            long idAfterUpdate = client1.GetID(item3);

            Assert.AreEqual(idBeforeDelete, idAfterUpdate);
            new FieldIndexAssert(typeof(CsDeleteReaddTestCase.Item), "name").AssertSingleEntry
                (FileSession(), idAfterUpdate);
        }
Exemplo n.º 35
0
		/// <exception cref="System.Exception"></exception>
		public virtual void ConcDelete(IExtObjectContainer oc, int seq)
		{
			IObjectSet os = oc.Query(typeof(CascadeToVectorTestCase));
			if (os.Count == 0)
			{
				// already deleted
				return;
			}
			Assert.AreEqual(1, os.Count);
			CascadeToVectorTestCase ctv = (CascadeToVectorTestCase)os.Next();
			// wait for other threads
			Thread.Sleep(500);
			oc.Delete(ctv);
		}
Exemplo n.º 36
0
 public virtual void Delete(object obj)
 {
     db.Delete(obj);
 }
Exemplo n.º 37
0
 private void TTwoRef(IExtObjectContainer oc, string name)
 {
     var commit = name.IndexOf("commit") > 1;
     var delete = name.IndexOf("delete") > 1;
     var q = oc.Query();
     q.Constrain(typeof (Item));
     q.Descend("name").Constrain(name);
     var objectSet = q.Execute();
     var item1 = (Item) objectSet
         .Next();
     var item2 = (Item) objectSet
         .Next();
     if (delete)
     {
         oc.Delete(item1.untypedMember);
         oc.Delete(item1.typedMember);
     }
     oc.Delete(item1);
     if (commit)
     {
         oc.Commit();
     }
     oc.Delete(item2);
     if (!commit)
     {
         oc.Commit();
     }
 }
		private void TTwoRef(IExtObjectContainer oc, string name)
		{
			bool commit = name.IndexOf("commit") > 1;
			bool delete = name.IndexOf("delete") > 1;
			IQuery q = oc.Query();
			q.Constrain(typeof(CascadeDeleteDeletedTestCase.Item));
			q.Descend("name").Constrain(name);
			IObjectSet objectSet = q.Execute();
			CascadeDeleteDeletedTestCase.Item item1 = (CascadeDeleteDeletedTestCase.Item)objectSet
				.Next();
			CascadeDeleteDeletedTestCase.Item item2 = (CascadeDeleteDeletedTestCase.Item)objectSet
				.Next();
			if (delete)
			{
				oc.Delete(item1.untypedMember);
				oc.Delete(item1.typedMember);
			}
			oc.Delete(item1);
			if (commit)
			{
				oc.Commit();
			}
			oc.Delete(item2);
			if (!commit)
			{
				oc.Commit();
			}
		}
Exemplo n.º 39
0
 private void TMembersFirst(IExtObjectContainer oc, string name)
 {
     var commit = name.IndexOf("commit") > 1;
     var q = oc.Query();
     q.Constrain(typeof (Item));
     q.Descend("name").Constrain(name);
     var objectSet = q.Execute();
     var cdd = (Item) objectSet
         .Next();
     oc.Delete(cdd.untypedMember);
     oc.Delete(cdd.typedMember);
     if (commit)
     {
         oc.Commit();
     }
     oc.Delete(cdd);
     if (!commit)
     {
         oc.Commit();
     }
 }
 protected override void AssertObjectsAreReadable(IExtObjectContainer objectContainer
     )
 {
     var objectSet = objectContainer.Query(typeof (StClass
         ));
     for (var i = 0; i < 2; i++)
     {
         var cls = (StClass
             ) objectSet.Next();
         var v = cls.GetVect();
         var intArray = (int[][]) v[0];
         ArrayAssert.AreEqual(IntArrayData[0], intArray[0]);
         ArrayAssert.AreEqual(IntArrayData[1], intArray[1]);
         var stringArray = (string[][]) v[1];
         ArrayAssert.AreEqual(StringArrayData[0], stringArray[0]);
         ArrayAssert.AreEqual(StringArrayData[1], stringArray[1]);
         objectContainer.Delete(cls);
     }
 }
		protected override void AssertObjectsAreReadable(IExtObjectContainer objectContainer
			)
		{
			IObjectSet objectSet = objectContainer.Query(typeof(FreespaceManagerMigrationTestCase.StClass
				));
			for (int i = 0; i < 2; i++)
			{
				FreespaceManagerMigrationTestCase.StClass cls = (FreespaceManagerMigrationTestCase.StClass
					)objectSet.Next();
				ArrayList v = cls.GetVect();
				int[][] intArray = (int[][])v[0];
				ArrayAssert.AreEqual(IntArrayData[0], intArray[0]);
				ArrayAssert.AreEqual(IntArrayData[1], intArray[1]);
				string[][] stringArray = (string[][])v[1];
				ArrayAssert.AreEqual(StringArrayData[0], stringArray[0]);
				ArrayAssert.AreEqual(StringArrayData[1], stringArray[1]);
				objectContainer.Delete(cls);
			}
		}
Exemplo n.º 42
0
 public void Visit(object obj)
 {
     oc.Delete(obj);
 }
		protected override void AssertObjectDeletion(IExtObjectContainer objectContainer)
		{
			DeletionUponFormatMigrationTestCase.Item item = ItemById(objectContainer, IdToBeDeleted
				);
			Assert.IsNotNull(item._child);
			Assert.IsNotNull(item._array[0]);
			objectContainer.Delete(item);
		}
		private void TMembersFirst(IExtObjectContainer oc, string name)
		{
			bool commit = name.IndexOf("commit") > 1;
			IQuery q = oc.Query();
			q.Constrain(typeof(CascadeDeleteDeletedTestCase.Item));
			q.Descend("name").Constrain(name);
			IObjectSet objectSet = q.Execute();
			CascadeDeleteDeletedTestCase.Item cdd = (CascadeDeleteDeletedTestCase.Item)objectSet
				.Next();
			oc.Delete(cdd.untypedMember);
			oc.Delete(cdd.typedMember);
			if (commit)
			{
				oc.Commit();
			}
			oc.Delete(cdd);
			if (!commit)
			{
				oc.Commit();
			}
		}