public static void Initialize() { ProviderCollection <StorageProviderDefinition> providers = new ProviderCollection <StorageProviderDefinition>(); providers.Add(new RdbmsProviderDefinition("PerformanceTestDomain", new SqlStorageObjectFactory(), ConnectionString)); StorageConfiguration storageConfiguration = new StorageConfiguration(providers, providers["PerformanceTestDomain"]); DomainObjectsConfiguration.SetCurrent(new FakeDomainObjectsConfiguration(storage: storageConfiguration)); var rootAssemblyFinder = new FixedRootAssemblyFinder(new RootAssembly(typeof(StandardConfiguration).Assembly, true)); var assemblyLoader = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance); var assemblyFinder = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader)); ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder); MappingConfiguration mappingConfiguration = new MappingConfiguration( new MappingReflector( typeDiscoveryService, new ClassIDProvider(), new ReflectionBasedMemberInformationNameResolver(), new PropertyMetadataReflector(), new DomainModelConstraintProvider(), MappingReflector.CreateDomainObjectCreator()), new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage))); MappingConfiguration.SetCurrent(mappingConfiguration); }
public void CreateDomainObjectCreator() { var registryStub = MockRepository.GenerateStub <IPipelineRegistry> (); var serviceLocator = DefaultServiceLocator.Create(); serviceLocator.RegisterSingle <IPipelineRegistry> (() => registryStub); using (new ServiceLocatorScope(serviceLocator)) { var creator = MappingReflector.CreateDomainObjectCreator(); Assert.That(creator.PipelineRegistry, Is.SameAs(registryStub)); } }
public int Run() { try { ServiceLocator.SetLocatorProvider(() => null); var assemblyLoader = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance); var rootAssemblyFinder = new FixedRootAssemblyFinder(new RootAssembly(typeof(BaseSecurityManagerObject).Assembly, true)); var assemblyFinder = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader)); ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder); MappingConfiguration.SetCurrent( new MappingConfiguration( new MappingReflector( typeDiscoveryService, new ClassIDProvider(), new ReflectionBasedMemberInformationNameResolver(), new PropertyMetadataReflector(), new DomainModelConstraintProvider(), MappingReflector.CreateDomainObjectCreator()), new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage)))); ClientTransaction transaction = ClientTransaction.CreateRootTransaction(); if (_arguments.ImportMetadata) { ImportMetadata(transaction); } transaction.Commit(); if (_arguments.ImportLocalization) { ImportLocalization(transaction); } transaction.Commit(); return(0); } catch (Exception e) { HandleException(e); return(1); } }
public void SetUp() { try { var serviceLocator = DefaultServiceLocator.Create(); serviceLocator.RegisterSingle <ISecurityProvider> (() => new NullSecurityProvider()); serviceLocator.RegisterSingle <IPrincipalProvider> (() => new NullPrincipalProvider()); ServiceLocator.SetLocatorProvider(() => serviceLocator); var providers = new ProviderCollection <StorageProviderDefinition>(); providers.Add(new RdbmsProviderDefinition("SecurityManager", new SecurityManagerSqlStorageObjectFactory(), TestDomainConnectionString)); var storageConfiguration = new StorageConfiguration(providers, providers["SecurityManager"]); storageConfiguration.StorageGroups.Add(new StorageGroupElement(new SecurityManagerStorageGroupAttribute(), "SecurityManager")); DomainObjectsConfiguration.SetCurrent(new FakeDomainObjectsConfiguration(storage: storageConfiguration)); var rootAssemblyFinder = new FixedRootAssemblyFinder(new RootAssembly(typeof(BaseSecurityManagerObject).Assembly, true)); var assemblyLoader = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance); var assemblyFinder = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader)); ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder); MappingConfiguration.SetCurrent( new MappingConfiguration( new MappingReflector( typeDiscoveryService, new ClassIDProvider(), new ReflectionBasedMemberInformationNameResolver(), new PropertyMetadataReflector(), new DomainModelConstraintProvider(), MappingReflector.CreateDomainObjectCreator()), new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage)))); SqlConnection.ClearAllPools(); DatabaseAgent masterAgent = new DatabaseAgent(MasterConnectionString); masterAgent.ExecuteBatchFile("SecurityManagerCreateDB.sql", false, DatabaseConfiguration.GetReplacementDictionary()); DatabaseAgent databaseAgent = new DatabaseAgent(TestDomainConnectionString); databaseAgent.ExecuteBatchFile("SecurityManagerSetupDB.sql", true); databaseAgent.ExecuteBatchFile("SecurityManagerSetupConstraints.sql", true); databaseAgent.ExecuteBatchFile("SecurityManagerSetupDBSpecialTables.sql", true); } catch (Exception e) { Console.WriteLine(e); } }