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();
        }
Beispiel #2
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();
        }
        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();
        }
        private LoadedObjectDataWithDataSourceData CreateFetchedOrderData(Order fetchedObject, ObjectID orderID)
        {
            var endPointID           = RelationEndPointObjectMother.CreateRelationEndPointID(fetchedObject.ID, "Customer");
            var loadedObjectDataStub = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(fetchedObject);
            var dataContainer        = RelationEndPointTestHelper.CreateExistingForeignKeyDataContainer(endPointID, orderID);

            return(new LoadedObjectDataWithDataSourceData(loadedObjectDataStub, dataContainer));
        }
Beispiel #5
0
        private LoadedObjectDataWithDataSourceData CreateFetchedComputerData(Computer fetchedObject, ObjectID EmployeeID)
        {
            var endPointID           = RelationEndPointObjectMother.CreateRelationEndPointID(fetchedObject.ID, "Employee");
            var loadedObjectDataStub = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(fetchedObject);
            var dataContainer        = RelationEndPointTestHelper.CreateExistingForeignKeyDataContainer(endPointID, EmployeeID);

            return(new LoadedObjectDataWithDataSourceData(loadedObjectDataStub, dataContainer));
        }
        public void GroupAndRegisterRelatedObjects_InvalidOriginalObject()
        {
            var endPointDefinition = GetEndPointDefinition(typeof(OrderTicket), "Order");

            _agent.GroupAndRegisterRelatedObjects(
                endPointDefinition,
                new[] { LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(DomainObjectIDs.Order1) },
                new LoadedObjectDataWithDataSourceData[0]);
        }
        public void GroupAndRegisterRelatedObjects_OriginatingObjectOfInvalidType()
        {
            var endPointDefinition = GetEndPointDefinition(typeof(Customer), "Orders");

            _virtualEndPointProviderMock.Replay();

            _agent.GroupAndRegisterRelatedObjects(
                endPointDefinition,
                new[] { LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(DomainObjectIDs.OrderItem1) },
                new LoadedObjectDataWithDataSourceData[0]);
        }
Beispiel #8
0
        public void GroupAndRegisterRelatedObjects_WithNullRelatedObject_AndMandatoryRelation()
        {
            var endPointDefinition = GetEndPointDefinition(typeof(Order), "OrderTicket");

            Assert.That(endPointDefinition.IsMandatory, Is.True);
            var originatingOrderData = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(DomainObjectIDs.Order1);

            _agent.GroupAndRegisterRelatedObjects(
                endPointDefinition,
                new[] { originatingOrderData },
                new[] { LoadedObjectDataObjectMother.CreateNullLoadedObjectDataWithDataSourceData() });
        }
        public void GroupAndRegisterRelatedObjects_MandatoryEndPointWithoutRelatedObjects_Throws()
        {
            var orderItemsEndPointDefinition = GetEndPointDefinition(typeof(Order), "OrderItems");

            Assert.That(orderItemsEndPointDefinition.IsMandatory, Is.True);

            var originatingOrderData = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(DomainObjectIDs.Order1);

            _agent.GroupAndRegisterRelatedObjects(
                orderItemsEndPointDefinition,
                new[] { originatingOrderData },
                new LoadedObjectDataWithDataSourceData[0]);
        }
        public void GroupAndRegisterRelatedObjects_PropertyOnBaseType()
        {
            var endPointDefinition = GetEndPointDefinition(typeof(FileSystemItem), "ParentFolder");

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

            var fetchedParentFolder     = DomainObjectMother.CreateFakeObject <Folder>();
            var fetchedParentFolderData = LoadedObjectDataObjectMother.CreateLoadedObjectDataWithDataSourceData(fetchedParentFolder);

            originatingFile.InternalDataContainer.SetValue(GetPropertyDefinition(typeof(FileSystemItem), "ParentFolder"), fetchedParentFolder.ID);

            _agent.GroupAndRegisterRelatedObjects(
                endPointDefinition,
                new[] { originatingFileData },
                new[] { fetchedParentFolderData });
        }
        public void GroupAndRegisterRelatedObjects_NonMandatoryEndPointWithoutRelatedObjects_RegistersEmptyCollection()
        {
            var originatingCustomerData  = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(DomainObjectIDs.Customer1);
            var ordersEndPointDefinition = GetEndPointDefinition(typeof(Customer), "Orders");

            Assert.That(ordersEndPointDefinition.IsMandatory, Is.False);

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

            ExpectGetEndPoint(originatingCustomerData.ObjectID, ordersEndPointDefinition, _virtualEndPointProviderMock, collectionEndPointMock, false);

            collectionEndPointMock.Expect(mock => mock.MarkDataComplete(new DomainObject[0]));

            _agent.GroupAndRegisterRelatedObjects(
                ordersEndPointDefinition,
                new[] { originatingCustomerData },
                new LoadedObjectDataWithDataSourceData[0]);

            collectionEndPointMock.VerifyAllExpectations();
        }
        public override void SetUp()
        {
            base.SetUp();

            _agent = new FetchedRealObjectRelationDataRegistrationAgent();

            var originatingOrderTicket1 = DomainObjectMother.CreateFakeObject <OrderTicket> (DomainObjectIDs.OrderTicket1);
            var originatingOrderTicket2 = DomainObjectMother.CreateFakeObject <OrderTicket> (DomainObjectIDs.OrderTicket2);

            _originatingOrderTicketData1 = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(originatingOrderTicket1);
            _originatingOrderTicketData2 = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(originatingOrderTicket2);

            var fetchedOrder1 = DomainObjectMother.CreateFakeObject <Order> (DomainObjectIDs.Order1);
            var fetchedOrder2 = DomainObjectMother.CreateFakeObject <Order> (DomainObjectIDs.Order3);
            var fetchedOrder3 = DomainObjectMother.CreateFakeObject <Order> (DomainObjectIDs.Order4);

            _fetchedOrderData1 = LoadedObjectDataObjectMother.CreateLoadedObjectDataWithDataSourceData(fetchedOrder1);
            _fetchedOrderData2 = LoadedObjectDataObjectMother.CreateLoadedObjectDataWithDataSourceData(fetchedOrder2);
            _fetchedOrderData3 = LoadedObjectDataObjectMother.CreateLoadedObjectDataWithDataSourceData(fetchedOrder3);
        }
        public override void SetUp()
        {
            base.SetUp();

            _virtualEndPointProviderMock = MockRepository.GenerateStrictMock <IVirtualEndPointProvider> ();

            _agent = new FetchedCollectionRelationDataRegistrationAgent(_virtualEndPointProviderMock);

            _originatingCustomer1 = DomainObjectMother.CreateFakeObject <Customer> (DomainObjectIDs.Customer1);
            _originatingCustomer2 = DomainObjectMother.CreateFakeObject <Customer> (DomainObjectIDs.Customer2);

            _originatingCustomerData1 = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(_originatingCustomer1);
            _originatingCustomerData2 = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(_originatingCustomer2);

            _fetchedOrder1 = DomainObjectMother.CreateFakeObject <Order> (DomainObjectIDs.Order1);
            _fetchedOrder2 = DomainObjectMother.CreateFakeObject <Order> (DomainObjectIDs.Order3);
            _fetchedOrder3 = DomainObjectMother.CreateFakeObject <Order> (DomainObjectIDs.Order4);

            _fetchedOrderData1 = CreateFetchedOrderData(_fetchedOrder1, _originatingCustomer1.ID);
            _fetchedOrderData2 = CreateFetchedOrderData(_fetchedOrder2, _originatingCustomer2.ID);
            _fetchedOrderData3 = CreateFetchedOrderData(_fetchedOrder3, _originatingCustomer1.ID);
        }
        public void GroupAndRegisterRelatedObjects_PropertyOnDerivedType()
        {
            var endPointDefinition = GetEndPointDefinition(typeof(Partner), "ContactPerson");

            var originatingCompany     = DomainObjectMother.CreateFakeObject <Company>();
            var originatingCompanyData = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(originatingCompany);

            var originatingPartner     = DomainObjectMother.CreateFakeObject <Partner>();
            var originatingPartnerData = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(originatingPartner);

            var originatingCustomer     = DomainObjectMother.CreateFakeObject <Customer>();
            var originatingCustomerData = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(originatingCustomer);

            var fetchedPerson     = DomainObjectMother.CreateFakeObject <Person>();
            var fetchedPersonData = LoadedObjectDataObjectMother.CreateLoadedObjectDataWithDataSourceData(fetchedPerson);

            originatingPartner.InternalDataContainer.SetValue(GetPropertyDefinition(typeof(Partner), "ContactPerson"), fetchedPerson.ID);

            _agent.GroupAndRegisterRelatedObjects(
                endPointDefinition,
                new[] { originatingCompanyData, originatingPartnerData, originatingCustomerData },
                new[] { fetchedPersonData });
        }
Beispiel #15
0
        public override void SetUp()
        {
            base.SetUp();

            _loadedDataContainerProviderStub = MockRepository.GenerateStub <ILoadedDataContainerProvider> ();
            _virtualEndPointProviderMock     = MockRepository.GenerateStrictMock <IVirtualEndPointProvider> ();

            _agent = new FetchedVirtualObjectRelationDataRegistrationAgent(_virtualEndPointProviderMock);

            _originatingEmployee1 = DomainObjectMother.CreateFakeObject <Employee> (DomainObjectIDs.Employee1);
            _originatingEmployee2 = DomainObjectMother.CreateFakeObject <Employee> (DomainObjectIDs.Employee2);

            _originatingEmployeeData1 = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(_originatingEmployee1);
            _originatingEmployeeData2 = LoadedObjectDataObjectMother.CreateLoadedObjectDataStub(_originatingEmployee2);

            _fetchedComputer1 = DomainObjectMother.CreateFakeObject <Computer> (DomainObjectIDs.Computer1);
            _fetchedComputer2 = DomainObjectMother.CreateFakeObject <Computer> (DomainObjectIDs.Computer2);
            _fetchedComputer3 = DomainObjectMother.CreateFakeObject <Computer> (DomainObjectIDs.Computer3);

            _fetchedComputerData1 = CreateFetchedComputerData(_fetchedComputer1, _originatingEmployee1.ID);
            _fetchedComputerData2 = CreateFetchedComputerData(_fetchedComputer2, _originatingEmployee2.ID);
            _fetchedComputerData3 = CreateFetchedComputerData(_fetchedComputer3, DomainObjectIDs.Employee3);
        }