public void SetDataFromSubTransaction_InvalidDefinition() { var otherID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order"); ObjectEndPoint source = RelationEndPointObjectMother.CreateRealObjectEndPoint(otherID); _endPointPartialMock.SetDataFromSubTransaction(source); }
public void CreateUnregisterCommandForDataContainer_Existing_IncludesRealObjectEndPoints_IgnoresVirtualEndPoints() { var realEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "Customer"); var dataContainer = RelationEndPointTestHelper.CreateExistingForeignKeyDataContainer(realEndPointID, DomainObjectIDs.Order3); _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer); var realEndPoint = _relationEndPointManager.RelationEndPoints[realEndPointID]; var virtualObjectEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems"); var virtualObjectEndPointStub = MockRepository.GenerateStub <IVirtualObjectEndPoint> (); virtualObjectEndPointStub.Stub(stub => stub.ID).Return(virtualObjectEndPointID); RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, virtualObjectEndPointStub); var collectionEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket"); var collectionEndPointStub = MockRepository.GenerateStub <ICollectionEndPoint> (); collectionEndPointStub.Stub(stub => stub.ID).Return(collectionEndPointID); RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, collectionEndPointStub); var command = _relationEndPointManager.CreateUnregisterCommandForDataContainer(dataContainer); Assert.That(command, Is.TypeOf <UnregisterEndPointsCommand> ()); Assert.That(((UnregisterEndPointsCommand)command).RegistrationAgent, Is.SameAs(_relationEndPointManager.RegistrationAgent)); Assert.That(((UnregisterEndPointsCommand)command).Map, Is.SameAs(_relationEndPointManager.RelationEndPoints)); Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.Member(realEndPoint)); Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.No.Member(virtualObjectEndPointStub)); Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.No.Member(collectionEndPointStub)); }
public void SetDataFromSubTransaction_InvalidDefinition() { var otherID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems"); var source = RelationEndPointObjectMother.CreateCollectionEndPoint(otherID, new DomainObject[0]); _endPoint.SetDataFromSubTransaction(source); }
public void CreateUnregisterCommandForDataContainer_New_IncludesRealObjectEndPoints_IncludesVirtualEndPoints() { var realEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "Customer"); var dataContainer = RelationEndPointTestHelper.CreateNewDataContainer(realEndPointID); _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer); var realEndPoint = _relationEndPointManager.RelationEndPoints[realEndPointID]; var virtualObjectEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems"); var virtualObjectEndPoint = _relationEndPointManager.RelationEndPoints[virtualObjectEndPointID]; Assert.That(virtualObjectEndPoint, Is.Not.Null); var collectionEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket"); var collectionEndPoint = _relationEndPointManager.RelationEndPoints[collectionEndPointID]; Assert.That(collectionEndPoint, Is.Not.Null); var command = _relationEndPointManager.CreateUnregisterCommandForDataContainer(dataContainer); Assert.That(command, Is.TypeOf <UnregisterEndPointsCommand> ()); Assert.That(((UnregisterEndPointsCommand)command).RegistrationAgent, Is.SameAs(_relationEndPointManager.RegistrationAgent)); Assert.That(((UnregisterEndPointsCommand)command).Map, Is.SameAs(_relationEndPointManager.RelationEndPoints)); Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.Member(realEndPoint)); Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.Member(virtualObjectEndPoint)); Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.Member(collectionEndPoint)); }
public void Initialize_InvalidDataContainer() { var id = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order"); var foreignKeyDataContainer = DataContainer.CreateNew(DomainObjectIDs.Order1); Dev.Null = new RealObjectEndPoint(TestableClientTransaction, id, foreignKeyDataContainer, _endPointProviderStub, _transactionEventSinkStub); }
public override void SetUp() { base.SetUp(); _eventSinkWithWock = MockRepository.GenerateMock <IClientTransactionEventSink>(); _endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems"); _stateUpdateListener = new VirtualEndPointStateUpdateListener(_eventSinkWithWock); }
public void RegisterEndPointsForDataContainer_Existing_RegistersNoVirtualObjectEndPoints() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket"); var dataContainer = RelationEndPointTestHelper.CreateExistingDataContainer(endPointID); _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer); Assert.That(_relationEndPointManager.RelationEndPoints[endPointID], Is.Null); }
public void GetOppositeRelationEndPointIDs_BidirectionalEndPoint() { _endPointPartialMock.Stub(stub => stub.OppositeObjectID).Return(DomainObjectIDs.OrderTicket1); var oppositeEndPointIDs = _endPointPartialMock.GetOppositeRelationEndPointIDs().ToArray(); var expectedID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order"); Assert.That(oppositeEndPointIDs, Is.EqualTo(new[] { expectedID })); }
public void GetOppositeRelationEndPointID_NonNullEndPoint() { _endPointPartialMock.Stub(stub => stub.OppositeObjectID).Return(DomainObjectIDs.OrderTicket1); var oppositeEndPointID = _endPointPartialMock.GetOppositeRelationEndPointID(); var expectedID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order"); Assert.That(oppositeEndPointID, Is.EqualTo(expectedID)); }
public void GetOppositeRelationEndPointIDs_UnidirectionalEndPoint() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Location1, "Client"); var endPoint = RelationEndPointObjectMother.CreateRealObjectEndPoint(endPointID); Assert.That(endPoint.Definition.GetOppositeEndPointDefinition().IsAnonymous, Is.True); var oppositeEndPointIDs = endPoint.GetOppositeRelationEndPointIDs().ToArray(); Assert.That(oppositeEndPointIDs, Is.Empty); }
public void RegisterEndPointsForDataContainer_Existing_RegistersNoOppositeNullObjectEndPoints() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order"); var dataContainer = RelationEndPointTestHelper.CreateExistingForeignKeyDataContainer(endPointID, null); _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer); var oppositeEndPointDefinition = endPointID.Definition.GetOppositeEndPointDefinition(); var expectedID = RelationEndPointID.Create(null, oppositeEndPointDefinition); Assert.That(_relationEndPointManager.RelationEndPoints[expectedID], Is.Null); }
public void RegisterEndPointsForDataContainer_New_RegistersRealObjectEndPoints() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order"); var dataContainer = RelationEndPointTestHelper.CreateNewDataContainer(endPointID); var foreignKeyProperty = GetPropertyDefinition(typeof(OrderTicket), "Order"); _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer); var objectEndPoint = (RealObjectEndPoint)_relationEndPointManager.RelationEndPoints[endPointID]; Assert.That(objectEndPoint.PropertyDefinition, Is.EqualTo(foreignKeyProperty)); }
public void GetOrCreateVirtualEndPoint_NewlyCreated_CollectionEndPoint() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems"); Assert.That(_relationEndPointManager.RelationEndPoints[endPointID], Is.Null); var result = _relationEndPointManager.GetOrCreateVirtualEndPoint(endPointID); Assert.That(result, Is.Not.Null.And.AssignableTo <ICollectionEndPoint>()); Assert.That(_relationEndPointManager.RelationEndPoints[endPointID], Is.SameAs(result)); Assert.That(result.IsDataComplete, Is.False); }
public void RegisterEndPointsForDataContainer_New_RegistersVirtualObjectEndPoints() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket"); var dataContainer = RelationEndPointTestHelper.CreateNewDataContainer(endPointID); _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer); var objectEndPoint = (IVirtualObjectEndPoint)_relationEndPointManager.RelationEndPoints[endPointID]; Assert.That(objectEndPoint, Is.Not.Null); Assert.That(objectEndPoint.IsDataComplete, Is.True); Assert.That(objectEndPoint.OppositeObjectID, Is.Null); }
public void GetRelationEndPointWithLazyLoad_DoesNotLoadData_OfObjectsWithVirtualEndPointNotYetRegistered() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket"); Assert.That(endPointID.Definition.IsVirtual, Is.True); Assert.That(TestableClientTransaction.DataManager.DataContainers[DomainObjectIDs.Order1], Is.Null); var result = _relationEndPointManager.GetRelationEndPointWithLazyLoad(endPointID); Assert.That(result, Is.Not.Null); Assert.That(TestableClientTransaction.DataManager.DataContainers[DomainObjectIDs.Order1], Is.Null); }
public void GetRelationEndPointWithLazyLoad_LoadsData_OfObjectsWithRealEndPointNotYetRegistered() { var locationEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Location1, "Client"); Assert.That(locationEndPointID.Definition.IsVirtual, Is.False); Assert.That(TestableClientTransaction.DataManager.DataContainers[DomainObjectIDs.Location1], Is.Null); var result = _relationEndPointManager.GetRelationEndPointWithLazyLoad(locationEndPointID); Assert.That(result, Is.Not.Null); Assert.That(TestableClientTransaction.DataManager.DataContainers[DomainObjectIDs.Location1], Is.Not.Null); }
public void RegisterEndPointsForDataContainer_New_RegistersCollectionEndPoints() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems"); var dataContainer = RelationEndPointTestHelper.CreateNewDataContainer(endPointID); _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer); var collectionEndPoint = (ICollectionEndPoint)_relationEndPointManager.RelationEndPoints[endPointID]; Assert.That(collectionEndPoint, Is.Not.Null); Assert.That(collectionEndPoint.IsDataComplete, Is.True); Assert.That(collectionEndPoint.Collection, Is.Empty); }
public void RegisterEndPointsForDataContainer_Existing_RegistersOppositeVirtualObjectEndPoints() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order"); var dataContainer = RelationEndPointTestHelper.CreateExistingForeignKeyDataContainer(endPointID, DomainObjectIDs.Order3); _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer); var oppositeID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order3, "OrderTicket"); var oppositeEndPoint = (IVirtualObjectEndPoint)_relationEndPointManager.RelationEndPoints[oppositeID]; Assert.That(oppositeEndPoint, Is.Not.Null); Assert.That(oppositeEndPoint.OppositeObjectID, Is.EqualTo(DomainObjectIDs.OrderTicket1)); }
public void Reset_RaisesUnregisteringEvents() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Customer1, "Orders"); var endPointStub = MockRepository.GenerateStub <IRelationEndPoint> (); endPointStub.Stub(stub => stub.ID).Return(endPointID); RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, endPointStub); var listenerMock = ClientTransactionTestHelperWithMocks.CreateAndAddListenerMock(_relationEndPointManager.ClientTransaction); _relationEndPointManager.Reset(); listenerMock.AssertWasCalled(mock => mock.RelationEndPointMapUnregistering(_relationEndPointManager.ClientTransaction, endPointID)); }
public void RegisterEndPointsForDataContainer_Existing_RegistersRealObjectEndPoints() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order"); var dataContainer = RelationEndPointTestHelper.CreateExistingForeignKeyDataContainer(endPointID, DomainObjectIDs.Order3); var foreignKeyProperty = GetPropertyDefinition(typeof(OrderTicket), "Order"); _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer); var endPoint = (RealObjectEndPoint)_relationEndPointManager.RelationEndPoints[endPointID]; Assert.That(endPoint, Is.Not.Null); Assert.That(endPoint.PropertyDefinition, Is.EqualTo(foreignKeyProperty)); Assert.That(endPoint.OppositeObjectID, Is.EqualTo(DomainObjectIDs.Order3)); }
public void GetRelationEndPointWithLazyLoad_RegistersVirtualObjectEndPoint_ButDoesNotLoadItsContents() { _relationEndPointManager.ClientTransaction.EnsureDataAvailable(DomainObjectIDs.Order1); // preload Order1 before lazily loading its virtual end point var orderTicketEndPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket"); Assert.That(_relationEndPointManager.RelationEndPoints[orderTicketEndPointID], Is.Null); var endPoint = _relationEndPointManager.GetRelationEndPointWithLazyLoad(orderTicketEndPointID); Assert.That(endPoint, Is.Not.Null); Assert.That(endPoint.IsDataComplete, Is.False); Assert.That(_relationEndPointManager.RelationEndPoints[orderTicketEndPointID], Is.SameAs(endPoint)); }
public void GetRelationEndPointWithLazyLoad_RegistersVirtualObjectEndPointWithNull() { _relationEndPointManager.ClientTransaction.EnsureDataAvailable(DomainObjectIDs.Employee1); // preload Employee before lazily loading its virtual end point var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Employee1, "Computer"); Assert.That(_relationEndPointManager.RelationEndPoints[endPointID], Is.Null); var endPoint = _relationEndPointManager.GetRelationEndPointWithLazyLoad(endPointID); Assert.That(endPoint, Is.Not.Null); Assert.That(_relationEndPointManager.RelationEndPoints[endPointID], Is.SameAs(endPoint)); Assert.That(((IVirtualObjectEndPoint)endPoint).OppositeObjectID, Is.Null); }
public override void SetUp() { base.SetUp(); _endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.OrderTicket1, "Order"); _foreignKeyDataContainer = DataContainer.CreateForExisting(_endPointID.ObjectID, null, pd => pd.DefaultValue); _endPointProviderStub = MockRepository.GenerateStub <IRelationEndPointProvider>(); _transactionEventSinkStub = MockRepository.GenerateStub <IClientTransactionEventSink>(); _syncStateMock = MockRepository.GenerateStrictMock <IRealObjectEndPointSyncState> (); _endPoint = new RealObjectEndPoint( TestableClientTransaction, _endPointID, _foreignKeyDataContainer, _endPointProviderStub, _transactionEventSinkStub); PrivateInvoke.SetNonPublicField(_endPoint, "_syncState", _syncStateMock); }
public void GetAllRelationEndPointIDs() { var endPointIDs = RelationEndPointID.GetAllRelationEndPointIDs(DomainObjectIDs.Order1); var expectedIDs = new[] { RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "Customer"), RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket"), RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderItems"), RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "Official"), }; Assert.That(endPointIDs, Is.EquivalentTo(expectedIDs)); }
public void RollbackAllEndPoints_RollsbackEndPoints() { RelationEndPointID endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Customer1, "Orders"); var endPointMock = MockRepository.GenerateStrictMock <IRelationEndPoint> (); endPointMock.Stub(stub => stub.ID).Return(endPointID); endPointMock.Expect(mock => mock.Rollback()); endPointMock.Replay(); RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, endPointMock); _relationEndPointManager.RollbackAllEndPoints(); endPointMock.VerifyAllExpectations(); }
public override void SetUp() { base.SetUp(); _invalidObject = Order.NewObject(); _invalidObject.Delete(); Assert.That(_invalidObject.State, Is.EqualTo(StateType.Invalid)); _endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket"); _endPoint = new TestableRelationEndPoint(TestableClientTransaction, _endPointID); _endPointWithNullObject = new TestableRelationEndPoint(TestableClientTransaction, RelationEndPointID.Create(null, _endPointID.Definition)); _endPointWithInvalidObject = new TestableRelationEndPoint(TestableClientTransaction, RelationEndPointID.Create(_invalidObject.ID, _endPointID.Definition)); }
public void Reset_RemovesEndPoints() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Customer1, "Orders"); var endPointMock = MockRepository.GenerateStrictMock <IRelationEndPoint> (); endPointMock.Stub(stub => stub.ID).Return(endPointID); endPointMock.Expect(mock => mock.Rollback()); endPointMock.Replay(); RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, endPointMock); Assert.That(_relationEndPointManager.RelationEndPoints, Is.Not.Empty.And.Member(endPointMock)); _relationEndPointManager.Reset(); endPointMock.VerifyAllExpectations(); Assert.That(_relationEndPointManager.RelationEndPoints, Is.Empty); }
public void CreateUnregisterCommandForDataContainer_WithUnidirectionalEndPoints() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Location1, "Client"); var dataContainer = RelationEndPointTestHelper.CreateNewDataContainer(endPointID); _relationEndPointManager.RegisterEndPointsForDataContainer(dataContainer); var unidirectionalEndPoint = (RealObjectEndPoint)_relationEndPointManager.RelationEndPoints[endPointID]; Assert.That(unidirectionalEndPoint, Is.Not.Null); var command = _relationEndPointManager.CreateUnregisterCommandForDataContainer(dataContainer); Assert.That(command, Is.TypeOf <UnregisterEndPointsCommand> ()); Assert.That(((UnregisterEndPointsCommand)command).RegistrationAgent, Is.SameAs(_relationEndPointManager.RegistrationAgent)); Assert.That(((UnregisterEndPointsCommand)command).Map, Is.SameAs(_relationEndPointManager.RelationEndPoints)); Assert.That(((UnregisterEndPointsCommand)command).EndPoints, Has.Member(unidirectionalEndPoint)); }
public void GetOrCreateVirtualEndPoint_AlreadyAvailable() { var endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket"); var endPointMock = MockRepository.GenerateStrictMock <IVirtualEndPoint> (); endPointMock.Stub(stub => stub.ID).Return(endPointID); endPointMock.Expect(mock => mock.EnsureDataComplete()); endPointMock.Replay(); RelationEndPointManagerTestHelper.AddEndPoint(_relationEndPointManager, endPointMock); Assert.That(_relationEndPointManager.RelationEndPoints[endPointID], Is.SameAs(endPointMock)); var result = _relationEndPointManager.GetOrCreateVirtualEndPoint(endPointID); Assert.That(result, Is.SameAs(endPointMock)); Assert.That(_relationEndPointManager.RelationEndPoints[endPointID], Is.SameAs(endPointMock)); }
public override void SetUp() { base.SetUp(); _endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Order1, "OrderTicket"); _lazyLoaderMock = MockRepository.GenerateStrictMock <ILazyLoader>(); _endPointProviderStub = MockRepository.GenerateStub <IRelationEndPointProvider> (); _transactionEventSinkStub = MockRepository.GenerateStub <IClientTransactionEventSink>(); _dataManagerFactory = new VirtualObjectEndPointDataManagerFactory(); _loadStateMock = MockRepository.GenerateStrictMock <IVirtualObjectEndPointLoadState> (); _endPoint = new VirtualObjectEndPoint( ClientTransaction.Current, _endPointID, _lazyLoaderMock, _endPointProviderStub, _transactionEventSinkStub, _dataManagerFactory); PrivateInvoke.SetNonPublicField(_endPoint, "_loadState", _loadStateMock); _oppositeEndPointStub = MockRepository.GenerateStub <IRealObjectEndPoint>(); _oppositeObject = DomainObjectMother.CreateFakeObject <OrderTicket>(); }