public void SetDataFromSubTransaction()
        {
            var sourceOppositeEndPointStub = MockRepository.GenerateStub <IRealObjectEndPoint> ();

            sourceOppositeEndPointStub.Stub(stub => stub.ID).Return(_domainObjectEndPoint2.ID);
            sourceOppositeEndPointStub.Stub(stub => stub.ObjectID).Return(_domainObjectEndPoint2.ObjectID);

            _dataManager.CollectionData.Add(_domainObject1);
            _dataManager.RegisterCurrentOppositeEndPoint(_domainObjectEndPoint1);

            var sourceDataManager = new CollectionEndPointDataManager(_endPointID, MockRepository.GenerateStub <ICollectionEndPointChangeDetectionStrategy>());

            sourceDataManager.CollectionData.Add(_domainObject2);
            sourceDataManager.RegisterCurrentOppositeEndPoint(sourceOppositeEndPointStub);

            var endPointProviderStub = MockRepository.GenerateStub <IRelationEndPointProvider> ();

            endPointProviderStub
            .Stub(stub => stub.GetRelationEndPointWithoutLoading(sourceOppositeEndPointStub.ID))
            .Return(_domainObjectEndPoint2);

            _dataManager.SetDataFromSubTransaction(sourceDataManager, endPointProviderStub);

            Assert.That(_dataManager.CollectionData.ToArray(), Is.EqualTo(new[] { _domainObject2 }));
            Assert.That(_dataManager.CurrentOppositeEndPoints, Is.EquivalentTo(new[] { _domainObjectEndPoint2 }));
        }
        public override void SetUp()
        {
            base.SetUp();

            _endPointID = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Customer1, "Orders");
            _changeDetectionStrategyMock = MockRepository.GenerateStrictMock <ICollectionEndPointChangeDetectionStrategy> ();

            _domainObject1 = DomainObjectMother.CreateFakeObject <Order> (DomainObjectIDs.Order1);
            _domainObject2 = DomainObjectMother.CreateFakeObject <Order> (DomainObjectIDs.Order3);
            _domainObject3 = DomainObjectMother.CreateFakeObject <Order> (DomainObjectIDs.Order4);
            _domainObject4 = DomainObjectMother.CreateFakeObject <Order> (DomainObjectIDs.Order5);

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

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

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

            _dataManager = new CollectionEndPointDataManager(_endPointID, _changeDetectionStrategyMock);

            _comparison123 = Compare123;
        }
        public void Initialization()
        {
            var dataManager = new CollectionEndPointDataManager(_endPointID, _changeDetectionStrategyMock);

            Assert.That(dataManager.CollectionData, Is.TypeOf(typeof(ChangeCachingCollectionDataDecorator)));
            Assert.That(dataManager.CollectionData.ToArray(), Is.Empty);
            Assert.That(dataManager.OriginalOppositeEndPoints, Is.Empty);
        }
        public void FlattenedSerializable()
        {
            var changeDetectionStrategy = new SerializableCollectionEndPointChangeDetectionStrategyFake();
            var data = new CollectionEndPointDataManager(_endPointID, changeDetectionStrategy);

            var endPointFake = new SerializableRealObjectEndPointFake(null, _domainObject1);

            data.RegisterOriginalOppositeEndPoint(endPointFake);
            data.RegisterOriginalItemWithoutEndPoint(_domainObject2);

            var deserializedInstance = FlattenedSerializer.SerializeAndDeserialize(data);

            Assert.That(deserializedInstance.EndPointID, Is.Not.Null);
            Assert.That(deserializedInstance.ChangeDetectionStrategy, Is.Not.Null);
            Assert.That(deserializedInstance.CollectionData.Count, Is.EqualTo(2));
            Assert.That(deserializedInstance.OriginalCollectionData.Count, Is.EqualTo(2));
            Assert.That(deserializedInstance.OriginalOppositeEndPoints.Length, Is.EqualTo(1));
            Assert.That(deserializedInstance.OriginalItemsWithoutEndPoints.Length, Is.EqualTo(1));
            Assert.That(deserializedInstance.CurrentOppositeEndPoints.Length, Is.EqualTo(1));
        }