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(); }
public void RelationEndPointManager_Content() { DomainObjectIDs.Order1.GetObject <Order> ().OrderItems.EnsureDataComplete(); Assert.That(_relationEndPointManager.RelationEndPoints.Count, Is.EqualTo(7)); var deserializedManager = (RelationEndPointManager)DataManagerTestHelper.GetRelationEndPointManager( Serializer.SerializeAndDeserialize(TestableClientTransaction.DataManager)); Assert.That(deserializedManager.ClientTransaction, Is.Not.Null); Assert.That(deserializedManager.ClientTransaction, Is.InstanceOf(typeof(TestableClientTransaction))); Assert.That(deserializedManager.ClientTransaction, Is.Not.SameAs(TestableClientTransaction)); Assert.That(deserializedManager.LazyLoader, Is.Not.Null); Assert.That(deserializedManager.LazyLoader, Is.TypeOf(_relationEndPointManager.LazyLoader.GetType())); Assert.That(deserializedManager.EndPointFactory, Is.Not.Null); Assert.That(deserializedManager.EndPointFactory, Is.TypeOf(_relationEndPointManager.EndPointFactory.GetType())); Assert.That(deserializedManager.RegistrationAgent, Is.TypeOf(_relationEndPointManager.RegistrationAgent.GetType())); Assert.That(deserializedManager.DataContainerEndPointsRegistrationAgent, Is.Not.Null); Assert.That(deserializedManager.RelationEndPoints.Count, Is.EqualTo(7)); var endPointID = RelationEndPointID.Create(DomainObjectIDs.Order1, ReflectionMappingHelper.GetPropertyName(typeof(Order), "OrderItems")); var endPoint = (ICollectionEndPoint)deserializedManager.GetRelationEndPointWithoutLoading(endPointID); Assert.That(endPoint.ClientTransaction, Is.SameAs(deserializedManager.ClientTransaction)); }
public void DataContainerMapIsFlattenedSerializable() { DataContainerMap map = DataManagerTestHelper.GetDataContainerMap(TestableClientTransaction.DataManager); DataContainerMap deserializedMap = FlattenedSerializer.SerializeAndDeserialize(map); Assert.That(deserializedMap, Is.Not.Null); }
public override void SetUp() { base.SetUp(); _transaction = ClientTransaction.CreateRootTransaction(); var dataManager = ClientTransactionTestHelper.GetDataManager(_transaction); _relationEndPointManager = (RelationEndPointManager)DataManagerTestHelper.GetRelationEndPointManager(dataManager); }
public void DataContainerMap_Content() { DataContainerMap map = DataManagerTestHelper.GetDataContainerMap(TestableClientTransaction.DataManager); DomainObjectIDs.Order1.GetObject <Order> (); Assert.That(map.Count, Is.EqualTo(1)); DataContainerMap deserializedMap = FlattenedSerializer.SerializeAndDeserialize(map); Assert.That(deserializedMap.TransactionEventSink, Is.Not.Null); Assert.That(deserializedMap.Count, Is.EqualTo(1)); }
public override void SetUp() { base.SetUp(); _relationEndPointManager = (RelationEndPointManager)DataManagerTestHelper.GetRelationEndPointManager(TestableClientTransaction.DataManager); }
public void CreateDataManager() { var fakeEventSink = MockRepository.GenerateStub <IClientTransactionEventSink> (); var fakeInvalidDomainObjectManager = MockRepository.GenerateStub <IInvalidDomainObjectManager> (); var fakePersistenceStrategy = MockRepository.GenerateStub <IPersistenceStrategy>(); var fakeDataContainerEventListener = MockRepository.GenerateStub <IDataContainerEventListener> (); var fakeEndPointProvider = MockRepository.GenerateStub <IRelationEndPointProvider> (); var fakeLazyLoader = MockRepository.GenerateStub <ILazyLoader> (); var fakeRelationEndPointManager = MockRepository.GenerateStub <IRelationEndPointManager> (); var fakeObjectLoader = MockRepository.GenerateStub <IObjectLoader> (); var fakeHierarchyManager = MockRepository.GenerateStub <ITransactionHierarchyManager> (); DelegatingDataManager endPointProviderDataManager = null; DelegatingDataManager lazyLoaderDataManager = null; DelegatingDataManager objectLoaderDataManager = null; var factoryPartialMock = MockRepository.GeneratePartialMock <TestableClientTransactionComponentFactoryBase>(); factoryPartialMock .Expect(mock => mock.CallCreateDataContainerEventListener(fakeEventSink)) .Return(fakeDataContainerEventListener); factoryPartialMock .Expect(mock => mock.CallGetEndPointProvider(Arg <DelegatingDataManager> .Is.TypeOf)) .Return(fakeEndPointProvider) .WhenCalled(mi => endPointProviderDataManager = (DelegatingDataManager)mi.Arguments[0]); factoryPartialMock .Expect(mock => mock.CallGetLazyLoader(Arg <DelegatingDataManager> .Is.TypeOf)) .Return(fakeLazyLoader) .WhenCalled(mi => lazyLoaderDataManager = (DelegatingDataManager)mi.Arguments[0]); factoryPartialMock .Expect( mock => mock.CallCreateRelationEndPointManager(_fakeConstructedTransaction, fakeEndPointProvider, fakeLazyLoader, fakeEventSink)) .Return(fakeRelationEndPointManager); factoryPartialMock .Expect( mock => mock.CallCreateObjectLoader( Arg.Is(_fakeConstructedTransaction), Arg.Is(fakeEventSink), Arg.Is(fakePersistenceStrategy), Arg.Is(fakeInvalidDomainObjectManager), Arg <DelegatingDataManager> .Is.TypeOf, Arg.Is(fakeHierarchyManager))) .Return(fakeObjectLoader) .WhenCalled(mi => objectLoaderDataManager = (DelegatingDataManager)mi.Arguments[4]); factoryPartialMock.Replay(); var dataManager = (DataManager)factoryPartialMock.CreateDataManager( _fakeConstructedTransaction, fakeEventSink, fakeInvalidDomainObjectManager, fakePersistenceStrategy, fakeHierarchyManager); factoryPartialMock.VerifyAllExpectations(); Assert.That(endPointProviderDataManager.InnerDataManager, Is.SameAs(dataManager)); Assert.That(lazyLoaderDataManager.InnerDataManager, Is.SameAs(dataManager)); Assert.That(objectLoaderDataManager.InnerDataManager, Is.SameAs(dataManager)); Assert.That(dataManager.ClientTransaction, Is.SameAs(_fakeConstructedTransaction)); Assert.That(dataManager.TransactionEventSink, Is.SameAs(fakeEventSink)); Assert.That(dataManager.DataContainerEventListener, Is.SameAs(fakeDataContainerEventListener)); Assert.That(DataManagerTestHelper.GetInvalidDomainObjectManager(dataManager), Is.SameAs(fakeInvalidDomainObjectManager)); Assert.That(DataManagerTestHelper.GetObjectLoader(dataManager), Is.SameAs(fakeObjectLoader)); Assert.That(DataManagerTestHelper.GetRelationEndPointManager(dataManager), Is.SameAs(fakeRelationEndPointManager)); }