コード例 #1
0
        public override void SetUp()
        {
            base.SetUp();

            _transaction       = ClientTransactionObjectMother.Create();
            _eventSinkWithMock = MockRepository.GenerateStrictMock <IClientTransactionEventSink>();
            _invalidDomainObjectManagerMock = MockRepository.GenerateStrictMock <IInvalidDomainObjectManager> ();
            _dataManagerMock = MockRepository.GenerateStrictMock <IDataManager> ();
            _enlistedDomainObjectManagerMock = MockRepository.GenerateStrictMock <IEnlistedDomainObjectManager> ();
            _persistenceStrategyMock         = MockRepository.GenerateStrictMock <IPersistenceStrategy>();

            _agent = new ObjectLifetimeAgent(
                _transaction,
                _eventSinkWithMock,
                _invalidDomainObjectManagerMock,
                _dataManagerMock,
                _enlistedDomainObjectManagerMock,
                _persistenceStrategyMock);

            _objectID1      = DomainObjectIDs.Order1;
            _domainObject1  = DomainObjectMother.CreateFakeObject(_objectID1);
            _dataContainer1 = DataContainerObjectMother.CreateExisting(_domainObject1);

            _objectID2      = DomainObjectIDs.Order3;
            _domainObject2  = DomainObjectMother.CreateFakeObject(_objectID2);
            _dataContainer2 = DataContainerObjectMother.CreateExisting(_domainObject2);

            _domainObjectCreatorMock       = MockRepository.GenerateStrictMock <IDomainObjectCreator>();
            _typeDefinitionWithCreatorMock = ClassDefinitionObjectMother.CreateClassDefinitionWithTable(
                TestDomainStorageProviderDefinition,
                classType: typeof(OrderItem),
                instanceCreator: _domainObjectCreatorMock);

            _objectIDWithCreatorMock = new ObjectID(_typeDefinitionWithCreatorMock, Guid.NewGuid());
        }
        public void CreateAddCommand()
        {
            var fakeCollectionData =
                new DomainObjectCollectionData(new[] { DomainObjectMother.CreateFakeObject <Order> (), DomainObjectMother.CreateFakeObject <Order> () });

            _dataManagerMock.Stub(stub => stub.CollectionData).Return(fakeCollectionData);
            _dataManagerMock.Stub(stub => stub.ContainsOriginalItemWithoutEndPoint(_relatedObject)).Return(false);

            var fakeCollection = new DomainObjectCollection();

            _collectionEndPointMock.Stub(mock => mock.IsNull).Return(false);
            _collectionEndPointMock.Stub(mock => mock.Collection).Return(fakeCollection);
            _collectionEndPointMock.Stub(mock => mock.GetDomainObject()).Return(_owningObject);

            var command = (RelationEndPointModificationCommand)_loadState.CreateAddCommand(_collectionEndPointMock, _relatedObject);

            Assert.That(command, Is.InstanceOf(typeof(CollectionEndPointInsertCommand)));
            Assert.That(command.ModifiedEndPoint, Is.SameAs(_collectionEndPointMock));
            Assert.That(command.NewRelatedObject, Is.SameAs(_relatedObject));
            Assert.That(((CollectionEndPointInsertCommand)command).Index, Is.EqualTo(2));

            Assert.That(((CollectionEndPointInsertCommand)command).ModifiedCollectionData, Is.SameAs(fakeCollectionData));
            Assert.That(((CollectionEndPointInsertCommand)command).ModifiedCollection, Is.SameAs(fakeCollection));
            Assert.That(((CollectionEndPointInsertCommand)command).EndPointProvider, Is.SameAs(_endPointProviderStub));
        }
コード例 #3
0
        private DataContainer CreateExistingDataContainer()
        {
            var dataContainer = DataContainer.CreateForExisting(new ObjectID(typeof(Order), Guid.NewGuid()), null, pd => pd.DefaultValue);

            dataContainer.SetDomainObject(DomainObjectMother.CreateFakeObject <Order> (dataContainer.ID));
            return(dataContainer);
        }
コード例 #4
0
        private DataContainer CreateNewDataContainer()
        {
            var dataContainer = DataContainer.CreateNew(new ObjectID(typeof(Order), Guid.NewGuid()));

            dataContainer.SetDomainObject(DomainObjectMother.CreateFakeObject <Order> (dataContainer.ID));
            return(dataContainer);
        }
        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 GroupAndRegisterRelatedObjects_PropertyOnDerivedType()
        {
            var endPointDefinition = GetEndPointDefinition(typeof(Folder), "FileSystemItems");

            var originatingFolder     = DomainObjectMother.CreateFakeObject <Folder>();
            var originatingFolderData = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(originatingFolder);

            var originatingFile     = DomainObjectMother.CreateFakeObject <File>();
            var originatingFileData = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(originatingFile);

            var fetchedFile     = DomainObjectMother.CreateFakeObject <File>();
            var fetchedFileData = LoadedObjectDataObjectMother.CreateLoadedObjectDataWithDataSourceData(fetchedFile);

            fetchedFileData.DataSourceData.SetValue(GetPropertyDefinition(typeof(FileSystemItem), "ParentFolder"), originatingFolder.ID);

            var endPointMock = MockRepository.GenerateStrictMock <ICollectionEndPoint> ();

            ExpectGetEndPoint(originatingFolder.ID, endPointDefinition, _virtualEndPointProviderMock, endPointMock, false);
            endPointMock.Expect(mock => mock.MarkDataComplete(new DomainObject[] { fetchedFile }));

            _virtualEndPointProviderMock.Replay();
            endPointMock.Replay();

            _agent.GroupAndRegisterRelatedObjects(
                endPointDefinition,
                new[] { originatingFolderData, originatingFileData },
                new[] { fetchedFileData });

            _virtualEndPointProviderMock.VerifyAllExpectations();
            endPointMock.VerifyAllExpectations();
        }
コード例 #7
0
        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 RegisterEndPoint_RealEndPoint_PointingToNonNull_OppositeObjectEndPoint()
        {
            var objectReference = DomainObjectMother.CreateFakeObject <OrderItem> ();
            var endPointMock    = CreateRealObjectEndPointMock(_virtualEndPointID.ObjectID);

            endPointMock.Stub(stub => stub.GetDomainObjectReference()).Return(objectReference);
            endPointMock.Replay();

            var oppositeEndPointMock = MockRepository.GenerateStrictMock <IVirtualObjectEndPoint> ();

            oppositeEndPointMock.Expect(mock => mock.RegisterOriginalOppositeEndPoint(endPointMock));
            oppositeEndPointMock.Replay();

            _endPointProviderMock
            .Expect(mock => mock.GetOrCreateVirtualEndPoint(_virtualEndPointID))
            .Return(oppositeEndPointMock);
            _endPointProviderMock.Replay();

            _agent.RegisterEndPoint(endPointMock, _map);

            oppositeEndPointMock.AssertWasNotCalled(mock => mock.MarkDataComplete(objectReference));
            endPointMock.VerifyAllExpectations();
            _endPointProviderMock.VerifyAllExpectations();
            oppositeEndPointMock.VerifyAllExpectations();
            Assert.That(_map, Has.Member(endPointMock));
        }
        public void MarkDataComplete_ItemWithEndPoint()
        {
            var item = DomainObjectMother.CreateFakeObject <Order> ();

            var oppositeEndPointMock = MockRepository.GenerateStrictMock <IRealObjectEndPoint> ();

            oppositeEndPointMock.Stub(stub => stub.ObjectID).Return(item.ID);
            oppositeEndPointMock.Stub(stub => stub.ResetSyncState());
            oppositeEndPointMock.Expect(mock => mock.MarkSynchronized());
            oppositeEndPointMock.Replay();

            AddOriginalOppositeEndPoint(_loadState, oppositeEndPointMock);

            _virtualObjectEndPointMock.Stub(stub => stub.ID).Return(_endPointID);
            _virtualObjectEndPointMock.Replay();

            var newManagerMock = MockRepository.GenerateMock <IVirtualObjectEndPointDataManager> ();

            using (newManagerMock.GetMockRepository().Ordered())
            {
                newManagerMock.Expect(mock => mock.RegisterOriginalOppositeEndPoint(oppositeEndPointMock));
            }
            newManagerMock.Replay();

            _dataManagerFactoryStub.Stub(stub => stub.CreateEndPointDataManager(_endPointID)).Return(newManagerMock);

            _loadState.MarkDataComplete(_virtualObjectEndPointMock, item, dataManager => { });

            newManagerMock.VerifyAllExpectations();
            oppositeEndPointMock.VerifyAllExpectations();
            _virtualObjectEndPointMock.AssertWasNotCalled(mock => mock.RegisterOriginalOppositeEndPoint(Arg <IRealObjectEndPoint> .Is.Anything));
        }
コード例 #10
0
        public override void SetUp()
        {
            base.SetUp();

            _registrationAgentMock = MockRepository.GenerateStrictMock <IFetchedRelationDataRegistrationAgent>();
            _fetchResultLoaderMock = MockRepository.GenerateStrictMock <IFetchEnabledObjectLoader>();

            _eagerFetcher = new EagerFetcher(_registrationAgentMock);

            _fetchQueryStub1 = MockRepository.GenerateStub <IQuery> ();
            _fetchQueryStub2 = MockRepository.GenerateStub <IQuery> ();

            _orderTicketEndPointDefinition      = GetEndPointDefinition(typeof(Order), "OrderTicket");
            _customerEndPointDefinition         = GetEndPointDefinition(typeof(Order), "Customer");
            _industrialSectorEndPointDefinition = GetEndPointDefinition(typeof(Company), "IndustrialSector");

            _originatingOrder1 = DomainObjectMother.CreateFakeObject <Order>();
            _originatingOrder2 = DomainObjectMother.CreateFakeObject <Order>();

            _originatingOrderData1 = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(_originatingOrder1);
            _originatingOrderData2 = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(_originatingOrder2);

            _fetchedOrderItem1 = DomainObjectMother.CreateFakeObject <OrderItem>();
            _fetchedOrderItem2 = DomainObjectMother.CreateFakeObject <OrderItem>();
            _fetchedOrderItem3 = DomainObjectMother.CreateFakeObject <OrderItem>();

            _fetchedOrderItemData1 = LoadedObjectDataObjectMother.CreateLoadedObjectDataWithDataSourceData(_fetchedOrderItem1);
            _fetchedOrderItemData2 = LoadedObjectDataObjectMother.CreateLoadedObjectDataWithDataSourceData(_fetchedOrderItem2);
            _fetchedOrderItemData3 = LoadedObjectDataObjectMother.CreateLoadedObjectDataWithDataSourceData(_fetchedOrderItem3);

            _fetchedCustomer     = DomainObjectMother.CreateFakeObject <Customer>();
            _fetchedCustomerData = LoadedObjectDataObjectMother.CreateLoadedObjectDataWithDataSourceData(_fetchedCustomer);

            _pendingRegistrationCollector = new LoadedObjectDataPendingRegistrationCollector();
        }
コード例 #11
0
        public void GroupAndRegisterRelatedObjects_PropertyOnBaseType()
        {
            var endPointDefinition = GetEndPointDefinition(typeof(Company), "Ceo");

            var originatingSupplier     = DomainObjectMother.CreateFakeObject <Supplier>();
            var originatingSupplierData = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(originatingSupplier);

            var fetchedCeo     = DomainObjectMother.CreateFakeObject <Ceo>();
            var fetchedCeoData = LoadedObjectDataObjectMother.CreateLoadedObjectDataWithDataSourceData(fetchedCeo);

            fetchedCeoData.DataSourceData.SetValue(GetPropertyDefinition(typeof(Ceo), "Company"), originatingSupplier.ID);

            _loadedDataContainerProviderStub.Stub(stub => stub.GetDataContainerWithoutLoading(fetchedCeo.ID)).Return(fetchedCeoData.DataSourceData);

            var endPointMock = MockRepository.GenerateStrictMock <IVirtualObjectEndPoint> ();

            ExpectGetEndPoint(originatingSupplier.ID, endPointDefinition, _virtualEndPointProviderMock, endPointMock, false);
            endPointMock.Expect(mock => mock.MarkDataComplete(fetchedCeo));

            _virtualEndPointProviderMock.Replay();
            endPointMock.Replay();

            _agent.GroupAndRegisterRelatedObjects(
                endPointDefinition,
                new[] { originatingSupplierData },
                new[] { fetchedCeoData });

            _virtualEndPointProviderMock.VerifyAllExpectations();
            endPointMock.VerifyAllExpectations();
        }
コード例 #12
0
        public void GetLoadedObject_Known()
        {
            var dataContainer = DataContainer.CreateForExisting(DomainObjectIDs.Order1, null, pd => pd.DefaultValue);

            dataContainer.SetDomainObject(DomainObjectMother.CreateFakeObject <Order> (dataContainer.ID));
            DataContainerTestHelper.SetClientTransaction(dataContainer, ClientTransaction.CreateRootTransaction());

            _invalidDomainObjectManagerMock
            .Stub(mock => mock.IsInvalid(DomainObjectIDs.Order1))
            .Return(false);
            _invalidDomainObjectManagerMock.Replay();

            _loadedDataContainerProviderMock
            .Expect(mock => mock.GetDataContainerWithoutLoading(DomainObjectIDs.Order1))
            .Return(dataContainer);
            _loadedDataContainerProviderMock.Replay();

            var loadedObject = _dataProvider.GetLoadedObject(DomainObjectIDs.Order1);

            _loadedDataContainerProviderMock.VerifyAllExpectations();
            Assert.That(
                loadedObject,
                Is.TypeOf <AlreadyExistingLoadedObjectData> ()
                .With.Property((AlreadyExistingLoadedObjectData obj) => obj.ExistingDataContainer).SameAs(dataContainer));
        }
コード例 #13
0
        public override void SetUp()
        {
            base.SetUp();

            _persistenceStrategyMock      = MockRepository.GenerateStrictMock <IPersistenceStrategy> ();
            _objectLoaderMock             = MockRepository.GenerateStrictMock <IObjectLoader> ();
            _transactionEventSinkWithMock = MockRepository.GenerateStrictMock <IClientTransactionEventSink>();

            _queryManager = new QueryManager(
                _persistenceStrategyMock,
                _objectLoaderMock,
                _transactionEventSinkWithMock);

            _collectionQuery = QueryFactory.CreateQueryFromConfiguration("OrderQuery");
            _scalarQuery     = QueryFactory.CreateQueryFromConfiguration("OrderNoSumByCustomerNameQuery");
            _customQuery     = QueryFactory.CreateQueryFromConfiguration("CustomQuery");

            _fakeOrder1 = DomainObjectMother.CreateFakeObject <Order> ();
            _fakeOrder2 = DomainObjectMother.CreateFakeObject <Order>();

            _loadedObjectDataStub1 = MockRepository.GenerateStub <ILoadedObjectData> ();
            _loadedObjectDataStub2 = MockRepository.GenerateStub <ILoadedObjectData> ();

            _rowConversion = qrr => qrr.GetRawValue(0);
        }
コード例 #14
0
        public void DelegatingMembers()
        {
            var objectID              = DomainObjectIDs.Order1;
            var dataContainer         = DataContainer.CreateNew(objectID);
            var relationEndPointID    = RelationEndPointID.Create(objectID, typeof(Order), "OrderTicket");
            var virtualEndPoint       = MockRepository.GenerateStub <IVirtualEndPoint>();
            var domainObject          = DomainObjectMother.CreateFakeObject <Order>();
            var persistableData       = new PersistableData(domainObject, StateType.Unchanged, dataContainer, new IRelationEndPoint[0]);
            var dataManagementCommand = MockRepository.GenerateStub <IDataManagementCommand> ();
            var randomBoolean         = BooleanObjectMother.GetRandomBoolean();

            CheckDelegation(dm => dm.GetOrCreateVirtualEndPoint(relationEndPointID), virtualEndPoint);
            CheckDelegation(dm => dm.GetRelationEndPointWithLazyLoad(relationEndPointID), virtualEndPoint);
            CheckDelegation(dm => dm.GetRelationEndPointWithoutLoading(relationEndPointID), virtualEndPoint);
            CheckDelegation(dm => dm.GetDataContainerWithoutLoading(objectID), dataContainer);
            CheckDelegation(dm => dm.RegisterDataContainer(dataContainer));
            CheckDelegation(dm => dm.Discard(dataContainer));
            CheckDelegation(dm => dm.DataContainers, MockRepository.GenerateStub <IDataContainerMapReadOnlyView> ());
            CheckDelegation(dm => dm.RelationEndPoints, MockRepository.GenerateStub <IRelationEndPointMapReadOnlyView> ());
            CheckDelegation(dm => dm.GetState(objectID), StateType.Deleted);
            CheckDelegation(dm => dm.GetDataContainerWithLazyLoad(objectID, randomBoolean), dataContainer);
            CheckDelegation(dm => dm.GetDataContainersWithLazyLoad(new[] { objectID }, true), new[] { dataContainer });
            CheckDelegation(dm => dm.GetLoadedDataByObjectState(StateType.Unchanged), new[] { persistableData });
            CheckDelegation(dm => dm.MarkInvalid(domainObject));
            CheckDelegation(dm => dm.MarkNotInvalid(objectID));
            CheckDelegation(dm => dm.Commit());
            CheckDelegation(dm => dm.Rollback());
            CheckDelegation(dm => dm.CreateDeleteCommand(domainObject), dataManagementCommand);
            CheckDelegation(dm => dm.CreateUnloadCommand(new[] { objectID }), dataManagementCommand);
            CheckDelegation(dm => dm.CreateUnloadVirtualEndPointsCommand(new[] { relationEndPointID }), dataManagementCommand);
            CheckDelegation(dm => dm.CreateUnloadAllCommand(), dataManagementCommand);
            CheckDelegation(dm => dm.LoadLazyCollectionEndPoint(relationEndPointID));
            CheckDelegation(dm => dm.LoadLazyVirtualObjectEndPoint(relationEndPointID));
            CheckDelegation(dm => dm.LoadLazyDataContainer(objectID), dataContainer);
        }
        public void CreateReplaceCommand()
        {
            var oldRelatedObject   = DomainObjectMother.CreateFakeObject <Order> ();
            var fakeCollectionData = new DomainObjectCollectionData(new[] { oldRelatedObject });

            _dataManagerMock.Stub(stub => stub.CollectionData).Return(fakeCollectionData);
            _dataManagerMock.Stub(stub => stub.ContainsOriginalItemWithoutEndPoint(_relatedObject)).Return(false);
            _dataManagerMock.Stub(stub => stub.ContainsOriginalItemWithoutEndPoint(oldRelatedObject)).Return(false);

            var fakeCollection = new DomainObjectCollection();

            _collectionEndPointMock.Stub(mock => mock.IsNull).Return(false);
            _collectionEndPointMock.Stub(mock => mock.Collection).Return(fakeCollection);
            _collectionEndPointMock.Stub(mock => mock.GetDomainObject()).Return(_owningObject);

            var command = (RelationEndPointModificationCommand)_loadState.CreateReplaceCommand(_collectionEndPointMock, 0, _relatedObject);

            Assert.That(command, Is.InstanceOf(typeof(CollectionEndPointReplaceCommand)));
            Assert.That(command.ModifiedEndPoint, Is.SameAs(_collectionEndPointMock));
            Assert.That(command.OldRelatedObject, Is.SameAs(oldRelatedObject));
            Assert.That(command.NewRelatedObject, Is.SameAs(_relatedObject));
            Assert.That(command.TransactionEventSink, Is.SameAs(_transactionEventSinkStub));

            Assert.That(((CollectionEndPointReplaceCommand)command).ModifiedCollectionData, Is.SameAs(fakeCollectionData));
            Assert.That(((CollectionEndPointReplaceCommand)command).ModifiedCollection, Is.SameAs(fakeCollection));
        }
コード例 #16
0
        public void RegisterEndPoint_RealEndPoint_PointingToNonNull_OppositeObjectEndPoint_VirtualEndPointNotYetComplete()
        {
            var objectReference = DomainObjectMother.CreateFakeObject <OrderItem> ();

            var endPointMock = CreateRealObjectEndPointMock(DomainObjectIDs.OrderTicket1, "Order", DomainObjectIDs.Order1);

            endPointMock.Stub(stub => stub.GetDomainObjectReference()).Return(objectReference);

            var oppositeEndPointMock = MockRepository.GenerateStrictMock <IVirtualObjectEndPoint> ();

            oppositeEndPointMock.Stub(stub => stub.IsDataComplete).Return(false);
            oppositeEndPointMock.Expect(mock => mock.RegisterOriginalOppositeEndPoint(endPointMock));
            oppositeEndPointMock.Expect(mock => mock.MarkDataComplete(objectReference));
            oppositeEndPointMock.Replay();

            var oppositeEndPointID = RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order), "OrderTicket");

            _virtualEndPointProviderMock
            .Expect(mock => mock.GetOrCreateVirtualEndPoint(oppositeEndPointID))
            .Return(oppositeEndPointMock);
            _virtualEndPointProviderMock.Replay();

            _agent.RegisterEndPoint(endPointMock, _map);

            endPointMock.VerifyAllExpectations();
            _virtualEndPointProviderMock.VerifyAllExpectations();
            oppositeEndPointMock.VerifyAllExpectations();
            Assert.That(_map, Has.Member(endPointMock));
        }
コード例 #17
0
        public override void SetUp()
        {
            base.SetUp();

            _invalidObjectReference = DomainObjectMother.CreateFakeObject <Order>();
            _loadedObjectData       = new InvalidLoadedObjectData(_invalidObjectReference);
        }
コード例 #18
0
        public void LoadObjectData_Single()
        {
            var objectID            = DomainObjectIDs.Order1;
            var parentObject        = DomainObjectMother.CreateFakeObject <Order> (objectID);
            var parentDataContainer = CreateChangedDataContainer(objectID, 4711, _orderNumberPropertyDefinition, 17);

            CheckDataContainer(parentDataContainer, objectID, 4711, StateType.Changed, _orderNumberPropertyDefinition, 17, 0, true);

            var parentEventListenerMock = MockRepository.GenerateStrictMock <IDataContainerEventListener>();

            parentDataContainer.SetEventListener(parentEventListenerMock);

            _parentTransactionContextMock
            .Expect(mock => mock.TryGetObject(objectID))
            .Return(parentObject);
            _parentTransactionContextMock
            .Expect(mock => mock.GetDataContainerWithLazyLoad(objectID, true))
            .Return(parentDataContainer);

            var result = _persistenceStrategy.LoadObjectData(objectID);

            _parentTransactionContextMock.VerifyAllExpectations();
            parentEventListenerMock.AssertWasNotCalled(
                mock => mock.PropertyValueReading(Arg <DataContainer> .Is.Anything, Arg <PropertyDefinition> .Is.Anything, Arg <ValueAccess> .Is.Anything));

            Assert.That(result, Is.TypeOf <FreshlyLoadedObjectData> ());
            Assert.That(result.ObjectID, Is.EqualTo(objectID));
            var dataContainer = ((FreshlyLoadedObjectData)result).FreshlyLoadedDataContainer;

            CheckDataContainer(dataContainer, objectID, 4711, StateType.Unchanged, _orderNumberPropertyDefinition, 17, 17, false);
        }
コード例 #19
0
        public void ResolveObjectRelationData_ResolvesToNotYetLoadedObject()
        {
            var parentObject = DomainObjectMother.CreateFakeObject <OrderTicket> ();

            _parentTransactionContextMock
            .Expect(mock => mock.ResolveRelatedObject(_virtualObjectRelationEndPointID))
            .Return(parentObject);
            _alreadyLoadedObjectDataProviderMock
            .Expect(mock => mock.GetLoadedObject(parentObject.ID))
            .Return(null);

            var parentDataContainer = CreateChangedDataContainer(parentObject.ID, 4711, _fileNamePropertyDefinition, "Hugo");

            CheckDataContainer(parentDataContainer, parentObject.ID, 4711, StateType.Changed, _fileNamePropertyDefinition, "Hugo", "", true);
            _parentTransactionContextMock
            .Expect(mock => mock.GetDataContainerWithLazyLoad(parentObject.ID, true))
            .Return(parentDataContainer);

            var result = _persistenceStrategy.ResolveObjectRelationData(_virtualObjectRelationEndPointID, _alreadyLoadedObjectDataProviderMock);

            _parentTransactionContextMock.VerifyAllExpectations();
            _alreadyLoadedObjectDataProviderMock.VerifyAllExpectations();
            Assert.That(result, Is.TypeOf <FreshlyLoadedObjectData> ());
            Assert.That(result.ObjectID, Is.EqualTo(parentObject.ID));

            var dataContainer = ((FreshlyLoadedObjectData)result).FreshlyLoadedDataContainer;

            CheckDataContainer(dataContainer, parentObject.ID, 4711, StateType.Unchanged, _fileNamePropertyDefinition, "Hugo", "Hugo", false);
        }
コード例 #20
0
        public void GetDomainObjectReference_AfterRegistration()
        {
            var domainObject = DomainObjectMother.CreateFakeObject <Order> (_dataContainer.ID);

            _dataContainer.SetDomainObject(domainObject);

            Assert.That(_loadedObjectData.GetDomainObjectReference(), Is.SameAs(domainObject));
        }
コード例 #21
0
        private PersistableData CreatePersistableData(StateType domainObjectState, IRelationEndPoint[] associatedEndPointSequence)
        {
            var domainObject = DomainObjectMother.CreateFakeObject <OrderItem> (DomainObjectIDs.OrderItem1);

            var dataContainer = DataContainer.CreateNew(domainObject.ID);

            return(new PersistableData(domainObject, domainObjectState, dataContainer, associatedEndPointSequence));
        }
コード例 #22
0
        private PersistableData CreatePersistableDataForExistingOrder()
        {
            var domainObject  = DomainObjectMother.CreateFakeObject <Order> ();
            var dataContainer = DataContainerObjectMother.CreateExisting(domainObject.ID);

            dataContainer.SetDomainObject(domainObject);
            return(new PersistableData(domainObject, StateType.Changed, dataContainer, new IRelationEndPoint[0]));
        }
        public void RegisterOriginalOppositeEndPoint_PreviouslyOtherItemWithoutEndPoint()
        {
            var oppositeObject2 = DomainObjectMother.CreateFakeObject <OrderTicket> (DomainObjectIDs.OrderTicket2);

            _dataManager.RegisterOriginalItemWithoutEndPoint(oppositeObject2);

            _dataManager.RegisterOriginalOppositeEndPoint(_oppositeEndPointStub);
        }
コード例 #24
0
        public void Resolve_Expression_Interface()
        {
            var instance   = DomainObjectMother.CreateFakeObject <Order> (_objectID);
            var endPointID = RelationEndPointID.Resolve(instance, o => ((IOrder)o).OrderTicket);

            Assert.That(endPointID.Definition, Is.EqualTo(_endPointDefinition));
            Assert.That(endPointID.ObjectID, Is.EqualTo(_objectID));
        }
コード例 #25
0
        public static ILoadedObjectData CreateLoadedObjectDataStub(DomainObject domainObjectReference = null)
        {
            domainObjectReference = domainObjectReference ?? DomainObjectMother.CreateFakeObject <Order>();
            var loadedObjectDataStub = CreateLoadedObjectDataStub(domainObjectReference.ID);

            loadedObjectDataStub.Stub(stub => stub.GetDomainObjectReference()).Return(domainObjectReference);
            return(loadedObjectDataStub);
        }
コード例 #26
0
        public void RegisterOriginalItem_CollectionUnchanged_OriginalCollectionNotCopied()
        {
            var domainObject = DomainObjectMother.CreateFakeObject <Order> ();

            _decoratorWithRealData.RegisterOriginalItem(domainObject);

            CheckOriginalDataNotCopied(_decoratorWithRealData);
        }
        public void CreateReplaceCommand_WithItemWithoutEndPoint()
        {
            _dataManagerMock.Stub(stub => stub.ContainsOriginalItemWithoutEndPoint(_relatedObject)).Return(true);

            _dataManagerMock
            .Stub(stub => stub.CollectionData)
            .Return(new DomainObjectCollectionData(new[] { DomainObjectMother.CreateFakeObject <Order> () }));
            _loadState.CreateReplaceCommand(_collectionEndPointMock, 0, _relatedObject);
        }
コード例 #28
0
        public void RegisterOriginalItem_CollectionUnchanged_ItemAddedToBothLists()
        {
            var domainObject = DomainObjectMother.CreateFakeObject <Order> ();

            _decoratorWithRealData.RegisterOriginalItem(domainObject);

            Assert.That(_decoratorWithRealData.GetObject(1), Is.SameAs(domainObject));
            Assert.That(_decoratorWithRealData.OriginalData.GetObject(1), Is.SameAs(domainObject));
        }
コード例 #29
0
        private AlreadyExistingLoadedObjectData GetAlreadyExistingLoadedObject()
        {
            var domainObject  = DomainObjectMother.CreateFakeObject <Order> ();
            var dataContainer = DataContainer.CreateForExisting(domainObject.ID, null, pd => pd.DefaultValue);

            dataContainer.SetDomainObject(domainObject);
            DataContainerTestHelper.SetClientTransaction(dataContainer, _clientTransaction);
            return(new AlreadyExistingLoadedObjectData(dataContainer));
        }
コード例 #30
0
        public override void SetUp()
        {
            base.SetUp();

            _transactionEventSinkWithMock = MockRepository.GenerateStrictMock <IClientTransactionEventSink>();

            _manager = new InvalidDomainObjectManager(_transactionEventSinkWithMock);
            _order1  = DomainObjectMother.CreateFakeObject <Order> (DomainObjectIDs.Order1);
        }