public override void SetUp()
        {
            base.SetUp();

            _definition = Configuration.GetTypeDefinition(typeof(Order)).GetRelationEndPointDefinition(typeof(Order).FullName + ".OrderTicket");

            _virtualObjectEndPointMock = MockRepository.GenerateStrictMock <IVirtualObjectEndPoint> ();
            _dataManagerMock           = MockRepository.GenerateStrictMock <IVirtualObjectEndPointDataManager> ();
            _dataManagerMock.Stub(stub => stub.EndPointID).Return(RelationEndPointID.Create(DomainObjectIDs.Order1, _definition));
            _endPointProviderStub     = MockRepository.GenerateStub <IRelationEndPointProvider> ();
            _transactionEventSinkStub = MockRepository.GenerateStub <IClientTransactionEventSink>();

            _loadState = new CompleteVirtualObjectEndPointLoadState(_dataManagerMock, _endPointProviderStub, _transactionEventSinkStub);

            _relatedObject = DomainObjectMother.CreateFakeObject <OrderTicket> (DomainObjectIDs.OrderTicket1);

            _relatedEndPointStub = MockRepository.GenerateStub <IRealObjectEndPoint> ();
            _relatedEndPointStub.Stub(stub => stub.GetDomainObjectReference()).Return(_relatedObject);
            _relatedEndPointStub.Stub(stub => stub.ObjectID).Return(_relatedObject.ID);

            _relatedObject2 = DomainObjectMother.CreateFakeObject <OrderTicket> (DomainObjectIDs.OrderTicket2);

            _relatedEndPointStub2 = MockRepository.GenerateStub <IRealObjectEndPoint> ();
            _relatedEndPointStub2.Stub(stub => stub.ID).Return(RelationEndPointID.Create(_relatedObject2.ID, typeof(OrderTicket), "Order"));
            _relatedEndPointStub2.Stub(stub => stub.GetDomainObjectReference()).Return(_relatedObject2);
            _relatedEndPointStub2.Stub(stub => stub.ObjectID).Return(_relatedObject2.ID);

            _owningObject = DomainObjectMother.CreateFakeObject <Order> ();
        }
        public void SetDataFromSubTransaction()
        {
            var sourceDataManager = MockRepository.GenerateStub <IVirtualObjectEndPointDataManager>();
            var sourceLoadState   = new CompleteVirtualObjectEndPointLoadState(sourceDataManager, _endPointProviderStub, _transactionEventSinkStub);

            _dataManagerMock.Expect(mock => mock.SetDataFromSubTransaction(sourceDataManager, _endPointProviderStub));
            _dataManagerMock.Replay();

            _loadState.SetDataFromSubTransaction(_virtualObjectEndPointMock, sourceLoadState);

            _dataManagerMock.VerifyAllExpectations();
        }
        public void FlattenedSerializable()
        {
            var state = new CompleteVirtualObjectEndPointLoadState(
                new SerializableVirtualObjectEndPointDataManagerFake(),
                new SerializableRelationEndPointProviderFake(),
                new SerializableClientTransactionEventSinkFake());

            var oppositeEndPoint = new SerializableRealObjectEndPointFake(null, _relatedObject);

            AddUnsynchronizedOppositeEndPoint(state, oppositeEndPoint);

            var result = FlattenedSerializer.SerializeAndDeserialize(state);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.DataManager, Is.Not.Null);
            Assert.That(result.TransactionEventSink, Is.Not.Null);
            Assert.That(result.EndPointProvider, Is.Not.Null);
            Assert.That(result.UnsynchronizedOppositeEndPoints.Count, Is.EqualTo(1));
        }
        private void AddUnsynchronizedOppositeEndPoint(CompleteVirtualObjectEndPointLoadState loadState, IRealObjectEndPoint oppositeEndPoint)
        {
            var dictionary = (Dictionary <ObjectID, IRealObjectEndPoint>)PrivateInvoke.GetNonPublicField(loadState, "_unsynchronizedOppositeEndPoints");

            dictionary.Add(oppositeEndPoint.ObjectID, oppositeEndPoint);
        }