Ejemplo n.º 1
0
        protected override void Initialize()
        {
            string tempName = Guid.NewGuid().ToString("N");

            s_localDbInstance.CreateDatabase(tempName, s_filesPath);
            s_localDbInstance.DetachDatabase(tempName);

            _prepareQueue     = new BlockingCollection <TestDbMeta>();
            _readySchemaQueue = new BlockingCollection <TestDbMeta>();
            _readyEmptyQueue  = new BlockingCollection <TestDbMeta>();

            for (int i = 0; i < _testDatabases.Count; i++)
            {
                TestDbMeta meta   = _testDatabases[i];
                bool       isLast = i == _testDatabases.Count - 1;

                _localDb.CopyDatabaseFiles(tempName, s_filesPath, targetDatabaseName: meta.Name, overwrite: true, delete: isLast);
                meta.ConnectionString = s_localDbInstance.GetAttachedConnectionString(meta.Name, s_filesPath);
                _prepareQueue.Add(meta);
            }

            for (int i = 0; i < _settings.PrepareThreadCount; i++)
            {
                var thread = new Thread(PrepareDatabase);
                thread.Start();
            }
        }