protected void CheckTouching (Action modification, TestDomainBase foreignKeyObject, string simpleForeignKeyPropertyName,
                                params RelationEndPointID[] endPointsInvolved)
    {
      // Ensure all end points are loaded into the RelationEndPointManager before trying to check them
      foreach (RelationEndPointID id in endPointsInvolved)
      {
        TestableClientTransaction.DataManager.GetRelationEndPointWithLazyLoad (id);
      }

      if (foreignKeyObject != null)
      {
        Assert.IsFalse (
            foreignKeyObject.Properties[foreignKeyObject.GetPublicDomainObjectType(), simpleForeignKeyPropertyName].HasBeenTouched,
            "ObjectID before modification");
      }

      foreach (RelationEndPointID id in endPointsInvolved)
        Assert.IsFalse (TestableClientTransaction.DataManager.GetRelationEndPointWithoutLoading (id).HasBeenTouched, id + " before modification");

      modification ();

      if (foreignKeyObject != null)
      {
        Assert.IsTrue (
            foreignKeyObject.Properties[foreignKeyObject.GetPublicDomainObjectType(), simpleForeignKeyPropertyName].HasBeenTouched,
            "ObjectID after modification");
      }

      foreach (RelationEndPointID id in endPointsInvolved)
        Assert.IsTrue (TestableClientTransaction.DataManager.GetRelationEndPointWithoutLoading (id).HasBeenTouched, id + " after modification");
    }
Example #2
0
 private void ExpectHandleReference(ICloneStrategy strategyMock, TestDomainBase original, TestDomainBase clone, string propertyName,
                                    ClientTransaction sourceTransaction, ClientTransaction cloneTransaction)
 {
     strategyMock.HandleReference(new PropertyAccessor(), new PropertyAccessor(), null);
     LastCall.Constraints(
         Rhino.Mocks.Constraints.Is.Equal(original.Properties[original.GetPublicDomainObjectType(), propertyName, sourceTransaction]),
         Rhino.Mocks.Constraints.Is.Equal(clone.Properties[clone.GetPublicDomainObjectType(), propertyName, cloneTransaction]),
         Rhino.Mocks.Constraints.Is.Anything());
 }
Example #3
0
        public TestDomainVertex GetVertex(TestDomainBase domain)
        {
            if (domain == null)
            {
                throw new ArgumentNullException("domain");
            }
            TestDomainVertex v = this.domainVertices[domain] as TestDomainVertex;

            return(v);
        }
        public override void SetUp()
        {
            base.SetUp();
            _endPointManagerMock            = MockRepository.GenerateStrictMock <IRelationEndPointManager>();
            _transactionEventSinkWithMock   = MockRepository.GenerateMock <IClientTransactionEventSink>();
            _dataContainerMap               = new DataContainerMap(_transactionEventSinkWithMock);
            _invalidDomainObjectManagerMock = MockRepository.GenerateStrictMock <IInvalidDomainObjectManager>();

            _existingDataContainer = CreateExistingDataContainer();
            _existingDomainObject  = (TestDomainBase)_existingDataContainer.DomainObject;

            _newDataContainer = CreateNewDataContainer();
            _newDomainObject  = (TestDomainBase)_newDataContainer.DomainObject;

            _unloadCommand = new UnloadAllCommand(_endPointManagerMock, _dataContainerMap, _invalidDomainObjectManagerMock, _transactionEventSinkWithMock);
        }
Example #5
0
        protected override void DomainObject_RelationChanged(object sender, RelationChangedEventArgs args)
        {
            TestDomainBase domainObject = (TestDomainBase)sender;

            changedObjectState = domainObject.State;

            string changedProperty = args.RelationEndPointDefinition.PropertyName;

            if (CardinalityType.One == domainObject.InternalDataContainer.ClassDefinition.GetRelationEndPointDefinition(changedProperty).Cardinality)
            {
                DomainObject relatedDomainObject = domainObject.GetRelatedObject(changedProperty);
                changedRelatedObjects.Add(changedProperty, relatedDomainObject);
            }
            else
            {
                DomainObjectCollection relatedDomainObjectCollection = domainObject.GetRelatedObjects(changedProperty);
                changedRelatedObjects.Add(changedProperty, relatedDomainObjectCollection.Clone(true));
            }

            base.DomainObject_RelationChanged(sender, args);
        }
Example #6
0
        public TestDomainVertex AddDomain(TestDomainBase domain)
        {
            if (domain == null)
            {
                throw new ArgumentNullException("domain");
            }
            TestDomainVertex v = this.domainVertices[domain] as TestDomainVertex;

            if (v != null)
            {
                return(v);
            }

            v        = (TestDomainVertex)this.graph.AddVertex();
            v.Domain = domain;
            this.domainVertices.Add(domain, v);

            // load domain
            domain.Load();

            /*
             * MLS 12/21/05 - Tell the test engine to add a console listener,
             * if started from console app with verbose option.
             * Note that the test engine is actually a remoting proxy to the remote test engine at this point.
             */
            if (this.verbose)
            {
                domain.TestEngine.AddConsoleListener();
            }


            // adding path
            foreach (string assemblyPath in this.AssemblyPaths)
            {
                domain.TestEngine.Resolver.AddHintDirectory(assemblyPath);
            }

            this.assemblyNameVertices.Add(domain.TestEngine.Explorer.AssemblyName, v);
            return(v);
        }
Example #7
0
        public void Ctor_RegistersObject()
        {
            TestDomainBase.StaticCtorHandler +=
                (sender, args) =>
                Assert.That(ObjectInititalizationContextScope.CurrentObjectInitializationContext.RegisteredObject, Is.SameAs(sender));

            Order instance;

            try
            {
                instance = _transaction.ExecuteInScope(() => Order.NewObject());
            }
            finally
            {
                TestDomainBase.ClearStaticCtorHandlers();
            }

            Assert.That(_transaction.IsEnlisted(instance), Is.True);
            var dataContainer = _transaction.DataManager.DataContainers[instance.ID];

            Assert.That(dataContainer, Is.Not.Null);
            Assert.That(dataContainer.DomainObject, Is.SameAs(instance));
            Assert.That(dataContainer.ClientTransaction, Is.SameAs(_transaction));
        }
        public override void TearDown()
        {
            TestDomainBase.ClearStaticCtorHandlers();

            base.TearDown();
        }