private void ExpectLoadOpposite() { var oppositeID = RelationEndPointID.CreateOpposite(_endPointID.Definition, DomainObjectIDs.Customer1); _virtualEndPointProviderMock.Expect(mock => mock.GetOrCreateVirtualEndPoint(oppositeID)).Return(_oppositeEndPointMock); _oppositeEndPointMock.Expect(mock => mock.EnsureDataComplete()); }
public void CreateOpposite_Unidirectional() { var sourceEndPointDefinition = Configuration.GetTypeDefinition(typeof(Location)).GetRelationEndPointDefinition(typeof(Location).FullName + ".Client"); var endPointID = RelationEndPointID.CreateOpposite(sourceEndPointDefinition, DomainObjectIDs.Client1); Assert.That(endPointID.Definition.IsAnonymous, Is.True); }
public void CreateOpposite() { var sourceEndPointDefinition = Configuration.GetTypeDefinition(typeof(OrderItem)).GetRelationEndPointDefinition(typeof(OrderItem).FullName + ".Order"); var endPointID = RelationEndPointID.CreateOpposite(sourceEndPointDefinition, DomainObjectIDs.Order1); Assert.That(endPointID, Is.EqualTo(RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order), "OrderItems"))); }
protected IRelationEndPoint GetOppositeEndPoint( IRelationEndPoint originatingEndPoint, DomainObject oppositeObject, IRelationEndPointProvider endPointProvider) { var oppositeEndPointID = RelationEndPointID.CreateOpposite(originatingEndPoint.Definition, oppositeObject.GetSafeID()); return(endPointProvider.GetRelationEndPointWithLazyLoad(oppositeEndPointID)); }
private void LoadOppositeEndPoint(IRealObjectEndPoint endPoint) { var oppositeID = RelationEndPointID.CreateOpposite(endPoint.Definition, endPoint.OppositeObjectID); Assertion.IsFalse(oppositeID.Definition.IsAnonymous, "Unidirectional end-points don't get used in unknown state."); var oppositeEndPoint = _virtualEndPointProvider.GetOrCreateVirtualEndPoint(oppositeID); oppositeEndPoint.EnsureDataComplete(); }
public void CreateOpposite_Null() { var sourceEndPointDefinition = Configuration.GetTypeDefinition(typeof(OrderItem)).GetRelationEndPointDefinition(typeof(OrderItem).FullName + ".Order"); var endPointID = RelationEndPointID.CreateOpposite(sourceEndPointDefinition, null); var expected = RelationEndPointID.Create( null, Configuration.GetTypeDefinition(typeof(Order)).GetRelationEndPointDefinition(typeof(Order).FullName + ".OrderItems")); Assert.That(endPointID, Is.EqualTo(expected)); }
public void CreateSetCommand_OneMany() { var oldRelatedObject = DomainObjectMother.CreateFakeObject <Customer> (); var newRelatedObject = DomainObjectMother.CreateFakeObject <Customer> (); _endPointMock.Stub(stub => stub.Definition).Return(_orderCustomerEndPointDefinition); _endPointMock.Stub(stub => stub.GetDomainObject()).Return(_order); _endPointMock.Stub(stub => stub.IsNull).Return(false); _endPointMock.Stub(stub => stub.OppositeObjectID).Return(oldRelatedObject.ID); _endPointMock.Stub(stub => stub.GetOppositeObject()).Return(oldRelatedObject); var oldOppositeEndPointStub = MockRepository.GenerateStub <IVirtualEndPoint> (); var newOppositeEndPointStub = MockRepository.GenerateStub <IVirtualEndPoint> (); var oldOppositeEndPointID = RelationEndPointID.CreateOpposite(_orderCustomerEndPointDefinition, oldRelatedObject.ID); var newOppositeEndPointID = RelationEndPointID.CreateOpposite(_orderCustomerEndPointDefinition, newRelatedObject.ID); _endPointProviderStub .Stub(stub => stub.GetRelationEndPointWithLazyLoad(oldOppositeEndPointID)) .Return(oldOppositeEndPointStub); _endPointProviderStub .Stub(stub => stub.GetRelationEndPointWithLazyLoad(newOppositeEndPointID)) .Return(newOppositeEndPointStub); var command = _state.CreateSetCommand(_endPointMock, newRelatedObject, _fakeSetter); Assert.That(command, Is.TypeOf(typeof(RealObjectEndPointRegistrationCommandDecorator))); var decorator = (RealObjectEndPointRegistrationCommandDecorator)command; Assert.That(decorator.RealObjectEndPoint, Is.SameAs(_endPointMock)); Assert.That(decorator.OldRelatedEndPoint, Is.SameAs(oldOppositeEndPointStub)); Assert.That(decorator.NewRelatedEndPoint, Is.SameAs(newOppositeEndPointStub)); Assert.That(decorator.DecoratedCommand, Is.TypeOf(typeof(ObjectEndPointSetOneManyCommand))); var decoratedCommand = (ObjectEndPointSetOneManyCommand)decorator.DecoratedCommand; Assert.That(decoratedCommand, Is.TypeOf(typeof(ObjectEndPointSetOneManyCommand))); Assert.That(decoratedCommand.ModifiedEndPoint, Is.SameAs(_endPointMock)); Assert.That(decoratedCommand.NewRelatedObject, Is.SameAs(newRelatedObject)); Assert.That(decoratedCommand.OldRelatedObject, Is.SameAs(oldRelatedObject)); Assert.That(decoratedCommand.EndPointProvider, Is.SameAs(_endPointProviderStub)); Assert.That(GetOppositeObjectIDSetter(decoratedCommand), Is.SameAs(_fakeSetter)); }
private Order PrepareUnsynchronizedOrder(ObjectID orderID, ObjectID relatedCustomerID) { var unsynchronizedOrder = (Order)LifetimeService.GetObjectReference(TestableClientTransaction, orderID); var dataContainer = DataContainer.CreateForExisting( unsynchronizedOrder.ID, null, pd => pd.PropertyName.EndsWith("Customer") ? relatedCustomerID : pd.DefaultValue); dataContainer.SetDomainObject(unsynchronizedOrder); TestableClientTransaction.DataManager.RegisterDataContainer(dataContainer); var endPointID = RelationEndPointID.Resolve(unsynchronizedOrder, o => o.Customer); var endPoint = (IRealObjectEndPoint)TestableClientTransaction.DataManager.GetRelationEndPointWithoutLoading(endPointID); var oppositeID = RelationEndPointID.CreateOpposite(endPoint.Definition, relatedCustomerID); var oppositeEndPoint = TestableClientTransaction.DataManager.GetOrCreateVirtualEndPoint(oppositeID); oppositeEndPoint.EnsureDataComplete(); Assert.That(endPoint.IsSynchronized, Is.False); return(unsynchronizedOrder); }
public void CreateDeleteCommand_VirtualOpposite() { var realDefinition = RelationEndPointObjectMother.GetEndPointDefinition(typeof(OrderTicket), "Order"); _endPointMock.Stub(stub => stub.GetDomainObject()).Return(_order); _endPointMock.Stub(stub => stub.IsNull).Return(false); _endPointMock.Stub(stub => stub.Definition).Return(realDefinition); _endPointMock.Stub(stub => stub.OppositeObjectID).Return(DomainObjectIDs.Order1); _endPointMock.Replay(); var oldOppositeEndPointStub = MockRepository.GenerateStrictMock <IVirtualEndPoint>(); var newOppositeEndPointStub = MockRepository.GenerateStrictMock <IVirtualEndPoint> (); var oldOppositeEndPointID = RelationEndPointID.CreateOpposite(realDefinition, DomainObjectIDs.Order1); var newOppositeEndPointID = RelationEndPointID.CreateOpposite(realDefinition, null); _endPointProviderStub .Stub(stub => stub.GetRelationEndPointWithLazyLoad(oldOppositeEndPointID)) .Return(oldOppositeEndPointStub); _endPointProviderStub .Stub(stub => stub.GetRelationEndPointWithLazyLoad(newOppositeEndPointID)) .Return(newOppositeEndPointStub); var command = _state.CreateDeleteCommand(_endPointMock, _fakeNullSetter); Assert.That(command, Is.TypeOf(typeof(RealObjectEndPointRegistrationCommandDecorator))); var decorator = (RealObjectEndPointRegistrationCommandDecorator)command; Assert.That(decorator.RealObjectEndPoint, Is.SameAs(_endPointMock)); Assert.That(decorator.OldRelatedEndPoint, Is.SameAs(oldOppositeEndPointStub)); Assert.That(decorator.NewRelatedEndPoint, Is.SameAs(newOppositeEndPointStub)); Assert.That(decorator.DecoratedCommand, Is.TypeOf(typeof(ObjectEndPointDeleteCommand))); var decoratedCommand = (ObjectEndPointDeleteCommand)decorator.DecoratedCommand; Assert.That(decoratedCommand.DomainObject, Is.SameAs(_order)); Assert.That(decoratedCommand.ModifiedEndPoint, Is.SameAs(_endPointMock)); Assert.That(GetOppositeObjectNullSetter(decoratedCommand), Is.SameAs(_fakeNullSetter)); }
public void UnregisterEndPoint_RealEndPoint_PointingToNull() { var endPointMock = CreateRealObjectEndPointMock(null); endPointMock.Stub(stub => stub.HasChanged).Return(false); endPointMock.Expect(mock => mock.ResetSyncState()); endPointMock.Replay(); _map.AddEndPoint(endPointMock); var oppositeEndPointID = RelationEndPointID.CreateOpposite(endPointMock.Definition, null); _endPointProviderMock .Expect(mock => mock.GetOrCreateVirtualEndPoint(oppositeEndPointID)) .Return(new NullCollectionEndPoint(ClientTransaction.CreateRootTransaction(), oppositeEndPointID.Definition)); _endPointProviderMock.Replay(); _agent.UnregisterEndPoint(endPointMock, _map); endPointMock.VerifyAllExpectations(); _endPointProviderMock.VerifyAllExpectations(); Assert.That(_map, Has.No.Member(endPointMock)); }
private IVirtualEndPoint GetOppositeEndPoint(IRealObjectEndPoint sourceEndPoint, ObjectID oppositeObjectID) { var newOppositeID = RelationEndPointID.CreateOpposite(sourceEndPoint.Definition, oppositeObjectID); return((IVirtualEndPoint)_endPointProvider.GetRelationEndPointWithLazyLoad(newOppositeID)); }