context: // --------------------------------------------------------------------------------------------------------------------
  // <copyright file="LifeCycleTest.cs" company="Allors bvba">
  //   Copyright 2002-2012 Allors bvba.
  // 
  // Dual Licensed under
  //   a) the Lesser General Public Licence v3 (LGPL)
  //   b) the Allors License
  // 
  // The LGPL License is included in the file lgpl.txt.
  // The Allors License is an addendum to your contract.
  // 
  // Allors Platform is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  // GNU General Public License for more details.
  // 
  // For more information visit http://www.allors.com/legal
  // </copyright>
  // --------------------------------------------------------------------------------------------------------------------
  
  namespace Allors.Adapters
  {
      using System;
      using System.Collections;
      using System.Collections.Generic;
      using System.Linq;
  
      using Allors;
      using Allors.Domain;
      using Allors.Meta;
      using Adapters;
  
      using NUnit.Framework;
  
      public abstract class LifeCycleTest
      {
          protected static readonly bool[] TrueFalse = { true, false };
  
          protected abstract IProfile Profile { get; }
  
          protected ISession Session
          {
              get
              {
                  return this.Profile.Session;
              }
          }
  
          protected Action[] Markers
          {
              get
              {
                  return this.Profile.Markers;
              }
          }
  
          protected Action[] Inits
          {
              get
              {
                  return this.Profile.Inits;
              }
          }
  
          [Test]
          public void NextId()
          {
              foreach (var init in this.Inits)
              {
                  init();
  
                  var c1 = this.Session.Create<C1>();
                  var strategy = c1.Strategy;
                  var id = long.Parse(strategy.ObjectId.ToString());
  
                  long nextId = long.Parse(this.Session.Create<C1>().Strategy.ObjectId.ToString());
  
                  Assert.AreEqual(id + 1, nextId);
              }
          }
  
          [Test]
          public void CreateMany()
          {
              foreach (var init in this.Inits)
              {
                  init();
  
                  int[] runs = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 };
  
                  var total = 0;
                  foreach (var run in runs)
                  {
                      var allorsObjects = this.Session.Create(MetaC1.Instance.ObjectType, run);
  
                      Assert.AreEqual(run, allorsObjects.Length);
  
                      total += run;
  
                      Assert.AreEqual(total, this.GetExtent(MetaC1.Instance.ObjectType).Length);
  
                      var ids = new ArrayList();
                      foreach (C1 allorsObject in allorsObjects)
                      {
                          Assert.AreEqual(MetaC1.Instance.ObjectType, allorsObject.Strategy.Class);
                          ids.Add(allorsObject.Strategy.ObjectId);
                          allorsObject.C1AllorsString = "CreateMany";
                      }
  
                      Assert.AreEqual(run, ids.Count);
  
                      this.Session.Commit();
  
                      allorsObjects = this.Session.Instantiate((long[])ids.ToArray(typeof(long)));
                      foreach (C1 allorsObject in allorsObjects)
                      {
                          Assert.AreEqual(MetaC1.Instance.ObjectType, allorsObject.Strategy.Class);
                          allorsObject.C1AllorsString = "CreateMany";
                      }
  
                      var c2s = (C2[])this.Session.Create(MetaC2.Instance.ObjectType, run);
                      Assert.AreEqual(run, c2s.Length);
                  }
              }
          }
  
          [Test]
          public void UnitRole()
          {
              foreach (var init in this.Inits)
              {
                  init();
  
                  C1 c1A = C1.Create(this.Session);
  
                  this.Session.Commit();
  
                  c1A.C1AllorsString = "1";
  
                  this.Session.Commit();
  
                  c1A.C1AllorsString = "2";
  
                  this.Session.Rollback();
  
                  Assert.AreEqual("1", c1A.C1AllorsString);
              }
          }
  
          [Test]
          public void CompositeRole()
          {
              foreach (var init in this.Inits)
              {
                  init();
  
                  C1 c1A = C1.Create(this.Session);
  
                  C2 c2A = C2.Create(this.Session);
                  C2 c2B = C2.Create(this.Session);
  
                  this.Session.Commit();
  
                  c1A.C1C2one2one = c2A;
  
                  this.Session.Commit();
  
                  c1A.C1C2one2one = c2B;
  
                  this.Session.Rollback();
  
                  Assert.AreEqual(c2A, c1A.C1C2one2one);
              }
          }
  
          [Test]
          public void CompositeRoles()
          {
              foreach (var init in this.Inits)
              {
                  init();
  
                  var c1A = C1.Create(this.Session);
  
                  var c2A = C2.Create(this.Session);
                  var c2B = C2.Create(this.Session);
  
                  this.Session.Commit();
  
                  c1A.AddC1C2one2many(c2A);
  
                  this.Session.Commit();
  
                  c1A.AddC1C2one2many(c2B);
  
                  this.Session.Rollback();
  
                  Assert.AreEqual(1, c1A.C1C2one2manies.Count);
                  Assert.AreEqual(c2A, c1A.C1C2one2manies[0]);
              }
          }
  
          [Test]
          public void Delete()
          {
              foreach (var init in this.Inits)
              {
                  init();
  
                  // Object
                  C1 anObject = C1.Create(this.Session);
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
                  anObject = (C1)this.Session.Instantiate(anObject.Strategy.ObjectId);
                  Assert.IsNull(anObject);
  
                  //// Commit & Rollback
  
                  anObject = C1.Create(this.Session);
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Commit();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Commit();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  // instantiate
                  anObject = C1.Create(this.Session);
                  var id = anObject.Strategy.ObjectId;
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Commit();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsNull(anObject);
  
                  this.Session.Commit();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsNull(anObject);
  
                  //// Commit + Commit + Commit
  
                  anObject = C1.Create(this.Session);
  
                  this.Session.Commit();
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Commit();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Commit();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  // instantiate
                  anObject = C1.Create(this.Session);
                  id = anObject.Strategy.ObjectId;
  
                  this.Session.Commit();
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Commit();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsNull(anObject);
  
                  this.Session.Commit();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsNull(anObject);
  
                  //// Nothing + Commit + Rollback
  
                  anObject = C1.Create(this.Session);
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Commit();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  // instantiate
                  anObject = C1.Create(this.Session);
                  id = anObject.Strategy.ObjectId;
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Commit();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsNull(anObject);
  
                  this.Session.Rollback();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsNull(anObject);
  
                  //// Commit + Commit + Rollback
  
                  anObject = C1.Create(this.Session);
  
                  this.Session.Commit();
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Commit();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  // instantiate
                  anObject = C1.Create(this.Session);
                  id = anObject.Strategy.ObjectId;
  
                  this.Session.Commit();
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Commit();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsNull(anObject);
  
                  this.Session.Rollback();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsNull(anObject);
  
                  //// Nothing + Rollback + Rollback
  
                  anObject = C1.Create(this.Session);
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  // instantiate
                  anObject = C1.Create(this.Session);
                  id = anObject.Strategy.ObjectId;
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsNull(anObject);
  
                  this.Session.Rollback();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsNull(anObject);
  
                  //// Commit + Rollback + Rollback
  
                  anObject = C1.Create(this.Session);
  
                  this.Session.Commit();
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  Assert.IsFalse(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  Assert.IsFalse(anObject.Strategy.IsDeleted);
  
                  // instantiate
                  anObject = C1.Create(this.Session);
                  id = anObject.Strategy.ObjectId;
  
                  this.Session.Commit();
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsFalse(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsFalse(anObject.Strategy.IsDeleted);
  
                  //// Nothing + Rollback + Commit
  
                  anObject = C1.Create(this.Session);
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Commit();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  // instantiate
                  anObject = C1.Create(this.Session);
                  id = anObject.Strategy.ObjectId;
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsNull(anObject);
  
                  this.Session.Rollback();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsNull(anObject);
  
                  //// Commit + Rollback + Commit
  
                  anObject = C1.Create(this.Session);
  
                  this.Session.Commit();
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  Assert.IsFalse(anObject.Strategy.IsDeleted);
  
                  this.Session.Commit();
                  Assert.IsFalse(anObject.Strategy.IsDeleted);
  
                  // instantiate
                  anObject = C1.Create(this.Session);
                  id = anObject.Strategy.ObjectId;
  
                  this.Session.Commit();
  
                  anObject.Strategy.Delete();
                  Assert.IsTrue(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsFalse(anObject.Strategy.IsDeleted);
  
                  this.Session.Rollback();
                  anObject = C1.Instantiate(this.Session, id);
                  Assert.IsFalse(anObject.Strategy.IsDeleted);
  
                  // Clean up
                  this.Session.Commit();
                  foreach (C1 removeObject in this.GetExtent(MetaC1.Instance.ObjectType))
                  {
                      removeObject.Strategy.Delete();
                  }
  
                  this.Session.Commit();
  
                  // Strategy
                  var databaseSession = this.Session as ISession;
                  if (databaseSession != null)
                  {
                      IStrategy aStrategy = C1.Create(this.Session).Strategy;
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
                      aStrategy = databaseSession.InstantiateStrategy(aStrategy.ObjectId);
                      Assert.IsNull(aStrategy);
  
                      //// Commit & Rollback
  
                      aStrategy = C1.Create(databaseSession).Strategy;
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Commit();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Commit();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      // instantiate
                      aStrategy = C1.Create(databaseSession).Strategy;
                      id = aStrategy.ObjectId;
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Commit();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsNull(aStrategy);
  
                      databaseSession.Commit();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsNull(aStrategy);
  
                      //// Commit + Commit + Commit
  
                      aStrategy = C1.Create(databaseSession).Strategy;
  
                      databaseSession.Commit();
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Commit();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Commit();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      // instantiate
                      aStrategy = C1.Create(databaseSession).Strategy;
                      id = aStrategy.ObjectId;
  
                      databaseSession.Commit();
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Commit();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsNull(aStrategy);
  
                      databaseSession.Commit();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsNull(aStrategy);
  
                      //// Nothing + Commit + Rollback
  
                      aStrategy = C1.Create(databaseSession).Strategy;
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Commit();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      // instantiate
                      aStrategy = C1.Create(databaseSession).Strategy;
                      id = aStrategy.ObjectId;
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Commit();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsNull(aStrategy);
  
                      databaseSession.Rollback();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsNull(aStrategy);
  
                      //// Commit + Commit + Rollback
  
                      aStrategy = C1.Create(databaseSession).Strategy;
  
                      databaseSession.Commit();
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Commit();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      // instantiate
                      aStrategy = C1.Create(databaseSession).Strategy;
                      id = aStrategy.ObjectId;
  
                      databaseSession.Commit();
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Commit();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsNull(aStrategy);
  
                      databaseSession.Rollback();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsNull(aStrategy);
  
                      //// Nothing + Rollback + Rollback
  
                      aStrategy = C1.Create(databaseSession).Strategy;
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      // instantiate
                      aStrategy = C1.Create(databaseSession).Strategy;
                      id = aStrategy.ObjectId;
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsNull(aStrategy);
  
                      databaseSession.Rollback();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsNull(aStrategy);
  
                      //// Commit + Rollback + Rollback
  
                      aStrategy = C1.Create(databaseSession).Strategy;
  
                      databaseSession.Commit();
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      Assert.IsFalse(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      Assert.IsFalse(aStrategy.IsDeleted);
  
                      // instantiate
                      aStrategy = C1.Create(databaseSession).Strategy;
                      id = aStrategy.ObjectId;
  
                      databaseSession.Commit();
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsFalse(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsFalse(aStrategy.IsDeleted);
  
                      //// Nothing + Rollback + Commit
  
                      aStrategy = C1.Create(databaseSession).Strategy;
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Commit();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      // instantiate
                      aStrategy = C1.Create(databaseSession).Strategy;
                      id = aStrategy.ObjectId;
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsNull(aStrategy);
  
                      databaseSession.Rollback();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsNull(aStrategy);
  
                      //// Commit + Rollback + Commit
  
                      aStrategy = C1.Create(databaseSession).Strategy;
  
                      databaseSession.Commit();
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      Assert.IsFalse(aStrategy.IsDeleted);
  
                      databaseSession.Commit();
                      Assert.IsFalse(aStrategy.IsDeleted);
  
                      // instantiate
                      aStrategy = C1.Create(databaseSession).Strategy;
                      id = aStrategy.ObjectId;
  
                      databaseSession.Commit();
  
                      aStrategy.Delete();
                      Assert.IsTrue(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsFalse(aStrategy.IsDeleted);
  
                      databaseSession.Rollback();
                      aStrategy = databaseSession.InstantiateStrategy(id);
                      Assert.IsFalse(aStrategy.IsDeleted);
  
                      // Clean up
                      databaseSession.Commit();
                      foreach (C1 removeObject in this.GetExtent(MetaC1.Instance.ObjectType))
                      {
                          removeObject.Strategy.Delete();
                      }
  
                      databaseSession.Commit();
                  }
  
                  //// Units
  
                  anObject = C1.Create(this.Session);
                  anObject.C1AllorsString = "a";
                  anObject.Strategy.Delete();
  
                  StrategyAssert.RoleExistHasException(anObject, MetaC1.Instance.C1AllorsString);
  
                  anObject = C1.Create(this.Session);
                  anObject.C1AllorsString = "a";
                  anObject.Strategy.Delete();
  
                  StrategyAssert.RoleGetHasException(anObject, MetaC1.Instance.C1AllorsString);
  
                  C1 secondObject = C1.Create(this.Session);
                  secondObject.C1AllorsString = "b";
                  C1 thirdObject = C1.Create(this.Session);
                  thirdObject.C1AllorsString = "c";
  
                  Assert.AreEqual(2, this.GetExtent(MetaC1.Instance.ObjectType).Length);
                  thirdObject.Strategy.Delete();
  
                  Assert.AreEqual(1, this.GetExtent(MetaC1.Instance.ObjectType).Length);
                  Assert.AreEqual("b", ((C1)this.GetExtent(MetaC1.Instance.ObjectType)[0]).C1AllorsString);
  
                  secondObject.Strategy.Delete();
  
                  //// Cached
  
                  anObject = C1.Create(this.Session);
                  anObject.C1AllorsString = "a";
  
                  AllorsTestUtils.ForceRoleCaching(anObject);
  
                  anObject.Strategy.Delete();
  
                  StrategyAssert.RoleExistHasException(anObject, MetaC1.Instance.C1AllorsString);
  
                  anObject = C1.Create(this.Session);
                  anObject.C1AllorsString = "a";
  
                  AllorsTestUtils.ForceRoleCaching(anObject);
  
                  anObject.Strategy.Delete();
  
                  StrategyAssert.RoleGetHasException(anObject, MetaC1.Instance.C1AllorsString);
  
                  secondObject = C1.Create(this.Session);
                  secondObject.C1AllorsString = "b";
                  thirdObject = C1.Create(this.Session);
                  thirdObject.C1AllorsString = "c";
  
                  Assert.AreEqual(2, this.GetExtent(MetaC1.Instance.ObjectType).Length);
  
                  AllorsTestUtils.ForceRoleCaching(secondObject);
                  AllorsTestUtils.ForceRoleCaching(thirdObject);
  
                  thirdObject.Strategy.Delete();
  
                  Assert.AreEqual(1, this.GetExtent(MetaC1.Instance.ObjectType).Length);
                  Assert.AreEqual("b", ((C1)this.GetExtent(MetaC1.Instance.ObjectType)[0]).C1AllorsString);
  
                  secondObject.Strategy.Delete();
  
                  //// Commit
  
                  anObject = C1.Create(this.Session);
                  anObject.C1AllorsString = "a";
                  anObject.Strategy.Delete();
  
                  this.Session.Commit();
  
                  StrategyAssert.RoleExistHasException(anObject, MetaC1.Instance.C1AllorsString);
  
                  anObject = C1.Create(this.Session);
                  anObject.C1AllorsString = "a";
                  anObject.Strategy.Delete();
  
                  this.Session.Commit();
  
                  StrategyAssert.RoleGetHasException(anObject, MetaC1.Instance.C1AllorsString);
  
                  secondObject = C1.Create(this.Session);
                  secondObject.C1AllorsString = "b";
                  thirdObject = C1.Create(this.Session);
                  thirdObject.C1AllorsString = "c";
  
                  Assert.AreEqual(2, this.GetExtent(MetaC1.Instance.ObjectType).Length);
                  thirdObject.Strategy.Delete();
  
                  this.Session.Commit();
  
                  Assert.AreEqual(1, this.GetExtent(MetaC1.Instance.ObjectType).Length);
                  Assert.AreEqual("b", ((C1)this.GetExtent(MetaC1.Instance.ObjectType)[0]).C1AllorsString);
  
                  secondObject.Strategy.Delete();
  
                  this.Session.Commit();
  
                  //// Cached
  
                  anObject = C1.Create(this.Session);
                  anObject.C1AllorsString = "a";
  
                  AllorsTestUtils.ForceRoleCaching(anObject);
  
                  anObject.Strategy.Delete();
                  this.Session.Commit();
  
                  StrategyAssert.RoleExistHasException(anObject, MetaC1.Instance.C1AllorsString);
  
                  anObject = C1.Create(this.Session);
                  anObject.C1AllorsString = "a";
  
                  AllorsTestUtils.ForceRoleCaching(anObject);
  
                  anObject.Strategy.Delete();
                  this.Session.Commit();
  
                  StrategyAssert.RoleGetHasException(anObject, MetaC1.Instance.C1AllorsString);
  
                  secondObject = C1.Create(this.Session);
                  secondObject.C1AllorsString = "b";
                  thirdObject = C1.Create(this.Session);
                  thirdObject.C1AllorsString = "c";
  
                  Assert.AreEqual(2, this.GetExtent(MetaC1.Instance.ObjectType).Length);
  
                  AllorsTestUtils.ForceRoleCaching(secondObject);
                  AllorsTestUtils.ForceRoleCaching(thirdObject);
  
                  thirdObject.Strategy.Delete();
                  this.Session.Commit();
  
                  Assert.AreEqual(1, this.GetExtent(MetaC1.Instance.ObjectType).Length);
                  Assert.AreEqual("b", ((C1)this.GetExtent(MetaC1.Instance.ObjectType)[0]).C1AllorsString);
  
                  secondObject.Strategy.Delete();
                  this.Session.Commit();
  
                  //// Rollback
  
                  anObject = C1.Create(this.Session);
                  anObject.C1AllorsString = "a";
                  this.Session.Commit();
  
                  anObject.Strategy.Delete();
  
                  this.Session.Rollback();
  
                  Assert.AreEqual(1, this.GetExtent(MetaC1.Instance.ObjectType).Length);
                  Assert.AreEqual("a", ((C1)this.GetExtent(MetaC1.Instance.ObjectType)[0]).C1AllorsString);
  
                  secondObject = C1.Create(this.Session);
                  secondObject.C1AllorsString = "b";
                  thirdObject = C1.Create(this.Session);
                  thirdObject.C1AllorsString = "c";
  
                  Assert.AreEqual(3, this.GetExtent(MetaC1.Instance.ObjectType).Length);
                  thirdObject.Strategy.Delete();
  
                  this.Session.Rollback();
  
                  Assert.AreEqual(1, this.GetExtent(MetaC1.Instance.ObjectType).Length);
                  Assert.AreEqual("a", ((C1)this.GetExtent(MetaC1.Instance.ObjectType)[0]).C1AllorsString);
  
                  anObject.Strategy.Delete();
  
                  this.Session.Commit();
  
                  //// Cached
  
                  anObject = C1.Create(this.Session);
                  anObject.C1AllorsString = "a";
                  this.Session.Commit();
  
                  AllorsTestUtils.ForceRoleCaching(anObject);
  
                  anObject.Strategy.Delete();
                  this.Session.Rollback();
  
                  Assert.AreEqual(1, this.GetExtent(MetaC1.Instance.ObjectType).Length);
                  Assert.AreEqual("a", ((C1)this.GetExtent(MetaC1.Instance.ObjectType)[0]).C1AllorsString);
  
                  secondObject = C1.Create(this.Session);
                  secondObject.C1AllorsString = "b";
                  thirdObject = C1.Create(this.Session);
                  thirdObject.C1AllorsString = "c";
  
                  Assert.AreEqual(3, this.GetExtent(MetaC1.Instance.ObjectType).Length);
  
                  AllorsTestUtils.ForceRoleCaching(secondObject);
                  AllorsTestUtils.ForceRoleCaching(thirdObject);
  
                  thirdObject.Strategy.Delete();
                  this.Session.Rollback();
  
                  Assert.AreEqual(1, this.GetExtent(MetaC1.Instance.ObjectType).Length);
                  Assert.AreEqual("a", ((C1)this.GetExtent(MetaC1.Instance.ObjectType)[0]).C1AllorsString);
  
                  anObject.Strategy.Delete();
                  this.Session.Commit();
  
                  //// IComposite
  
                  //// Role
  
                  C1 fromC1a = C1.Create(this.Session);
                  C1 fromC1b = C1.Create(this.Session);
                  C1 fromC1c = C1.Create(this.Session);
                  C1 fromC1d = C1.Create(this.Session);
  
                  C1 toC1a = C1.Create(this.Session);
                  C1 toC1b = C1.Create(this.Session);
                  C1 toC1c = C1.Create(this.Session);
                  C1 toC1d = C1.Create(this.Session);
  
                  C2 toC2a = C2.Create(this.Session);
                  C2 toC2b = C2.Create(this.Session);
                  C2 toC2c = C2.Create(this.Session);
                  C2 toC2d = C2.Create(this.Session);
  
                  //// C1 <-> C1
  
                  fromC1a.C1C1one2one = toC1a;
                  fromC1b.C1C1one2one = toC1c;
  
                  fromC1a.C1C1many2one = toC1a;
                  fromC1b.C1C1many2one = toC1c;
  
                  fromC1a.AddC1C1one2many(toC1a);
                  fromC1a.AddC1C1one2many(toC1b);
                  fromC1b.AddC1C1one2many(toC1c);
                  fromC1b.AddC1C1one2many(toC1d);
  
                  fromC1a.AddC1C1many2many(toC1a);
                  fromC1a.AddC1C1many2many(toC1b);
                  fromC1b.AddC1C1many2many(toC1c);
                  fromC1b.AddC1C1many2many(toC1d);
  
                  toC1a.Strategy.Delete();
                  toC1b.Strategy.Delete();
  
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  Assert.IsFalse(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC1b.Strategy.IsDeleted);
                  Assert.AreEqual(null, fromC1a.C1C1one2one);
                  Assert.AreEqual(0, fromC1a.C1C1one2manies.Count);
                  Assert.AreEqual(null, fromC1a.C1C1many2one);
                  Assert.AreEqual(0, fromC1a.C1C1many2manies.Count);
  
                  Assert.IsFalse(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(toC1c.Strategy.IsDeleted);
                  Assert.IsFalse(toC1d.Strategy.IsDeleted);
                  Assert.AreEqual(toC1c, fromC1b.C1C1one2one);
                  Assert.AreEqual(2, fromC1b.C1C1one2manies.Count);
                  Assert.AreEqual(toC1c, fromC1b.C1C1many2one);
                  Assert.AreEqual(2, fromC1b.C1C1many2manies.Count);
  
                  this.Session.Commit();
  
                  //// C1 <-> C2
  
                  fromC1a.C1C2one2one = toC2a;
                  fromC1b.C1C2one2one = toC2c;
  
                  fromC1a.C1C2many2one = toC2a;
                  fromC1b.C1C2many2one = toC2c;
  
                  fromC1a.AddC1C2one2many(toC2a);
                  fromC1a.AddC1C2one2many(toC2b);
                  fromC1b.AddC1C2one2many(toC2c);
                  fromC1b.AddC1C2one2many(toC2d);
  
                  fromC1a.AddC1C2many2many(toC2a);
                  fromC1a.AddC1C2many2many(toC2b);
                  fromC1b.AddC1C2many2many(toC2c);
                  fromC1b.AddC1C2many2many(toC2d);
  
                  toC2a.Strategy.Delete();
                  toC2b.Strategy.Delete();
  
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1sWhereC1C2many2many);
  
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC2.Instance.C1sWhereC1C2many2many);
  
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC2.Instance.C1sWhereC1C2many2many);
  
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC2.Instance.C1sWhereC1C2many2many);
  
                  Assert.IsFalse(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC2a.Strategy.IsDeleted);
                  Assert.IsTrue(toC2b.Strategy.IsDeleted);
                  Assert.AreEqual(null, fromC1a.C1C2one2one);
                  Assert.AreEqual(0, fromC1a.C1C2one2manies.Count);
                  Assert.AreEqual(null, fromC1a.C1C2many2one);
                  Assert.AreEqual(0, fromC1a.C1C2many2manies.Count);
  
                  Assert.IsFalse(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(toC2c.Strategy.IsDeleted);
                  Assert.IsFalse(toC2d.Strategy.IsDeleted);
                  Assert.AreEqual(toC2c, fromC1b.C1C2one2one);
                  Assert.AreEqual(2, fromC1b.C1C2one2manies.Count);
                  Assert.AreEqual(toC2c, fromC1b.C1C2many2one);
                  Assert.AreEqual(2, fromC1b.C1C2many2manies.Count);
  
                  this.Session.Commit();
  
                  //// Commit
  
                  //// C1 <-> C1
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
  
                  toC1a = C1.Create(this.Session);
                  toC1b = C1.Create(this.Session);
                  toC1c = C1.Create(this.Session);
                  toC1d = C1.Create(this.Session);
  
                  fromC1a.C1C1one2one = toC1a;
                  fromC1b.C1C1one2one = toC1c;
  
                  fromC1a.C1C1many2one = toC1a;
                  fromC1b.C1C1many2one = toC1c;
  
                  fromC1a.AddC1C1one2many(toC1a);
                  fromC1a.AddC1C1one2many(toC1b);
                  fromC1b.AddC1C1one2many(toC1c);
                  fromC1b.AddC1C1one2many(toC1d);
  
                  fromC1a.AddC1C1many2many(toC1a);
                  fromC1a.AddC1C1many2many(toC1b);
                  fromC1b.AddC1C1many2many(toC1c);
                  fromC1b.AddC1C1many2many(toC1d);
  
                  toC1a.Strategy.Delete();
                  toC1b.Strategy.Delete();
  
                  this.Session.Commit();
  
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  Assert.IsFalse(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC1b.Strategy.IsDeleted);
                  Assert.AreEqual(null, fromC1a.C1C1one2one);
                  Assert.AreEqual(0, fromC1a.C1C1one2manies.Count);
                  Assert.AreEqual(null, fromC1a.C1C1many2one);
                  Assert.AreEqual(0, fromC1a.C1C1many2manies.Count);
  
                  Assert.IsFalse(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(toC1c.Strategy.IsDeleted);
                  Assert.IsFalse(toC1d.Strategy.IsDeleted);
                  Assert.AreEqual(toC1c, fromC1b.C1C1one2one);
                  Assert.AreEqual(2, fromC1b.C1C1one2manies.Count);
                  Assert.AreEqual(toC1c, fromC1b.C1C1many2one);
                  Assert.AreEqual(2, fromC1b.C1C1many2manies.Count);
  
                  //// C1 <-> C2
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
  
                  toC2a = C2.Create(this.Session);
                  toC2b = C2.Create(this.Session);
                  toC2c = C2.Create(this.Session);
                  toC2d = C2.Create(this.Session);
  
                  fromC1a.C1C2one2one = toC2a;
                  fromC1b.C1C2one2one = toC2c;
  
                  fromC1a.C1C2many2one = toC2a;
                  fromC1b.C1C2many2one = toC2c;
  
                  fromC1a.AddC1C2one2many(toC2a);
                  fromC1a.AddC1C2one2many(toC2b);
                  fromC1b.AddC1C2one2many(toC2c);
                  fromC1b.AddC1C2one2many(toC2d);
  
                  fromC1a.AddC1C2many2many(toC2a);
                  fromC1a.AddC1C2many2many(toC2b);
                  fromC1b.AddC1C2many2many(toC2c);
                  fromC1b.AddC1C2many2many(toC2d);
  
                  toC2a.Strategy.Delete();
                  toC2b.Strategy.Delete();
  
                  this.Session.Commit();
  
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1sWhereC1C2many2many);
  
                  StrategyAssert.AssociationExistHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationExistHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationExistHasException(toC2a, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationExistHasException(toC2a, MetaC2.Instance.C1sWhereC1C2many2many);
  
                  StrategyAssert.AssociationExistHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationExistHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationExistHasException(toC2b, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationExistHasException(toC2b, MetaC2.Instance.C1sWhereC1C2many2many);
  
                  StrategyAssert.AssociationGetHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationGetHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationGetHasException(toC2b, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationGetHasException(toC2b, MetaC2.Instance.C1sWhereC1C2many2many);
  
                  Assert.IsFalse(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC2a.Strategy.IsDeleted);
                  Assert.IsTrue(toC2b.Strategy.IsDeleted);
                  Assert.AreEqual(null, fromC1a.C1C2one2one);
                  Assert.AreEqual(0, fromC1a.C1C2one2manies.Count);
                  Assert.AreEqual(null, fromC1a.C1C2many2one);
                  Assert.AreEqual(0, fromC1a.C1C2many2manies.Count);
  
                  Assert.IsFalse(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(toC2c.Strategy.IsDeleted);
                  Assert.IsFalse(toC2d.Strategy.IsDeleted);
                  Assert.AreEqual(toC2c, fromC1b.C1C2one2one);
                  Assert.AreEqual(2, fromC1b.C1C2one2manies.Count);
                  Assert.AreEqual(toC2c, fromC1b.C1C2many2one);
                  Assert.AreEqual(2, fromC1b.C1C2many2manies.Count);
  
                  //// Rollback
  
                  //// C1 <-> C1
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
                  fromC1c = C1.Create(this.Session);
                  fromC1d = C1.Create(this.Session);
  
                  toC1a = C1.Create(this.Session);
                  toC1b = C1.Create(this.Session);
                  toC1c = C1.Create(this.Session);
                  toC1d = C1.Create(this.Session);
  
                  fromC1a.C1C1one2one = toC1a;
                  fromC1b.C1C1one2one = toC1c;
  
                  fromC1a.C1C1many2one = toC1a;
                  fromC1b.C1C1many2one = toC1c;
  
                  fromC1a.AddC1C1one2many(toC1a);
                  fromC1a.AddC1C1one2many(toC1b);
                  fromC1b.AddC1C1one2many(toC1c);
                  fromC1b.AddC1C1one2many(toC1d);
  
                  fromC1a.AddC1C1many2many(toC1a);
                  fromC1a.AddC1C1many2many(toC1b);
                  fromC1b.AddC1C1many2many(toC1c);
                  fromC1b.AddC1C1many2many(toC1d);
  
                  toC1a.Strategy.Delete();
                  toC1b.Strategy.Delete();
  
                  this.Session.Rollback();
  
                  Assert.IsTrue(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1b.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1c.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1d.Strategy.IsDeleted);
  
                  Assert.IsTrue(toC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC1b.Strategy.IsDeleted);
                  Assert.IsTrue(toC1c.Strategy.IsDeleted);
                  Assert.IsTrue(toC1d.Strategy.IsDeleted);
  
                  // Commit + Rollback
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
                  fromC1c = C1.Create(this.Session);
                  fromC1d = C1.Create(this.Session);
  
                  toC1a = C1.Create(this.Session);
                  toC1b = C1.Create(this.Session);
                  toC1c = C1.Create(this.Session);
                  toC1d = C1.Create(this.Session);
  
                  fromC1a.C1C1one2one = toC1a;
                  fromC1b.C1C1one2one = toC1c;
  
                  fromC1a.C1C1many2one = toC1a;
                  fromC1b.C1C1many2one = toC1c;
  
                  fromC1a.AddC1C1one2many(toC1a);
                  fromC1a.AddC1C1one2many(toC1b);
                  fromC1b.AddC1C1one2many(toC1c);
                  fromC1b.AddC1C1one2many(toC1d);
  
                  fromC1a.AddC1C1many2many(toC1a);
                  fromC1a.AddC1C1many2many(toC1b);
                  fromC1b.AddC1C1many2many(toC1c);
                  fromC1b.AddC1C1many2many(toC1d);
  
                  this.Session.Commit();
  
                  toC1a.Strategy.Delete();
                  toC1b.Strategy.Delete();
  
                  this.Session.Rollback();
  
                  Assert.IsFalse(fromC1a.Strategy.IsDeleted);
                  Assert.IsFalse(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(fromC1c.Strategy.IsDeleted);
                  Assert.IsFalse(fromC1d.Strategy.IsDeleted);
  
                  Assert.IsFalse(toC1a.Strategy.IsDeleted);
                  Assert.IsFalse(toC1b.Strategy.IsDeleted);
                  Assert.IsFalse(toC1c.Strategy.IsDeleted);
                  Assert.IsFalse(toC1d.Strategy.IsDeleted);
  
                  Assert.AreEqual(fromC1a, toC1a.C1WhereC1C1one2one);
                  Assert.AreEqual(fromC1a, toC1b.C1WhereC1C1one2many);
                  Assert.AreEqual(1, toC1a.C1sWhereC1C1many2one.Count);
                  Assert.AreEqual(1, toC1a.C1sWhereC1C1many2many.Count);
                  Assert.AreEqual(1, toC1b.C1sWhereC1C1many2many.Count);
  
                  //// C1 <-> C2
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
                  fromC1c = C1.Create(this.Session);
                  fromC1d = C1.Create(this.Session);
  
                  toC2a = C2.Create(this.Session);
                  toC2b = C2.Create(this.Session);
                  toC2c = C2.Create(this.Session);
                  toC2d = C2.Create(this.Session);
  
                  fromC1a.C1C2one2one = toC2a;
                  fromC1b.C1C2one2one = toC2c;
  
                  fromC1a.C1C2many2one = toC2a;
                  fromC1b.C1C2many2one = toC2c;
  
                  fromC1a.AddC1C2one2many(toC2a);
                  fromC1a.AddC1C2one2many(toC2b);
                  fromC1b.AddC1C2one2many(toC2c);
                  fromC1b.AddC1C2one2many(toC2d);
  
                  fromC1a.AddC1C2many2many(toC2a);
                  fromC1a.AddC1C2many2many(toC2b);
                  fromC1b.AddC1C2many2many(toC2c);
                  fromC1b.AddC1C2many2many(toC2d);
  
                  toC2a.Strategy.Delete();
                  toC2b.Strategy.Delete();
  
                  this.Session.Rollback();
  
                  Assert.IsTrue(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1b.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1c.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1d.Strategy.IsDeleted);
  
                  Assert.IsTrue(toC2a.Strategy.IsDeleted);
                  Assert.IsTrue(toC2b.Strategy.IsDeleted);
                  Assert.IsTrue(toC2c.Strategy.IsDeleted);
                  Assert.IsTrue(toC2d.Strategy.IsDeleted);
  
                  // Commit + Rollback
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
                  fromC1c = C1.Create(this.Session);
                  fromC1d = C1.Create(this.Session);
  
                  toC2a = C2.Create(this.Session);
                  toC2b = C2.Create(this.Session);
                  toC2c = C2.Create(this.Session);
                  toC2d = C2.Create(this.Session);
  
                  fromC1a.C1C2one2one = toC2a;
                  fromC1b.C1C2one2one = toC2c;
  
                  fromC1a.C1C2many2one = toC2a;
                  fromC1b.C1C2many2one = toC2c;
  
                  fromC1a.AddC1C2one2many(toC2a);
                  fromC1a.AddC1C2one2many(toC2b);
                  fromC1b.AddC1C2one2many(toC2c);
                  fromC1b.AddC1C2one2many(toC2d);
  
                  fromC1a.AddC1C2many2many(toC2a);
                  fromC1a.AddC1C2many2many(toC2b);
                  fromC1b.AddC1C2many2many(toC2c);
                  fromC1b.AddC1C2many2many(toC2d);
  
                  this.Session.Commit();
  
                  toC2a.Strategy.Delete();
                  toC2b.Strategy.Delete();
  
                  this.Session.Rollback();
  
                  Assert.IsFalse(fromC1a.Strategy.IsDeleted);
                  Assert.IsFalse(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(fromC1c.Strategy.IsDeleted);
                  Assert.IsFalse(fromC1d.Strategy.IsDeleted);
  
                  Assert.IsFalse(toC2a.Strategy.IsDeleted);
                  Assert.IsFalse(toC2b.Strategy.IsDeleted);
                  Assert.IsFalse(toC2c.Strategy.IsDeleted);
                  Assert.IsFalse(toC2d.Strategy.IsDeleted);
  
                  Assert.AreEqual(fromC1a, toC2a.C1WhereC1C2one2one);
                  Assert.AreEqual(fromC1a, toC2b.C1WhereC1C2one2many);
                  Assert.AreEqual(1, toC2a.C1sWhereC1C2many2one.Count);
                  Assert.AreEqual(1, toC2a.C1sWhereC1C2many2many.Count);
                  Assert.AreEqual(1, toC2b.C1sWhereC1C2many2many.Count);
  
                  //// Cached
  
                  //// C1 <-> C1
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
  
                  toC1a = C1.Create(this.Session);
                  toC1b = C1.Create(this.Session);
                  toC1c = C1.Create(this.Session);
                  toC1d = C1.Create(this.Session);
  
                  fromC1a.C1C1one2one = toC1a;
                  fromC1b.C1C1one2one = toC1c;
  
                  fromC1a.C1C1many2one = toC1a;
                  fromC1b.C1C1many2one = toC1c;
  
                  fromC1a.AddC1C1one2many(toC1a);
                  fromC1a.AddC1C1one2many(toC1b);
                  fromC1b.AddC1C1one2many(toC1c);
                  fromC1b.AddC1C1one2many(toC1d);
  
                  fromC1a.AddC1C1many2many(toC1a);
                  fromC1a.AddC1C1many2many(toC1b);
                  fromC1b.AddC1C1many2many(toC1c);
                  fromC1b.AddC1C1many2many(toC1d);
  
                  AllorsTestUtils.ForceRoleCaching(fromC1a);
                  AllorsTestUtils.ForceRoleCaching(fromC1b);
  
                  toC1a.Strategy.Delete();
                  toC1b.Strategy.Delete();
  
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  Assert.IsFalse(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC1b.Strategy.IsDeleted);
                  Assert.AreEqual(null, fromC1a.C1C1one2one);
                  Assert.AreEqual(0, fromC1a.C1C1one2manies.Count);
                  Assert.AreEqual(null, fromC1a.C1C1many2one);
                  Assert.AreEqual(0, fromC1a.C1C1many2manies.Count);
  
                  Assert.IsFalse(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(toC1c.Strategy.IsDeleted);
                  Assert.IsFalse(toC1d.Strategy.IsDeleted);
                  Assert.AreEqual(toC1c, fromC1b.C1C1one2one);
                  Assert.AreEqual(2, fromC1b.C1C1one2manies.Count);
                  Assert.AreEqual(toC1c, fromC1b.C1C1many2one);
                  Assert.AreEqual(2, fromC1b.C1C1many2manies.Count);
  
                  this.Session.Commit();
  
                  //// Commit
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
  
                  toC1a = C1.Create(this.Session);
                  toC1b = C1.Create(this.Session);
                  toC1c = C1.Create(this.Session);
                  toC1d = C1.Create(this.Session);
  
                  fromC1a.C1C1one2one = toC1a;
                  fromC1b.C1C1one2one = toC1c;
  
                  fromC1a.C1C1many2one = toC1a;
                  fromC1b.C1C1many2one = toC1c;
  
                  fromC1a.AddC1C1one2many(toC1a);
                  fromC1a.AddC1C1one2many(toC1b);
                  fromC1b.AddC1C1one2many(toC1c);
                  fromC1b.AddC1C1one2many(toC1d);
  
                  fromC1a.AddC1C1many2many(toC1a);
                  fromC1a.AddC1C1many2many(toC1b);
                  fromC1b.AddC1C1many2many(toC1c);
                  fromC1b.AddC1C1many2many(toC1d);
  
                  AllorsTestUtils.ForceRoleCaching(fromC1a);
                  AllorsTestUtils.ForceRoleCaching(fromC1b);
  
                  toC1a.Strategy.Delete();
                  toC1b.Strategy.Delete();
  
                  this.Session.Commit();
  
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationGetHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationExistHasException(toC1a, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationExistHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2one);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1WhereC1C1one2many);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2one);
                  StrategyAssert.AssociationGetHasException(toC1b, MetaC1.Instance.C1sWhereC1C1many2many);
  
                  Assert.IsFalse(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC1b.Strategy.IsDeleted);
                  Assert.AreEqual(null, fromC1a.C1C1one2one);
                  Assert.AreEqual(0, fromC1a.C1C1one2manies.Count);
                  Assert.AreEqual(null, fromC1a.C1C1many2one);
                  Assert.AreEqual(0, fromC1a.C1C1many2manies.Count);
  
                  Assert.IsFalse(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(toC1c.Strategy.IsDeleted);
                  Assert.IsFalse(toC1d.Strategy.IsDeleted);
                  Assert.AreEqual(toC1c, fromC1b.C1C1one2one);
                  Assert.AreEqual(2, fromC1b.C1C1one2manies.Count);
                  Assert.AreEqual(toC1c, fromC1b.C1C1many2one);
                  Assert.AreEqual(2, fromC1b.C1C1many2manies.Count);
  
                  this.Session.Commit();
  
                  //// Rollback
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
                  fromC1c = C1.Create(this.Session);
                  fromC1d = C1.Create(this.Session);
  
                  toC1a = C1.Create(this.Session);
                  toC1b = C1.Create(this.Session);
                  toC1c = C1.Create(this.Session);
                  toC1d = C1.Create(this.Session);
  
                  fromC1a.C1C1one2one = toC1a;
                  fromC1b.C1C1one2one = toC1c;
  
                  fromC1a.C1C1many2one = toC1a;
                  fromC1b.C1C1many2one = toC1c;
  
                  fromC1a.AddC1C1one2many(toC1a);
                  fromC1a.AddC1C1one2many(toC1b);
                  fromC1b.AddC1C1one2many(toC1c);
                  fromC1b.AddC1C1one2many(toC1d);
  
                  fromC1a.AddC1C1many2many(toC1a);
                  fromC1a.AddC1C1many2many(toC1b);
                  fromC1b.AddC1C1many2many(toC1c);
                  fromC1b.AddC1C1many2many(toC1d);
  
                  AllorsTestUtils.ForceRoleCaching(fromC1a);
                  AllorsTestUtils.ForceRoleCaching(fromC1b);
  
                  toC1a.Strategy.Delete();
                  toC1b.Strategy.Delete();
  
                  this.Session.Rollback();
  
                  Assert.IsTrue(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1b.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1c.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1d.Strategy.IsDeleted);
  
                  Assert.IsTrue(toC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC1b.Strategy.IsDeleted);
                  Assert.IsTrue(toC1c.Strategy.IsDeleted);
                  Assert.IsTrue(toC1d.Strategy.IsDeleted);
  
                  //// Commit + Rollback
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
                  fromC1c = C1.Create(this.Session);
                  fromC1d = C1.Create(this.Session);
  
                  toC1a = C1.Create(this.Session);
                  toC1b = C1.Create(this.Session);
                  toC1c = C1.Create(this.Session);
                  toC1d = C1.Create(this.Session);
  
                  fromC1a.C1C1one2one = toC1a;
                  fromC1b.C1C1one2one = toC1c;
  
                  fromC1a.C1C1many2one = toC1a;
                  fromC1b.C1C1many2one = toC1c;
  
                  fromC1a.AddC1C1one2many(toC1a);
                  fromC1a.AddC1C1one2many(toC1b);
                  fromC1b.AddC1C1one2many(toC1c);
                  fromC1b.AddC1C1one2many(toC1d);
  
                  fromC1a.AddC1C1many2many(toC1a);
                  fromC1a.AddC1C1many2many(toC1b);
                  fromC1b.AddC1C1many2many(toC1c);
                  fromC1b.AddC1C1many2many(toC1d);
  
                  AllorsTestUtils.ForceRoleCaching(fromC1a);
                  AllorsTestUtils.ForceRoleCaching(fromC1b);
  
                  this.Session.Commit();
  
                  toC1a.Strategy.Delete();
                  toC1b.Strategy.Delete();
  
                  this.Session.Rollback();
  
                  Assert.IsFalse(fromC1a.Strategy.IsDeleted);
                  Assert.IsFalse(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(fromC1c.Strategy.IsDeleted);
                  Assert.IsFalse(fromC1d.Strategy.IsDeleted);
  
                  Assert.IsFalse(toC1a.Strategy.IsDeleted);
                  Assert.IsFalse(toC1b.Strategy.IsDeleted);
                  Assert.IsFalse(toC1c.Strategy.IsDeleted);
                  Assert.IsFalse(toC1d.Strategy.IsDeleted);
  
                  Assert.AreEqual(fromC1a, toC1a.C1WhereC1C1one2one);
                  Assert.AreEqual(fromC1a, toC1b.C1WhereC1C1one2many);
                  Assert.AreEqual(1, toC1a.C1sWhereC1C1many2one.Count);
                  Assert.AreEqual(1, toC1a.C1sWhereC1C1many2many.Count);
                  Assert.AreEqual(1, toC1b.C1sWhereC1C1many2many.Count);
  
                  //// C1 <-> C2
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
  
                  toC2a = C2.Create(this.Session);
                  toC2b = C2.Create(this.Session);
                  toC2c = C2.Create(this.Session);
                  toC2d = C2.Create(this.Session);
  
                  fromC1a.C1C2one2one = toC2a;
                  fromC1b.C1C2one2one = toC2c;
  
                  fromC1a.C1C2many2one = toC2a;
                  fromC1b.C1C2many2one = toC2c;
  
                  fromC1a.AddC1C2one2many(toC2a);
                  fromC1a.AddC1C2one2many(toC2b);
                  fromC1b.AddC1C2one2many(toC2c);
                  fromC1b.AddC1C2one2many(toC2d);
  
                  fromC1a.AddC1C2many2many(toC2a);
                  fromC1a.AddC1C2many2many(toC2b);
                  fromC1b.AddC1C2many2many(toC2c);
                  fromC1b.AddC1C2many2many(toC2d);
  
                  AllorsTestUtils.ForceRoleCaching(fromC1a);
                  AllorsTestUtils.ForceRoleCaching(fromC1b);
  
                  toC2a.Strategy.Delete();
                  toC2b.Strategy.Delete();
  
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2many);
  
                  StrategyAssert.AssociationExistHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationExistHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationExistHasException(toC2a, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationExistHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2many);
  
                  StrategyAssert.AssociationExistHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationExistHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationExistHasException(toC2b, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationExistHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2many);
  
                  StrategyAssert.AssociationGetHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationGetHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationGetHasException(toC2b, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationGetHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2many);
  
                  Assert.IsFalse(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC2a.Strategy.IsDeleted);
                  Assert.IsTrue(toC2b.Strategy.IsDeleted);
                  Assert.AreEqual(null, fromC1a.C1C2one2one);
                  Assert.AreEqual(0, fromC1a.C1C2one2manies.Count);
                  Assert.AreEqual(null, fromC1a.C1C2many2one);
                  Assert.AreEqual(0, fromC1a.C1C2many2manies.Count);
  
                  Assert.IsFalse(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(toC2c.Strategy.IsDeleted);
                  Assert.IsFalse(toC2d.Strategy.IsDeleted);
                  Assert.AreEqual(toC2c, fromC1b.C1C2one2one);
                  Assert.AreEqual(2, fromC1b.C1C2one2manies.Count);
                  Assert.AreEqual(toC2c, fromC1b.C1C2many2one);
                  Assert.AreEqual(2, fromC1b.C1C2many2manies.Count);
  
                  this.Session.Commit();
  
                  //// Commit
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
  
                  toC2a = C2.Create(this.Session);
                  toC2b = C2.Create(this.Session);
                  toC2c = C2.Create(this.Session);
                  toC2d = C2.Create(this.Session);
  
                  fromC1a.C1C2one2one = toC2a;
                  fromC1b.C1C2one2one = toC2c;
  
                  fromC1a.C1C2many2one = toC2a;
                  fromC1b.C1C2many2one = toC2c;
  
                  fromC1a.AddC1C2one2many(toC2a);
                  fromC1a.AddC1C2one2many(toC2b);
                  fromC1b.AddC1C2one2many(toC2c);
                  fromC1b.AddC1C2one2many(toC2d);
  
                  fromC1a.AddC1C2many2many(toC2a);
                  fromC1a.AddC1C2many2many(toC2b);
                  fromC1b.AddC1C2many2many(toC2c);
                  fromC1b.AddC1C2many2many(toC2d);
  
                  AllorsTestUtils.ForceRoleCaching(fromC1a);
                  AllorsTestUtils.ForceRoleCaching(fromC1b);
  
                  toC2a.Strategy.Delete();
                  toC2b.Strategy.Delete();
  
                  this.Session.Commit();
  
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationGetHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2many);
  
                  StrategyAssert.AssociationExistHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationExistHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationExistHasException(toC2a, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationExistHasException(toC2a, MetaC2.Instance.C1WhereC1C2one2many);
  
                  StrategyAssert.AssociationExistHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationExistHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationExistHasException(toC2b, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationExistHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2many);
  
                  StrategyAssert.AssociationGetHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2one);
                  StrategyAssert.AssociationGetHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2many);
                  StrategyAssert.AssociationGetHasException(toC2b, MetaC2.Instance.C1sWhereC1C2many2one);
                  StrategyAssert.AssociationGetHasException(toC2b, MetaC2.Instance.C1WhereC1C2one2many);
  
                  Assert.IsFalse(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(toC2a.Strategy.IsDeleted);
                  Assert.IsTrue(toC2b.Strategy.IsDeleted);
                  Assert.AreEqual(null, fromC1a.C1C2one2one);
                  Assert.AreEqual(0, fromC1a.C1C2one2manies.Count);
                  Assert.AreEqual(null, fromC1a.C1C2many2one);
                  Assert.AreEqual(0, fromC1a.C1C2many2manies.Count);
  
                  Assert.IsFalse(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(toC2c.Strategy.IsDeleted);
                  Assert.IsFalse(toC2d.Strategy.IsDeleted);
                  Assert.AreEqual(toC2c, fromC1b.C1C2one2one);
                  Assert.AreEqual(2, fromC1b.C1C2one2manies.Count);
                  Assert.AreEqual(toC2c, fromC1b.C1C2many2one);
                  Assert.AreEqual(2, fromC1b.C1C2many2manies.Count);
  
                  this.Session.Commit();
  
                  //// Rollback
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
                  fromC1c = C1.Create(this.Session);
                  fromC1d = C1.Create(this.Session);
  
                  toC2a = C2.Create(this.Session);
                  toC2b = C2.Create(this.Session);
                  toC2c = C2.Create(this.Session);
                  toC2d = C2.Create(this.Session);
  
                  fromC1a.C1C2one2one = toC2a;
                  fromC1b.C1C2one2one = toC2c;
  
                  fromC1a.C1C2many2one = toC2a;
                  fromC1b.C1C2many2one = toC2c;
  
                  fromC1a.AddC1C2one2many(toC2a);
                  fromC1a.AddC1C2one2many(toC2b);
                  fromC1b.AddC1C2one2many(toC2c);
                  fromC1b.AddC1C2one2many(toC2d);
  
                  fromC1a.AddC1C2many2many(toC2a);
                  fromC1a.AddC1C2many2many(toC2b);
                  fromC1b.AddC1C2many2many(toC2c);
                  fromC1b.AddC1C2many2many(toC2d);
  
                  AllorsTestUtils.ForceRoleCaching(fromC1a);
                  AllorsTestUtils.ForceRoleCaching(fromC1b);
  
                  toC2a.Strategy.Delete();
                  toC2b.Strategy.Delete();
  
                  this.Session.Rollback();
  
                  Assert.IsTrue(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1b.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1c.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1d.Strategy.IsDeleted);
  
                  Assert.IsTrue(toC2a.Strategy.IsDeleted);
                  Assert.IsTrue(toC2b.Strategy.IsDeleted);
                  Assert.IsTrue(toC2c.Strategy.IsDeleted);
                  Assert.IsTrue(toC2d.Strategy.IsDeleted);
  
                  // Commit + Rollback
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
                  fromC1c = C1.Create(this.Session);
                  fromC1d = C1.Create(this.Session);
  
                  toC2a = C2.Create(this.Session);
                  toC2b = C2.Create(this.Session);
                  toC2c = C2.Create(this.Session);
                  toC2d = C2.Create(this.Session);
  
                  fromC1a.C1C2one2one = toC2a;
                  fromC1b.C1C2one2one = toC2c;
  
                  fromC1a.C1C2many2one = toC2a;
                  fromC1b.C1C2many2one = toC2c;
  
                  fromC1a.AddC1C2one2many(toC2a);
                  fromC1a.AddC1C2one2many(toC2b);
                  fromC1b.AddC1C2one2many(toC2c);
                  fromC1b.AddC1C2one2many(toC2d);
  
                  fromC1a.AddC1C2many2many(toC2a);
                  fromC1a.AddC1C2many2many(toC2b);
                  fromC1b.AddC1C2many2many(toC2c);
                  fromC1b.AddC1C2many2many(toC2d);
  
                  AllorsTestUtils.ForceRoleCaching(fromC1a);
                  AllorsTestUtils.ForceRoleCaching(fromC1b);
  
                  this.Session.Commit();
  
                  toC2a.Strategy.Delete();
                  toC2b.Strategy.Delete();
  
                  this.Session.Rollback();
  
                  Assert.IsFalse(fromC1a.Strategy.IsDeleted);
                  Assert.IsFalse(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(fromC1c.Strategy.IsDeleted);
                  Assert.IsFalse(fromC1d.Strategy.IsDeleted);
  
                  Assert.IsFalse(toC2a.Strategy.IsDeleted);
                  Assert.IsFalse(toC2b.Strategy.IsDeleted);
                  Assert.IsFalse(toC2c.Strategy.IsDeleted);
                  Assert.IsFalse(toC2d.Strategy.IsDeleted);
  
                  Assert.AreEqual(fromC1a, toC2a.C1WhereC1C2one2one);
                  Assert.AreEqual(fromC1a, toC2b.C1WhereC1C2one2many);
                  Assert.AreEqual(1, toC2a.C1sWhereC1C2many2one.Count);
                  Assert.AreEqual(1, toC2a.C1sWhereC1C2many2many.Count);
                  Assert.AreEqual(1, toC2b.C1sWhereC1C2many2many.Count);
  
                  //// Association
  
                  //// C1 <-> C1
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
  
                  toC1a = C1.Create(this.Session);
                  toC1b = C1.Create(this.Session);
                  toC1c = C1.Create(this.Session);
                  toC1d = C1.Create(this.Session);
  
                  fromC1a.C1C1one2one = toC1a;
                  fromC1a.AddC1C1one2many(toC1a);
                  fromC1a.AddC1C1one2many(toC1b);
                  fromC1a.C1C1many2one = toC1a;
                  fromC1a.AddC1C1many2many(toC1a);
                  fromC1a.AddC1C1many2many(toC1b);
  
                  fromC1b.C1C1one2one = toC1b;
                  fromC1b.AddC1C1one2many(toC1c);
                  fromC1b.AddC1C1one2many(toC1d);
                  fromC1b.C1C1many2one = toC1b;
                  fromC1b.AddC1C1many2many(toC1c);
                  fromC1b.AddC1C1many2many(toC1d);
  
                  fromC1a.Strategy.Delete();
                  fromC1b.Strategy.Delete();
  
                  StrategyAssert.RoleExistHasException(fromC1a, MetaC1.Instance.C1C1one2one);
                  StrategyAssert.RoleExistHasException(fromC1a, MetaC1.Instance.C1C1one2manies);
                  StrategyAssert.RoleExistHasException(fromC1a, MetaC1.Instance.C1C1many2one);
                  StrategyAssert.RoleExistHasException(fromC1a, MetaC1.Instance.C1C1many2manies);
  
                  StrategyAssert.RoleGetHasException(fromC1a, MetaC1.Instance.C1C1one2one);
                  StrategyAssert.RoleGetHasException(fromC1a, MetaC1.Instance.C1C1one2manies);
                  StrategyAssert.RoleGetHasException(fromC1a, MetaC1.Instance.C1C1many2one);
                  StrategyAssert.RoleGetHasException(fromC1a, MetaC1.Instance.C1C1many2manies);
  
                  Assert.IsTrue(fromC1a.Strategy.IsDeleted);
                  Assert.IsTrue(fromC1b.Strategy.IsDeleted);
                  Assert.IsFalse(toC1a.Strategy.IsDeleted);
                  Assert.IsFalse(toC1b.Strategy.IsDeleted);
                  Assert.AreEqual(null, toC1a.C1WhereC1C1one2one);
                  Assert.AreEqual(null, toC1b.C1WhereC1C1one2many);
                  Assert.AreEqual(0, toC1a.C1sWhereC1C1many2one.Count);
                  Assert.AreEqual(0, toC1a.C1sWhereC1C1many2many.Count);
                  Assert.AreEqual(0, toC1b.C1sWhereC1C1many2many.Count);
  
                  //// C1 <-> C2
  
                  fromC1a = C1.Create(this.Session);
                  fromC1b = C1.Create(this.Session);
  
                  toC2a = C2.Create(this.Session);
  
gt:                 toC2b = C2.Create(this.Session);