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