Пример #1
0
        public static T CreateWithComponents <T> (
            Dictionary <Enum, object> applicationData = null,
            IClientTransactionEventBroker eventBroker = null,
            ITransactionHierarchyManager transactionHierarchyManager = null,
            IEnlistedDomainObjectManager enlistedDomainObjectManager = null,
            IInvalidDomainObjectManager invalidDomainObjectManager   = null,
            IPersistenceStrategy persistenceStrategy = null,
            IDataManager dataManager = null,
            IObjectLifetimeAgent objectLifetimeAgent = null,
            IQueryManager queryManager = null,
            ICommitRollbackAgent commitRollbackAgent             = null,
            IEnumerable <IClientTransactionExtension> extensions = null)
            where T : ClientTransaction
        {
            var componentFactoryStub = CreateComponentFactory(
                applicationData,
                eventBroker,
                transactionHierarchyManager,
                enlistedDomainObjectManager,
                invalidDomainObjectManager,
                persistenceStrategy,
                dataManager,
                objectLifetimeAgent,
                queryManager,
                commitRollbackAgent,
                extensions);

            return(CreateWithComponents <T> (componentFactoryStub));
        }
Пример #2
0
        public static IClientTransactionComponentFactory CreateComponentFactory(
            Dictionary <Enum, object> applicationData = null,
            IClientTransactionEventBroker eventBroker = null,
            ITransactionHierarchyManager transactionHierarchyManager = null,
            IEnlistedDomainObjectManager enlistedDomainObjectManager = null,
            IInvalidDomainObjectManager invalidDomainObjectManager   = null,
            IPersistenceStrategy persistenceStrategy = null,
            IDataManager dataManager = null,
            IObjectLifetimeAgent objectLifetimeAgent = null,
            IQueryManager queryManager = null,
            ICommitRollbackAgent commitRollbackAgent             = null,
            IEnumerable <IClientTransactionExtension> extensions = null)
        {
            applicationData             = applicationData ?? new Dictionary <Enum, object>();
            transactionHierarchyManager = transactionHierarchyManager ?? MockRepository.GenerateStub <ITransactionHierarchyManager>();
            enlistedDomainObjectManager = enlistedDomainObjectManager ?? MockRepository.GenerateStub <IEnlistedDomainObjectManager>();
            invalidDomainObjectManager  = invalidDomainObjectManager ?? MockRepository.GenerateStub <IInvalidDomainObjectManager>();
            persistenceStrategy         = persistenceStrategy ?? MockRepository.GenerateStub <IPersistenceStrategy>();
            dataManager         = dataManager ?? MockRepository.GenerateStub <IDataManager>();
            objectLifetimeAgent = objectLifetimeAgent ?? MockRepository.GenerateStub <IObjectLifetimeAgent>();
            eventBroker         = eventBroker ?? MockRepository.GenerateStub <IClientTransactionEventBroker>();
            queryManager        = queryManager ?? MockRepository.GenerateStub <IQueryManager>();
            commitRollbackAgent = commitRollbackAgent ?? MockRepository.GenerateStub <ICommitRollbackAgent>();
            extensions          = extensions ?? Enumerable.Empty <IClientTransactionExtension>();

            var componentFactoryStub = MockRepository.GenerateStub <IClientTransactionComponentFactory>();

            componentFactoryStub.Stub(stub => stub.CreateApplicationData(Arg <ClientTransaction> .Is.Anything)).Return(applicationData);
            componentFactoryStub
            .Stub(stub => stub.CreateEventBroker(Arg <ClientTransaction> .Is.Anything))
            .Return(eventBroker);
            componentFactoryStub
            .Stub(stub => stub.CreateTransactionHierarchyManager(Arg <ClientTransaction> .Is.Anything, Arg <IClientTransactionEventSink> .Is.Anything))
            .Return(transactionHierarchyManager);
            componentFactoryStub.Stub(stub => stub.CreateEnlistedObjectManager(Arg <ClientTransaction> .Is.Anything)).Return(enlistedDomainObjectManager);
            componentFactoryStub
            .Stub(stub => stub.CreateInvalidDomainObjectManager(Arg <ClientTransaction> .Is.Anything, Arg <IClientTransactionEventSink> .Is.Anything))
            .Return(invalidDomainObjectManager);
            componentFactoryStub.Stub(stub => stub.CreatePersistenceStrategy(Arg <ClientTransaction> .Is.Anything)).Return(persistenceStrategy);
            componentFactoryStub
            .Stub(stub => stub.CreateDataManager(
                      Arg <ClientTransaction> .Is.Anything,
                      Arg <IClientTransactionEventSink> .Is.Anything,
                      Arg <IInvalidDomainObjectManager> .Is.Anything,
                      Arg <IPersistenceStrategy> .Is.Anything,
                      Arg <ITransactionHierarchyManager> .Is.Anything))
            .Return(dataManager);
            componentFactoryStub
            .Stub(
                stub =>
                stub.CreateObjectLifetimeAgent(
                    Arg <ClientTransaction> .Is.Anything,
                    Arg <IClientTransactionEventSink> .Is.Anything,
                    Arg <IInvalidDomainObjectManager> .Is.Anything,
                    Arg <IDataManager> .Is.Anything,
                    Arg <IEnlistedDomainObjectManager> .Is.Anything,
                    Arg <IPersistenceStrategy> .Is.Anything))
            .Return(objectLifetimeAgent);
            componentFactoryStub
            .Stub(stub => stub.CreateQueryManager(
                      Arg <ClientTransaction> .Is.Anything,
                      Arg <IClientTransactionEventSink> .Is.Anything,
                      Arg <IInvalidDomainObjectManager> .Is.Anything,
                      Arg <IPersistenceStrategy> .Is.Anything,
                      Arg <IDataManager> .Is.Anything,
                      Arg <ITransactionHierarchyManager> .Is.Anything))
            .Return(queryManager);
            componentFactoryStub
            .Stub(stub => stub.CreateCommitRollbackAgent(
                      Arg <ClientTransaction> .Is.Anything,
                      Arg <IClientTransactionEventSink> .Is.Anything,
                      Arg <IPersistenceStrategy> .Is.Anything,
                      Arg <IDataManager> .Is.Anything))
            .Return(commitRollbackAgent);
            componentFactoryStub.Stub(stub => stub.CreateExtensions(Arg <ClientTransaction> .Is.Anything)).Return(extensions);
            return(componentFactoryStub);
        }