public virtual void TearDown()
 {
     if (_isDatabaseModifyable)
     {
         _databaseAgent.ExecuteBatchFile(_createTestDataFileName, true, DatabaseConfiguration.GetReplacementDictionary());
     }
 }
Example #2
0
        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;
            }
        }
Example #3
0
        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);
            }
        }
Example #4
0
        public override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();

            SetDatabaseModifyable();
            DatabaseAgent.ExecuteBatchFile("DataDomainObjects_DropFulltextIndices.sql", false, DatabaseConfiguration.GetReplacementDictionary());
            DatabaseAgent.ExecuteBatchFile("DataDomainObjects_CreateFulltextIndices.sql", false, DatabaseConfiguration.GetReplacementDictionary());
            WaitForIndices();
        }
        public void SetUp()
        {
            try
            {
                ServiceLocator.SetLocatorProvider(() => null);

                LogManager.ResetConfiguration();
                Assert.That(LogManager.GetLogger(typeof(LoggingClientTransactionListener)).IsDebugEnabled, Is.False);

                StandardConfiguration.Initialize();
                TableInheritanceConfiguration.Initialize();

                SqlConnection.ClearAllPools();

                var masterAgent = new DatabaseAgent(DatabaseTest.MasterConnectionString);
                masterAgent.ExecuteBatchFile("DataDomainObjects_CreateDB.sql", false, DatabaseConfiguration.GetReplacementDictionary());
                var testDomainAgent = new DatabaseAgent(DatabaseTest.TestDomainConnectionString);
                testDomainAgent.ExecuteBatchFile("DataDomainObjects_SetupDB.sql", true, DatabaseConfiguration.GetReplacementDictionary());

                _standardMappingDatabaseAgent = new StandardMappingDatabaseAgent(DatabaseTest.TestDomainConnectionString);
                string sqlFileName = StandardMappingTest.CreateTestDataFileName;
                _standardMappingDatabaseAgent.ExecuteBatchFile(sqlFileName, true, DatabaseConfiguration.GetReplacementDictionary());
                string sqlFileName1 = TableInheritanceMappingTest.CreateTestDataFileName;
                _standardMappingDatabaseAgent.ExecuteBatchFile(sqlFileName1, true, DatabaseConfiguration.GetReplacementDictionary());
                _standardMappingDatabaseAgent.SetDatabaseReadOnly(DatabaseTest.DatabaseName);

                // We don't want the tests to initialize a default mapping; therefore, modify MappingConfiguration.s_mappingConfiguration so that it will
                // throw when asked to generate a new MappingConfiguration.

                _previousMappingConfigurationContainer = (DoubleCheckedLockingContainer <IMappingConfiguration>)PrivateInvoke.GetNonPublicStaticField(
                    typeof(MappingConfiguration),
                    "s_mappingConfiguration");
                var throwingMappingConfigurationContainer = new DoubleCheckedLockingContainer <IMappingConfiguration> (
                    () =>
                {
                    throw new InvalidOperationException(
                        "This test failed to setup the mapping configuration. Did you forget to derive from StandardMappingTest or to call base.SetUp?");
                });
                PrivateInvoke.SetNonPublicStaticField(typeof(MappingConfiguration), "s_mappingConfiguration", throwingMappingConfigurationContainer);
            }
            catch (Exception ex)
            {
                Console.WriteLine("SetUpFixture failed: " + ex);
                Console.WriteLine();
                throw;
            }
        }
Example #6
0
 public override void TestFixtureTearDown()
 {
     DatabaseAgent.ExecuteBatchFile("DataDomainObjects_DropFulltextIndices.sql", false, DatabaseConfiguration.GetReplacementDictionary());
     base.TestFixtureTearDown();
 }