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 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 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 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 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_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 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_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 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 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)); }