public override void SetUp() { base.SetUp(); DomainObjectsConfiguration.SetCurrent(SchemaGenerationConfiguration.Instance.GetDomainObjectsConfiguration()); MappingConfiguration.SetCurrent(SchemaGenerationConfiguration.Instance.GetMappingConfiguration()); }
public override void TestFixtureSetUp() { base.TestFixtureSetUp(); DomainObjectsConfiguration.SetCurrent(TableInheritanceConfiguration.Instance.GetDomainObjectsConfiguration()); MappingConfiguration.SetCurrent(StandardConfiguration.Instance.GetMappingConfiguration()); ConfigurationWrapper.SetCurrent(null); }
protected TestMappingConfiguration() { ProviderCollection <StorageProviderDefinition> storageProviderDefinitionCollection = StorageProviderDefinitionObjectMother.CreateTestDomainStorageProviders(); _storageConfiguration = new StorageConfiguration( storageProviderDefinitionCollection, storageProviderDefinitionCollection[MappingReflectionTestBase.DefaultStorageProviderID]); _storageConfiguration.StorageGroups.Add(new StorageGroupElement(new TestDomainAttribute(), MappingReflectionTestBase.c_testDomainProviderID)); _storageConfiguration.StorageGroups.Add( new StorageGroupElement(new StorageProviderStubAttribute(), MappingReflectionTestBase.c_unitTestStorageProviderStubID)); _storageConfiguration.StorageGroups.Add( new StorageGroupElement(new TableInheritanceTestDomainAttribute(), TableInheritanceMappingTest.TableInheritanceTestDomainProviderID)); _mappingLoaderConfiguration = new MappingLoaderConfiguration(); _queryConfiguration = new QueryConfiguration("QueriesForStandardMapping.xml"); DomainObjectsConfiguration.SetCurrent( new FakeDomainObjectsConfiguration(_mappingLoaderConfiguration, _storageConfiguration, _queryConfiguration)); var typeDiscoveryService = GetTypeDiscoveryService(); _mappingConfiguration = new MappingConfiguration( MappingReflectorObjectMother.CreateMappingReflector(typeDiscoveryService), new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage))); MappingConfiguration.SetCurrent(_mappingConfiguration); _domainObjectIDs = new DomainObjectIDs(); }
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 virtual void TestFixtureSetUp() { DomainObjectsConfiguration.SetCurrent(TestMappingConfiguration.Instance.GetDomainObjectsConfiguration()); MappingConfiguration.SetCurrent(TestMappingConfiguration.Instance.GetMappingConfiguration()); ConfigurationWrapper.SetCurrent(null); FakeMappingConfiguration.Reset(); }
public void SetUp() { try { var providers = new ProviderCollection <StorageProviderDefinition>(); providers.Add(new RdbmsProviderDefinition("TheStorageProvider", new SqlStorageObjectFactory(), TestDomainConnectionString)); var storageConfiguration = new StorageConfiguration(providers, providers["TheStorageProvider"]); DomainObjectsConfiguration.SetCurrent(new FakeDomainObjectsConfiguration(storage: storageConfiguration)); SqlConnection.ClearAllPools(); var scriptGenerator = new ScriptGenerator( pd => pd.Factory.CreateSchemaScriptBuilder(pd), new RdbmsStorageEntityDefinitionProvider(), new ScriptToStringConverter()); var scripts = scriptGenerator.GetScripts(MappingConfiguration.Current.GetTypeDefinitions()).Single(); var masterAgent = new DatabaseAgent(MasterConnectionString); masterAgent.ExecuteBatchFile("Database\\CreateDB.sql", false, DatabaseConfiguration.GetReplacementDictionary()); var databaseAgent = new DatabaseAgent(TestDomainConnectionString); databaseAgent.ExecuteBatchString(scripts.SetUpScript, true); } catch (Exception e) { Console.WriteLine("SetUpFixture failed: " + e); Console.WriteLine(); throw; } }
protected virtual void InitializeConfiguration(string assemblyDirectory) { ApplicationAssemblyLoaderFilter filter = ApplicationAssemblyLoaderFilter.Instance; // TODO: Duplicates logic from AssemblyFinder? The DLL searching part below can probably be removed. List <Assembly> assemblies = new List <Assembly>(); DirectoryInfo dir = new DirectoryInfo(assemblyDirectory); foreach (FileInfo file in dir.GetFiles("*.dll")) { Assembly asm = Assembly.LoadFile(file.FullName); if (filter.ShouldConsiderAssembly(asm.GetName()) && filter.ShouldIncludeAssembly(asm)) { assemblies.Add(asm); } } DomainObjectsConfiguration.SetCurrent( new FakeDomainObjectsConfiguration(DomainObjectsConfiguration.Current.MappingLoader, GetPersistenceConfiguration(), new QueryConfiguration())); var rootAssemblyFinder = new FixedRootAssemblyFinder(assemblies.Select(a => new RootAssembly(a, false)).ToArray()); var assemblyLoader = new FilteringAssemblyLoader(filter); ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(new AssemblyFinder(rootAssemblyFinder, assemblyLoader)); var mappingReflector = new MappingReflector(typeDiscoveryService); var persistenceModelLoader = new PersistenceModelLoader(new StorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage)); var mappingConfiguration = new MappingConfiguration(mappingReflector, persistenceModelLoader); MappingConfiguration.SetCurrent(mappingConfiguration); }
public override void TestFixtureTearDown() { DomainObjectsConfiguration.SetCurrent(null); MappingConfiguration.SetCurrent(null); ConfigurationWrapper.SetCurrent(null); base.TestFixtureTearDown(); }
public override void SetUp() { base.SetUp(); DomainObjectsConfiguration.SetCurrent(StandardConfiguration.Instance.GetDomainObjectsConfiguration()); MappingConfiguration.SetCurrent(StandardConfiguration.Instance.GetMappingConfiguration()); ConfigurationWrapper.SetCurrent(null); }
public override void SetUp() { base.SetUp(); DomainObjectsConfiguration.SetCurrent(TableInheritanceConfiguration.Instance.GetDomainObjectsConfiguration()); MappingConfiguration.SetCurrent(TableInheritanceConfiguration.Instance.GetMappingConfiguration()); ConfigurationWrapper.SetCurrent(null); _transactionScope = ClientTransaction.CreateRootTransaction().EnterDiscardingScope(); }
public void GetAndSet() { IDomainObjectsConfiguration configuration = new FakeDomainObjectsConfiguration(new MappingLoaderConfiguration(), new StorageConfiguration(), new QueryConfiguration()); DomainObjectsConfiguration.SetCurrent(configuration); Assert.That(DomainObjectsConfiguration.Current, Is.SameAs(configuration)); }
protected virtual void InitializeConfiguration() { DomainObjectsConfiguration.SetCurrent( new FakeDomainObjectsConfiguration( DomainObjectsConfiguration.Current.MappingLoader, GetPersistenceConfiguration(), new QueryConfiguration())); MappingConfiguration.SetCurrent( new MappingConfiguration( DomainObjectsConfiguration.Current.MappingLoader.CreateMappingLoader(), new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage)))); }
public virtual void SetUp() { DomainObjectsConfiguration.SetCurrent(TestMappingConfiguration.Instance.GetDomainObjectsConfiguration()); MappingConfiguration.SetCurrent(TestMappingConfiguration.Instance.GetMappingConfiguration()); ConfigurationWrapper.SetCurrent(null); ClassIDProviderStub = MockRepository.GenerateStub <IClassIDProvider>(); DomainModelConstraintProviderStub = MockRepository.GenerateStub <IDomainModelConstraintProvider>(); DomainObjectCreatorStub = MockRepository.GenerateStub <IDomainObjectCreator>(); PropertyMetadataProvider = new PropertyMetadataReflector(); MappingObjectFactory = new ReflectionBasedMappingObjectFactory( Configuration.NameResolver, ClassIDProviderStub, PropertyMetadataProvider, DomainModelConstraintProviderStub, DomainObjectCreatorStub); }
public void UnknownQueryDefinitionInQueryConfiguration() { QueryDefinition unknownQueryDefinition = new QueryDefinition("UnknownQuery", TestDomainStorageProviderDefinition, "select 42", QueryType.Scalar); DomainObjectsConfiguration.Current.Query.QueryDefinitions.Add(unknownQueryDefinition); using (MemoryStream stream = new MemoryStream()) { Serialize(stream, unknownQueryDefinition); DomainObjectsConfiguration.SetCurrent( new FakeDomainObjectsConfiguration( DomainObjectsConfiguration.Current.MappingLoader, DomainObjectsConfiguration.Current.Storage, new QueryConfiguration())); Deserialize(stream); } }
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); } }
public void SetUp() { try { var providers = new ProviderCollection <StorageProviderDefinition>(); providers.Add(new RdbmsProviderDefinition(StubStorageProvider.StorageProviderID, new StubStorageFactory(), "NonExistingRdbms")); var storageConfiguration = new StorageConfiguration(providers, providers[StubStorageProvider.StorageProviderID]); DomainObjectsConfiguration.SetCurrent(new FakeDomainObjectsConfiguration(storage: storageConfiguration)); Dev.Null = MappingConfiguration.Current; } catch (Exception ex) { Console.WriteLine("SetUpFixture failed: " + ex); Console.WriteLine(); throw; } }
public void SetUp() { try { ProviderCollection <StorageProviderDefinition> providers = new ProviderCollection <StorageProviderDefinition>(); providers.Add(new RdbmsProviderDefinition("Development.Data.DomainObjects", new SqlStorageObjectFactory(), "ConnectionString")); StorageConfiguration storageConfiguration = new StorageConfiguration(providers, providers["Development.Data.DomainObjects"]); DomainObjectsConfiguration.SetCurrent( new FakeDomainObjectsConfiguration( new MappingLoaderConfiguration(), storageConfiguration, new QueryConfiguration())); var rootAssemblyFinder = new FixedRootAssemblyFinder(new RootAssembly(typeof(TestDomainObject).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(), new ThrowingDomainObjectCreator()), new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage)))); } catch (Exception e) { Console.WriteLine(e); throw; } }
public void SetUp() { DomainObjectsConfiguration.SetCurrent(null); }