/// <exception cref="System.Exception"></exception>
        private void AssertNoAccidentalDeletes(bool cascadeOnUpdate, bool cascadeOnDelete
                                               )
        {
            DeleteAll(typeof(CascadeOnDeleteTestCase.Holder));
            DeleteAll(typeof(CascadeOnDeleteTestCase.Item));
            IObjectClass oc = Fixture().Config().ObjectClass(typeof(CascadeOnDeleteTestCase.Holder
                                                                    ));

            oc.CascadeOnDelete(cascadeOnDelete);
            oc.CascadeOnUpdate(cascadeOnUpdate);
            Reopen();
            CascadeOnDeleteTestCase.Item   item   = new CascadeOnDeleteTestCase.Item();
            CascadeOnDeleteTestCase.Holder holder = new CascadeOnDeleteTestCase.Holder();
            holder.items = new CascadeOnDeleteTestCase.Item[] { item };
            Db().Store(holder);
            Db().Commit();
            holder.items[0].item = "abrakadabra";
            Db().Store(holder);
            if (!cascadeOnDelete && !cascadeOnUpdate)
            {
                // the only case, where we don't cascade
                Db().Store(holder.items[0]);
            }
            Assert.AreEqual(1, CountOccurences(typeof(CascadeOnDeleteTestCase.Item)));
            Db().Commit();
            Assert.AreEqual(1, CountOccurences(typeof(CascadeOnDeleteTestCase.Item)));
        }
Esempio n. 2
0
		/// <exception cref="System.Exception"></exception>
		private void AssertNoAccidentalDeletes(bool cascadeOnUpdate, bool cascadeOnDelete
			)
		{
			DeleteAll(typeof(CascadeOnDeleteTestCase.Holder));
			DeleteAll(typeof(CascadeOnDeleteTestCase.Item));
			IObjectClass oc = Fixture().Config().ObjectClass(typeof(CascadeOnDeleteTestCase.Holder
				));
			oc.CascadeOnDelete(cascadeOnDelete);
			oc.CascadeOnUpdate(cascadeOnUpdate);
			Reopen();
			CascadeOnDeleteTestCase.Item item = new CascadeOnDeleteTestCase.Item();
			CascadeOnDeleteTestCase.Holder holder = new CascadeOnDeleteTestCase.Holder();
			holder.items = new CascadeOnDeleteTestCase.Item[] { item };
			Db().Store(holder);
			Db().Commit();
			holder.items[0].item = "abrakadabra";
			Db().Store(holder);
			if (!cascadeOnDelete && !cascadeOnUpdate)
			{
				// the only case, where we don't cascade
				Db().Store(holder.items[0]);
			}
			Assert.AreEqual(1, CountOccurences(typeof(CascadeOnDeleteTestCase.Item)));
			Db().Commit();
			Assert.AreEqual(1, CountOccurences(typeof(CascadeOnDeleteTestCase.Item)));
		}