public CollectionEndPointDataManagerFactory(
            ICollectionEndPointChangeDetectionStrategy changeDetectionStrategy)
        {
            ArgumentUtility.CheckNotNull("changeDetectionStrategy", changeDetectionStrategy);

            _changeDetectionStrategy = changeDetectionStrategy;
        }
        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;
        }
Example #3
0
        public override void SetUp()
        {
            base.SetUp();

            _changeDetectionStrategy = MockRepository.GenerateStub <ICollectionEndPointChangeDetectionStrategy>();

            _factory = new CollectionEndPointDataManagerFactory(_changeDetectionStrategy);
        }
Example #4
0
        public bool HasChanged(ICollectionEndPointChangeDetectionStrategy strategy)
        {
            if (!_isCacheUpToDate)
            {
                bool hasChanged = CalculateHasChangedFlag(strategy);
                SetCachedHasChangedFlag(hasChanged);
            }

            return(_cachedHasChangedFlag);
        }
Example #5
0
        public override void SetUp()
        {
            base.SetUp();

            _domainObject = DomainObjectMother.CreateFakeObject <Order> ();

            _wrappedData           = new DomainObjectCollectionData(new[] { _domainObject });
            _decoratorWithRealData = new ChangeCachingCollectionDataDecorator(_wrappedData);

            _strategyStrictMock = new MockRepository().StrictMock <ICollectionEndPointChangeDetectionStrategy> ();
        }
        public CollectionEndPointDataManager(RelationEndPointID endPointID, ICollectionEndPointChangeDetectionStrategy changeDetectionStrategy)
        {
            ArgumentUtility.CheckNotNull("endPointID", endPointID);
            ArgumentUtility.CheckNotNull("changeDetectionStrategy", changeDetectionStrategy);

            _endPointID = endPointID;
            _changeDetectionStrategy = changeDetectionStrategy;

            var wrappedData = new DomainObjectCollectionData();

            _changeCachingCollectionData = new ChangeCachingCollectionDataDecorator(wrappedData);

            _originalOppositeEndPoints    = new HashSet <IRealObjectEndPoint>();
            _originalItemsWithoutEndPoint = new HashSet <DomainObject>();
            _currentOppositeEndPoints     = new Dictionary <ObjectID, IRealObjectEndPoint>();
        }
Example #7
0
        private bool CalculateHasChangedFlag(ICollectionEndPointChangeDetectionStrategy strategy)
        {
            // If the original data still points to this collection, we don't ask the strategy - we know we haven't changed.
            if (!_originalData.IsContentsCopied)
            {
                return(false);
            }

            // If the original data has a different number of items, we don't ask the strategy - we know we have changed.
            if (_originalData.Count != Count)
            {
                return(true);
            }

            return(strategy.HasDataChanged(this, OriginalData));
        }
        // ReSharper disable UnusedMember.Local
        private CollectionEndPointDataManager(FlattenedDeserializationInfo info)
        {
            ArgumentUtility.CheckNotNull("info", info);

            _endPointID = info.GetValueForHandle <RelationEndPointID>();
            _changeDetectionStrategy = info.GetValueForHandle <ICollectionEndPointChangeDetectionStrategy>();

            _changeCachingCollectionData = info.GetValue <ChangeCachingCollectionDataDecorator>();

            _originalOppositeEndPoints = new HashSet <IRealObjectEndPoint>();
            info.FillCollection(_originalOppositeEndPoints);

            _originalItemsWithoutEndPoint = new HashSet <DomainObject>();
            info.FillCollection(_originalItemsWithoutEndPoint);

            var currentOppositeEndPoints = new List <IRealObjectEndPoint>();

            info.FillCollection(currentOppositeEndPoints);
            _currentOppositeEndPoints = currentOppositeEndPoints.ToDictionary(ep => ep.ObjectID);
        }