Example #1
0
        public void Synchronize_InTransactionHierarchy_StartsWithRoot()
        {
            var endPointID = RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order), "OrderItems");

            var endPointMockInParent = MockRepository.GenerateStrictMock <IRelationEndPoint> ();

            endPointMockInParent.Stub(stub => stub.ID).Return(endPointID);
            endPointMockInParent.Stub(stub => stub.Definition).Return(endPointID.Definition);
            endPointMockInParent.Stub(stub => stub.IsDataComplete).Return(true);
            endPointMockInParent.Expect(mock => mock.Synchronize());
            endPointMockInParent.Replay();
            RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, endPointMockInParent);

            var subTransaction    = _transaction.CreateSubTransaction();
            var endPointMockInSub = MockRepository.GenerateStrictMock <IRelationEndPoint> ();

            endPointMockInSub.Stub(stub => stub.ID).Return(endPointID);
            endPointMockInSub.Stub(stub => stub.Definition).Return(endPointID.Definition);
            endPointMockInSub.Stub(stub => stub.IsDataComplete).Return(true);
            endPointMockInSub.Expect(mock => mock.Synchronize());
            endPointMockInSub.Replay();
            DataManagerTestHelper.AddEndPoint(ClientTransactionTestHelper.GetDataManager(subTransaction), endPointMockInSub);

            BidirectionalRelationSyncService.Synchronize(subTransaction, endPointID);

            endPointMockInParent.VerifyAllExpectations();
            endPointMockInSub.VerifyAllExpectations();
        }
Example #2
0
        public void Synchronize_EndPointIncomplete()
        {
            var endPointID   = RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order), "OrderItems");
            var endPointStub = MockRepository.GenerateStub <IRelationEndPoint> ();

            endPointStub.Stub(stub => stub.ID).Return(endPointID);
            endPointStub.Stub(stub => stub.Definition).Return(endPointID.Definition);
            endPointStub.Stub(stub => stub.IsDataComplete).Return(false);
            RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, endPointStub);

            BidirectionalRelationSyncService.Synchronize(_transaction, endPointID);
        }
Example #3
0
        public void IsSynchronized_EndPointReturnsNull()
        {
            var endPointID   = RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order), "OrderItems");
            var endPointStub = MockRepository.GenerateStub <IRelationEndPoint> ();

            endPointStub.Stub(stub => stub.ID).Return(endPointID);
            endPointStub.Stub(stub => stub.Definition).Return(endPointID.Definition);
            endPointStub.Stub(stub => stub.IsSynchronized).Return(null);
            RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, endPointStub);

            var result = BidirectionalRelationSyncService.IsSynchronized(_transaction, endPointID);

            Assert.That(result, Is.Null);
        }
        public void CreateRelationEndPointManager()
        {
            var lazyLoader       = MockRepository.GenerateStub <ILazyLoader> ();
            var endPointProvider = MockRepository.GenerateStub <IRelationEndPointProvider> ();
            var eventSink        = MockRepository.GenerateStub <IClientTransactionEventSink> ();

            var relationEndPointManager =
                (RelationEndPointManager)PrivateInvoke.InvokeNonPublicMethod(
                    _factory,
                    "CreateRelationEndPointManager",
                    _fakeConstructedTransaction,
                    endPointProvider,
                    lazyLoader,
                    eventSink);

            Assert.That(relationEndPointManager.ClientTransaction, Is.SameAs(_fakeConstructedTransaction));
            Assert.That(relationEndPointManager.RegistrationAgent, Is.TypeOf <RootRelationEndPointRegistrationAgent> ());
            Assert.That(relationEndPointManager.EndPointFactory, Is.TypeOf <StateUpdateRaisingRelationEndPointFactoryDecorator> ());

            Assert.That(RelationEndPointManagerTestHelper.GetMap(relationEndPointManager).TransactionEventSink, Is.SameAs(eventSink));

            var stateUpdateRaisingFactory = (StateUpdateRaisingRelationEndPointFactoryDecorator)relationEndPointManager.EndPointFactory;

            Assert.That(
                stateUpdateRaisingFactory.Listener,
                Is.TypeOf <VirtualEndPointStateUpdateListener>()
                .With.Property <VirtualEndPointStateUpdateListener> (l => l.TransactionEventSink).SameAs(eventSink));
            Assert.That(stateUpdateRaisingFactory.InnerFactory, Is.TypeOf <RelationEndPointFactory> ());
            var endPointFactory = ((RelationEndPointFactory)stateUpdateRaisingFactory.InnerFactory);

            Assert.That(endPointFactory.ClientTransaction, Is.SameAs(_fakeConstructedTransaction));
            Assert.That(endPointFactory.LazyLoader, Is.SameAs(lazyLoader));
            Assert.That(endPointFactory.EndPointProvider, Is.SameAs(endPointProvider));
            Assert.That(endPointFactory.TransactionEventSink, Is.SameAs(eventSink));

            Assert.That(endPointFactory.CollectionEndPointDataManagerFactory, Is.TypeOf(typeof(CollectionEndPointDataManagerFactory)));
            var collectionEndPointDataManagerFactory = ((CollectionEndPointDataManagerFactory)endPointFactory.CollectionEndPointDataManagerFactory);

            Assert.That(collectionEndPointDataManagerFactory.ChangeDetectionStrategy, Is.TypeOf <RootCollectionEndPointChangeDetectionStrategy> ());
            Assert.That(endPointFactory.VirtualObjectEndPointDataManagerFactory, Is.TypeOf <VirtualObjectEndPointDataManagerFactory> ());

            Assert.That(endPointFactory.CollectionEndPointCollectionProvider, Is.TypeOf <CollectionEndPointCollectionProvider> ());
            var collectionEndPointCollectionProvider = (CollectionEndPointCollectionProvider)endPointFactory.CollectionEndPointCollectionProvider;

            Assert.That(
                collectionEndPointCollectionProvider.DataStrategyFactory,
                Is.TypeOf <AssociatedCollectionDataStrategyFactory> ()
                .With.Property((AssociatedCollectionDataStrategyFactory f) => f.VirtualEndPointProvider).SameAs(endPointProvider));
        }
Example #5
0
        public void IsSynchronized()
        {
            var endPointID   = RelationEndPointID.Create(DomainObjectIDs.OrderItem1, typeof(OrderItem), "Order");
            var endPointStub = MockRepository.GenerateStub <IRelationEndPoint>();

            endPointStub.Stub(stub => stub.ID).Return(endPointID);
            endPointStub.Stub(stub => stub.Definition).Return(endPointID.Definition);
            endPointStub.Stub(stub => stub.IsDataComplete).Return(true);
            endPointStub.Stub(stub => stub.IsSynchronized).Return(true).Repeat.Once();
            endPointStub.Stub(stub => stub.IsSynchronized).Return(false).Repeat.Once();
            RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, endPointStub);

            Assert.That(BidirectionalRelationSyncService.IsSynchronized(_transaction, endPointID), Is.True);
            Assert.That(BidirectionalRelationSyncService.IsSynchronized(_transaction, endPointID), Is.False);
        }
Example #6
0
        public void Synchronize()
        {
            var endPointID = RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order), "OrderItems");

            var endPointMock = MockRepository.GenerateStrictMock <IRelationEndPoint>();

            endPointMock.Stub(stub => stub.ID).Return(endPointID);
            endPointMock.Stub(stub => stub.Definition).Return(endPointID.Definition);
            endPointMock.Stub(stub => stub.IsDataComplete).Return(true);
            endPointMock.Expect(mock => mock.Synchronize());
            endPointMock.Replay();
            RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, endPointMock);

            BidirectionalRelationSyncService.Synchronize(_transaction, endPointID);

            endPointMock.VerifyAllExpectations();
        }
Example #7
0
 public static void AddEndPoint(DataManager dataManager, IRelationEndPoint endPoint)
 {
     RelationEndPointManagerTestHelper.AddEndPoint((RelationEndPointManager)GetRelationEndPointManager(dataManager), endPoint);
 }
Example #8
0
 public static void RemoveEndPoint(IDataManager dataManager, RelationEndPointID endPointID)
 {
     RelationEndPointManagerTestHelper.RemoveEndPoint((RelationEndPointManager)GetRelationEndPointManager(dataManager), endPointID);
 }