public void TestStartUp()
        {
            m_managerStorage = new InMemoryManagerStorage();

            m_managerStorage.SetUpStorage();
            m_managerStorage.InitializeStorageData();
        }
 public void SetUp()
 {
     m_managerStorage = new InMemoryManagerStorage();
     ManagerStorageFactory.SetManagerStorage(m_managerStorage);
 }
 public void TearDown()
 {
     m_managerStorage = null;
     ManagerStorageFactory.SetManagerStorage(null);
 }
 public void TearDown()
 {
     m_managerStorage = null;
 }
 public void SetUp()
 {
     m_managerStorage = new InMemoryManagerStorage();
 }
        /// <summary>
        /// Create the right manager storage object based on the storage type in the configuration file.
        /// </summary>
        /// <param name="config"></param>
        /// <param name="overwriteDefaultDatabase">Specify if the default catalog is set to the database name in the config file.</param>
        /// <returns></returns>
        public static IManagerStorage CreateManagerStorage(Configuration config, bool overwriteDefaultDatabase)
        {
            Configuration configuration = config;

            if (configuration == null)
            {
                configuration = Configuration.GetConfiguration();
            }

            string sqlConnStr;

            switch (configuration.DbType)
            {
            case ManagerStorageEnum.SqlServer:

                if (overwriteDefaultDatabase)
                {
                    // build sql server configuration string
                    sqlConnStr = string.Format(
                        "user id={1};password={2};initial catalog={3};data source={0};Connect Timeout=5; Max Pool Size=5; Min Pool Size=5",
                        configuration.DbServer,
                        configuration.DbUsername,
                        configuration.DbPassword,
                        configuration.DbName
                        );
                }
                else
                {
                    sqlConnStr = string.Format(
                        "user id={1};password={2};data source={0};Connect Timeout=5; Max Pool Size=5; Min Pool Size=5",
                        configuration.DbServer,
                        configuration.DbUsername,
                        configuration.DbPassword
                        );
                }

                m_managerStorage = new SqlServerManagerDatabaseStorage(sqlConnStr);
                break;

            case ManagerStorageEnum.MySql:

                if (overwriteDefaultDatabase)
                {
                    // build sql server configuration string
                    sqlConnStr = string.Format(
                        "user id={1};password={2};database={3};data source={0};Connect Timeout=5; Max Pool Size=5; Min Pool Size=5",
                        configuration.DbServer,
                        configuration.DbUsername,
                        configuration.DbPassword,
                        configuration.DbName
                        );
                }
                else
                {
                    sqlConnStr = string.Format(
                        "user id={1};password={2};data source={0};Connect Timeout=5; Max Pool Size=5; Min Pool Size=5",
                        configuration.DbServer,
                        configuration.DbUsername,
                        configuration.DbPassword
                        );
                }

                m_managerStorage = new MySqlManagerDatabaseStorage(sqlConnStr);
                break;

            case ManagerStorageEnum.InMemory:
                /// in memory storage is volatile so we always return the same object
                if (m_managerStorage == null)
                {
                    lock (m_inMemoryManagerStorageLock)
                    {
                        // make sure that when we got the lock we are still uninitialized
                        if (m_managerStorage == null)
                        {
                            InMemoryManagerStorage inMemoryStorage = new InMemoryManagerStorage();

                            // volatile storage, we must initialize the data here
                            inMemoryStorage.InitializeStorageData();

                            m_managerStorage = inMemoryStorage;
                        }
                    }
                }

                break;

            default:
                throw new ConfigurationException(String.Format("Unknown storage type: {0}", configuration.DbType));
            }

            return(m_managerStorage);
        }
        public void SetUp()
        {
            m_managerStorage = new InMemoryManagerStorage();
            ManagerStorageFactory.SetManagerStorage(m_managerStorage);

            m_executorCollection = new MExecutorCollection();
        }
        /// <summary>
        /// Create the right manager storage object based on the storage type in the configuration file.
        /// </summary>
        /// <param name="config"></param>
        /// <param name="overwriteDefaultDatabase">Specify if the default catalog is set to the database name in the config file.</param>
        /// <returns></returns>
        public static IManagerStorage CreateManagerStorage(Configuration config, bool overwriteDefaultDatabase)
        {
            Configuration configuration = config;

            if (configuration==null)
            {
                configuration = Configuration.GetConfiguration();
            }

            string sqlConnStr;

            switch(configuration.DbType)
            {
                    case ManagerStorageEnum.SqlServer:

                    if (overwriteDefaultDatabase)
                    {
                        // build sql server configuration string
                        sqlConnStr = string.Format(
                            "user id={1};password={2};initial catalog={3};data source={0};Connect Timeout={4}; Max Pool Size={5}; Min Pool Size={6}",
                            configuration.DbServer,
                            configuration.DbUsername,
                            configuration.DbPassword,
                            configuration.DbName,
                            configuration.DbConnectTimeout,
                            configuration.DbMaxPoolSize,
                            configuration.DbMinPoolSize
                            );
                    }
                    else
                    {
                        sqlConnStr = string.Format(
                            "user id={1};password={2};data source={0};Connect Timeout={3}; Max Pool Size={4}; Min Pool Size={5}",
                            configuration.DbServer,
                            configuration.DbUsername,
                            configuration.DbPassword,
                            configuration.DbConnectTimeout,
                            configuration.DbMaxPoolSize,
                            configuration.DbMinPoolSize
                            );
                    }

                    _managerStorage = new SqlServerManagerDatabaseStorage(sqlConnStr);
                    break;

                case ManagerStorageEnum.MySql:

                    if (overwriteDefaultDatabase)
                    {
                        // build sql server configuration string
                        sqlConnStr = string.Format(
                            "user id={1};password={2};database={3};data source={0};Connect Timeout={4}; Max Pool Size={5}; Min Pool Size={6}",
                            configuration.DbServer,
                            configuration.DbUsername,
                            configuration.DbPassword,
                            configuration.DbName,
                            configuration.DbConnectTimeout,
                            configuration.DbMaxPoolSize,
                            configuration.DbMinPoolSize
                            );
                    }
                    else
                    {
                        sqlConnStr = string.Format(
                            "user id={1};password={2};data source={0};Connect Timeout={3}; Max Pool Size={4}; Min Pool Size={5}",
                            configuration.DbServer,
                            configuration.DbUsername,
                            configuration.DbPassword,
                            configuration.DbConnectTimeout,
                            configuration.DbMaxPoolSize,
                            configuration.DbMinPoolSize
                            );
                    }

                    _managerStorage = new MySqlManagerDatabaseStorage(sqlConnStr);
                    break;
                case ManagerStorageEnum.Postgresql:
                    if (overwriteDefaultDatabase)
                    {
                        // build configuration string
                        sqlConnStr = string.Format(
                            "user id={1};password={2};database={3};port=5432;server={0};Connect Timeout={4}; Max Pool Size={5}; Min Pool Size={6}",
                            configuration.DbServer,
                            configuration.DbUsername,
                            configuration.DbPassword,
                            configuration.DbName,
                            configuration.DbConnectTimeout,
                            configuration.DbMaxPoolSize,
                            configuration.DbMinPoolSize
                            );
                    }
                    else
                    {
                        sqlConnStr = string.Format(
                            "user id={1};password={2};database=postgres;server={0};port=5432;Connect Timeout={3}; Max Pool Size={4}; Min Pool Size={5}",
                            configuration.DbServer,
                            configuration.DbUsername,
                            configuration.DbPassword,
                            configuration.DbConnectTimeout,
                            configuration.DbMaxPoolSize,
                            configuration.DbMinPoolSize
                            );
                    }

                    _managerStorage = new PostgresqlManagerDatabaseStorage(sqlConnStr);
                    break;
                case ManagerStorageEnum.db4o:
                    if (_managerStorage == null)
                    {
                        lock (_inMemoryManagerStorageLock)
                        {
                            // make sure that when we got the lock we are still uninitialized
                            if (_managerStorage == null)
                            {
                                db4oManagerStorage db4oStorage = new db4oManagerStorage(configuration.DbFilePath);

                                // volatile storage, we must initialize the data here
                                //db4oStorage.InitializeStorageData();

                                _managerStorage = db4oStorage;
                            }
                        }
                    }

                    break;
                case ManagerStorageEnum.InMemory:
                    /// in memory storage is volatile so we always return the same object
                    if (_managerStorage == null)
                    {
                        lock (_inMemoryManagerStorageLock)
                        {
                            // make sure that when we got the lock we are still uninitialized
                            if (_managerStorage == null)
                            {
                                InMemoryManagerStorage inMemoryStorage = new InMemoryManagerStorage();

                                // volatile storage, we must initialize the data here
                                inMemoryStorage.InitializeStorageData();

                                _managerStorage = inMemoryStorage;
                            }
                        }
                    }

                    break;

                default:
                    throw new System.Configuration.ConfigurationErrorsException(
                        string.Format("Unknown storage type: {0}", configuration.DbType));
            }

            return _managerStorage;
        }
        /// <summary>
        /// Create the right manager storage object based on the storage type in the configuration file.
        /// </summary>
        /// <param name="config"></param>
        /// <param name="overwriteDefaultDatabase">Specify if the default catalog is set to the database name in the config file.</param>
        /// <returns></returns>
        public static IManagerStorage CreateManagerStorage(Configuration config, bool overwriteDefaultDatabase)
        {
            Configuration configuration = config;

            if (configuration==null)
            {
                configuration = Configuration.GetConfiguration();
            }

            string sqlConnStr;

            switch(configuration.DbType)
            {
                    case ManagerStorageEnum.SqlServer:

                    if (overwriteDefaultDatabase)
                    {
                        // build sql server configuration string
                        sqlConnStr = string.Format(
                            "user id={1};password={2};initial catalog={3};data source={0};Connect Timeout=5; Max Pool Size=5; Min Pool Size=5",
                            configuration.DbServer,
                            configuration.DbUsername,
                            configuration.DbPassword,
                            configuration.DbName
                            );
                    }
                    else
                    {
                        sqlConnStr = string.Format(
                            "user id={1};password={2};data source={0};Connect Timeout=5; Max Pool Size=5; Min Pool Size=5",
                            configuration.DbServer,
                            configuration.DbUsername,
                            configuration.DbPassword
                            );
                    }

                    m_managerStorage = new SqlServerManagerDatabaseStorage(sqlConnStr);
                    break;

                case ManagerStorageEnum.MySql:

                    if (overwriteDefaultDatabase)
                    {
                        // build sql server configuration string
                        sqlConnStr = string.Format(
                            "user id={1};password={2};database={3};data source={0};Connect Timeout=5; Max Pool Size=5; Min Pool Size=5",
                            configuration.DbServer,
                            configuration.DbUsername,
                            configuration.DbPassword,
                            configuration.DbName
                            );
                    }
                    else
                    {
                        sqlConnStr = string.Format(
                            "user id={1};password={2};data source={0};Connect Timeout=5; Max Pool Size=5; Min Pool Size=5",
                            configuration.DbServer,
                            configuration.DbUsername,
                            configuration.DbPassword
                            );
                    }

                    m_managerStorage = new MySqlManagerDatabaseStorage(sqlConnStr);
                    break;

                case ManagerStorageEnum.InMemory:
                    /// in memory storage is volatile so we always return the same object
                    if (m_managerStorage == null)
                    {
                        lock (m_inMemoryManagerStorageLock)
                        {
                            // make sure that when we got the lock we are still uninitialized
                            if (m_managerStorage == null)
                            {
                                InMemoryManagerStorage inMemoryStorage = new InMemoryManagerStorage();

                                // volatile storage, we must initialize the data here
                                inMemoryStorage.InitializeStorageData();

                                m_managerStorage = inMemoryStorage;
                            }
                        }
                    }

                    break;

                default:
                    throw new ConfigurationException(String.Format("Unknown storage type: {0}", configuration.DbType));
            }

            return m_managerStorage;
        }