Esempio n. 1
0
        public static async Task InitiateTempDatabase(bool enforceRestart, bool mustRenew)
        {
            if (!IsTddExecutionMode())
            {
                return;
            }

            IsDatabaseBeingCreated = true;
            var createdNew = false;

            try
            {
                SqlConnection.ClearAllPools();
                if (enforceRestart)
                {
                    TempDatabaseInitiated = null;
                }
                if (TempDatabaseInitiated.HasValue)
                {
                    return;
                }

                var generator = new TestDatabaseGenerator(isTempDatabaseOptional: true, mustRenew: mustRenew);
                TempDatabaseInitiated = generator.Process();
                createdNew            = generator.CreatedNewDatabase;

                await Entity.Database.Refresh();

                SqlConnection.ClearAllPools();
            }
            finally { IsDatabaseBeingCreated = false; }

            if (ReferenceDataCreator != null && createdNew)
            {
                // A new database is created. Add the reference data
                await ReferenceDataCreator();
            }
        }
Esempio n. 2
0
        static string CreateSnapshotName(string name)
        {
            var schemaHash = new TestDatabaseGenerator(false, false).GetCurrentDatabaseCreationHash();

            return("{0}_{1}".FormatWith(name, schemaHash).Except(Path.GetInvalidFileNameChars()).ToString(""));
        }