public CollectionEndPointSetCollectionCommand(
            ICollectionEndPoint modifiedEndPoint,
            DomainObjectCollection newCollection,
            IDomainObjectCollectionData modifiedCollectionData,
            ICollectionEndPointCollectionManager collectionEndPointCollectionManager,
            IClientTransactionEventSink transactionEventSink)
            : base(
                ArgumentUtility.CheckNotNull("modifiedEndPoint", modifiedEndPoint),
                null,
                null,
                ArgumentUtility.CheckNotNull("transactionEventSink", transactionEventSink))
        {
            ArgumentUtility.CheckNotNull("newCollection", newCollection);
            ArgumentUtility.CheckNotNull("modifiedCollectionData", modifiedCollectionData);
            ArgumentUtility.CheckNotNull("collectionEndPointCollectionManager", collectionEndPointCollectionManager);

            if (modifiedEndPoint.IsNull)
            {
                throw new ArgumentException("Modified end point is null, a NullEndPointModificationCommand is needed.", "modifiedEndPoint");
            }

            _newCollection          = newCollection;
            _modifiedCollectionData = modifiedCollectionData;
            _collectionEndPointCollectionManager = collectionEndPointCollectionManager;

            var oldOppositeObjects = ModifiedCollectionData;

            _removedObjects = oldOppositeObjects.Where(oldObject => !NewCollection.Contains(oldObject.ID)).ToArray();

            var newOppositeObjects = NewCollection.Cast <DomainObject> ();

            _addedObjects = newOppositeObjects.Where(newObject => !ModifiedCollectionData.ContainsObjectID(newObject.ID)).ToArray();
        }
        public override void SetUp()
        {
            base.SetUp();

            _owningOrder = DomainObjectIDs.Order1.GetObject <Order> ();
            _endPointID  = RelationEndPointID.Resolve(_owningOrder, o => o.OrderItems);

            _collectionEndPointMock = MockRepository.GenerateStrictMock <ICollectionEndPoint>();
            StubCollectionEndPoint(_collectionEndPointMock, TestableClientTransaction, _owningOrder);
            _virtualEndPointProviderStub = MockRepository.GenerateStub <IVirtualEndPointProvider> ();
            _virtualEndPointProviderStub
            .Stub(stub => stub.GetOrCreateVirtualEndPoint(_endPointID))
            .Return(_collectionEndPointMock);

            _endPointDataStub      = MockRepository.GenerateStub <IDomainObjectCollectionData>();
            _endPointDataDecorator = new ReadOnlyCollectionDataDecorator(_endPointDataStub);

            _commandStub       = MockRepository.GenerateStub <IDataManagementCommand>();
            _nestedCommandMock = MockRepository.GenerateMock <IDataManagementCommand> ();
            _nestedCommandMock.Stub(stub => stub.GetAllExceptions()).Return(new Exception[0]);
            _expandedCommandFake = new ExpandedCommand(_nestedCommandMock);

            _delegatingData = new EndPointDelegatingCollectionData(_endPointID, _virtualEndPointProviderStub);

            _orderItem1 = DomainObjectIDs.OrderItem1.GetObject <OrderItem>();
            _orderItem2 = DomainObjectIDs.OrderItem2.GetObject <OrderItem>();

            ClientTransactionScope.EnterNullScope(); // no active transaction
        }
예제 #3
0
            public ICollectionEndPointLoadState LoadEndPointAndGetNewState(ICollectionEndPoint endPoint)
            {
                var collectionEndPoint = ArgumentUtility.CheckNotNullAndType <CollectionEndPoint> ("endPoint", endPoint);

                _lazyLoader.LoadLazyCollectionEndPoint(endPoint.ID);
                return(collectionEndPoint._loadState);
            }
예제 #4
0
        public CollectionEndPointRemoveCommand(
            ICollectionEndPoint modifiedEndPoint,
            DomainObject removedObject,
            IDomainObjectCollectionData collectionData,
            IRelationEndPointProvider endPointProvider,
            IClientTransactionEventSink transactionEventSink)
            : base(
                ArgumentUtility.CheckNotNull("modifiedEndPoint", modifiedEndPoint),
                ArgumentUtility.CheckNotNull("removedObject", removedObject),
                null,
                ArgumentUtility.CheckNotNull("transactionEventSink", transactionEventSink))
        {
            ArgumentUtility.CheckNotNull("collectionData", collectionData);
            ArgumentUtility.CheckNotNull("endPointProvider", endPointProvider);

            if (modifiedEndPoint.IsNull)
            {
                throw new ArgumentException("Modified end point is null, a NullEndPointModificationCommand is needed.", "modifiedEndPoint");
            }

            _index = modifiedEndPoint.Collection.IndexOf(removedObject);
            _modifiedCollectionData = collectionData;
            _modifiedCollection     = modifiedEndPoint.Collection;
            _endPointProvider       = endPointProvider;
        }
    public StateUpdateRaisingCollectionEndPointDecorator (ICollectionEndPoint innerEndPoint, IVirtualEndPointStateUpdateListener listener)
    {
      ArgumentUtility.CheckNotNull ("innerEndPoint", innerEndPoint);
      ArgumentUtility.CheckNotNull ("listener", listener);

      _innerEndPoint = innerEndPoint;
      _listener = listener;
    }
        private void StubCollectionEndPoint(ICollectionEndPoint endPointStub, ClientTransaction clientTransaction, Order owningOrder)
        {
            endPointStub.Stub(stub => stub.ClientTransaction).Return(clientTransaction);
            var relationEndPointDefinition = owningOrder.ID.ClassDefinition.GetMandatoryRelationEndPointDefinition(typeof(Order).FullName + ".OrderItems");

            endPointStub.Stub(mock => mock.ObjectID).Return(owningOrder.ID);
            endPointStub.Stub(mock => mock.Definition).Return(relationEndPointDefinition);
            endPointStub.Stub(mock => mock.GetDomainObject()).Return(owningOrder);
            endPointStub.Stub(mock => mock.GetDomainObjectReference()).Return(owningOrder);
        }
        private void ExpectGetEndPoint(
            ObjectID objectID,
            IRelationEndPointDefinition endPointDefinition,
            IVirtualEndPointProvider relationEndPointProviderMock,
            ICollectionEndPoint collectionEndPointMock,
            bool expectedIsDataComplete)
        {
            var relationEndPointID = RelationEndPointID.Create(objectID, endPointDefinition);

            relationEndPointProviderMock.Expect(mock => mock.GetOrCreateVirtualEndPoint(relationEndPointID)).Return(collectionEndPointMock);
            collectionEndPointMock.Expect(mock => mock.IsDataComplete).Return(expectedIsDataComplete);
        }
        public override void SetUp()
        {
            base.SetUp();

            _endPointID        = RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order), "OrderItems");
            _listenerMock      = MockRepository.GenerateStrictMock <IVirtualEndPointStateUpdateListener> ();
            _innerEndPointMock = MockRepository.GenerateStrictMock <ICollectionEndPoint>();
            _innerEndPointMock.Stub(stub => stub.HasChangedFast).Return(false);
            _innerEndPointMock.Stub(stub => stub.ID).Return(_endPointID);

            _decorator           = new StateUpdateRaisingCollectionEndPointDecorator(_innerEndPointMock, _listenerMock);
            _decoratorTestHelper = new DecoratorTestHelper <ICollectionEndPoint> (_decorator, _innerEndPointMock);
        }
 public CollectionEndPointReplaceSameCommand(
     ICollectionEndPoint modifiedEndPoint,
     DomainObject selfReplacedObject,
     IClientTransactionEventSink transactionEventSink)
     : base(
         ArgumentUtility.CheckNotNull("modifiedEndPoint", modifiedEndPoint),
         ArgumentUtility.CheckNotNull("selfReplacedObject", selfReplacedObject),
         ArgumentUtility.CheckNotNull("selfReplacedObject", selfReplacedObject),
         ArgumentUtility.CheckNotNull("transactionEventSink", transactionEventSink))
 {
     if (modifiedEndPoint.IsNull)
     {
         throw new ArgumentException("Modified end point is null, a NullEndPointModificationCommand is needed.", "modifiedEndPoint");
     }
 }
예제 #10
0
        public CollectionEndPointDeleteCommand(
            ICollectionEndPoint modifiedEndPoint,
            IDomainObjectCollectionData collectionData,
            IClientTransactionEventSink transactionEventSink)
            : base(
                ArgumentUtility.CheckNotNull("modifiedEndPoint", modifiedEndPoint),
                null,
                null,
                ArgumentUtility.CheckNotNull("transactionEventSink", transactionEventSink))
        {
            if (modifiedEndPoint.IsNull)
            {
                throw new ArgumentException("Modified end point is null, a NullEndPointModificationCommand is needed.", "modifiedEndPoint");
            }

            _modifiedCollectionData = collectionData;
            _modifiedCollection     = modifiedEndPoint.Collection;
        }
        public override void SetUp()
        {
            base.SetUp();

            _definition = Configuration.GetTypeDefinition(typeof(Customer)).GetRelationEndPointDefinition(typeof(Customer).FullName + ".Orders");

            _collectionEndPointMock = MockRepository.GenerateStrictMock <ICollectionEndPoint>();
            _dataManagerMock        = MockRepository.GenerateStrictMock <ICollectionEndPointDataManager>();
            _dataManagerMock.Stub(stub => stub.EndPointID).Return(RelationEndPointID.Create(DomainObjectIDs.Customer1, _definition));
            _endPointProviderStub     = MockRepository.GenerateStub <IRelationEndPointProvider> ();
            _transactionEventSinkStub = MockRepository.GenerateStub <IClientTransactionEventSink> ();
            _eventRaiserMock          = MockRepository.GenerateStrictMock <IDomainObjectCollectionEventRaiser>();

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

            _relatedObject       = DomainObjectMother.CreateFakeObject <Order> (DomainObjectIDs.Order1);
            _relatedEndPointStub = MockRepository.GenerateStub <IRealObjectEndPoint> ();
            _relatedEndPointStub.Stub(stub => stub.GetDomainObjectReference()).Return(_relatedObject);
            _relatedEndPointStub.Stub(stub => stub.ObjectID).Return(_relatedObject.ID);
            _owningObject          = DomainObjectMother.CreateFakeObject <Customer>();
            _collectionManagerStub = MockRepository.GenerateStub <ICollectionEndPointCollectionManager> ();
        }
예제 #12
0
        public override void SetUp()
        {
            base.SetUp();

            _endPointID             = RelationEndPointID.Create(DomainObjectIDs.Customer1, typeof(Customer), "Orders");
            _collectionEndPointMock = MockRepository.GenerateStrictMock <ICollectionEndPoint> ();

            _endPointLoaderMock     = MockRepository.GenerateStrictMock <IncompleteCollectionEndPointLoadState.IEndPointLoader> ();
            _dataManagerFactoryStub = MockRepository.GenerateStub <ICollectionEndPointDataManagerFactory> ();

            var dataManagerStub = MockRepository.GenerateStub <ICollectionEndPointDataManager> ();

            dataManagerStub.Stub(stub => stub.HasDataChanged()).Return(false);

            _loadState = new IncompleteCollectionEndPointLoadState(_endPointLoaderMock, _dataManagerFactoryStub);

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

            _relatedObject2       = DomainObjectMother.CreateFakeObject <Order> ();
            _relatedEndPointStub2 = MockRepository.GenerateStub <IRealObjectEndPoint> ();
            _relatedEndPointStub2.Stub(stub => stub.ObjectID).Return(_relatedObject2.ID);
        }
 public StateUpdateRaisingCollectionEndPointDecorator (FlattenedDeserializationInfo info)
 {
   _innerEndPoint = info.GetValue<ICollectionEndPoint>();
   _listener = info.GetValueForHandle<IVirtualEndPointStateUpdateListener>();
 }
 public ConstantChangeStateAsserter (ICollectionEndPoint innerEndPoint)
 {
   _changeStateBefore = innerEndPoint.HasChangedFast;
   _innerEndPoint = innerEndPoint;
 }