Esempio n. 1
0
        public void PublishWithScope(string dbconnection, string data, bool sample, bool reduced, string scope)
        {
            string connection = dbconnection;

            SafeWriteDebug("ConnectionString: " + connection);

            using (var db = new EFAppConfigRepository(connection))
            {
                SqlAppConfigDatabaseInitializer initializer;

                if (sample)
                {
                    if (reduced)
                    {
                        SafeWriteVerbose("Running reduced sample scripts");
                        initializer = new SqlAppConfigReducedSampleDatabaseInitializer();
                    }
                    else
                    {
                        SafeWriteVerbose("Running sample scripts");
                        initializer = new SqlAppConfigSampleDatabaseInitializer();
                    }
                }
                else
                {
                    SafeWriteVerbose("Running minimum scripts");
                    initializer = new SqlAppConfigDatabaseInitializer();
                }

                initializer.Scope = scope;
                initializer.InitializeDatabase(db);
            }
        }
Esempio n. 2
0
        private IAppConfigRepository GetRepository()
        {
            EnsureDatabaseInitialized(() => new EFAppConfigRepository(_databaseName), () => Database.SetInitializer(new SetupMigrateDatabaseToLatestVersion <EFAppConfigRepository, Configuration>()));
            var retVal = new EFAppConfigRepository(_databaseName);

            return(retVal);
        }
        public void Can_generate_sequence()
        {
            var client = new EFAppConfigRepository("VirtoCommerce");
            //var client = GetRepository();
            var sequence = new DbIdentitySequenceService(client);
            var result   = sequence.GetNext("test");

            Assert.NotNull(result);
        }
Esempio n. 4
0
        public static void Cleanup()
        {
            const string sql =
                @"IF OBJECT_ID('dbo.UniqueSequence', 'U') IS NOT NULL
                    DROP TABLE [dbo].[UniqueSequence]";
            var repository = new EFAppConfigRepository("VirtoCommerce");

            repository.Database.ExecuteSqlCommand(sql);
        }
Esempio n. 5
0
        public static void Initialize(TestContext context)
        {
            const string sql =
                @"IF OBJECT_ID('dbo.UniqueSequence', 'U') IS NULL
                    CREATE TABLE [dbo].[UniqueSequence]([Sequence] [nvarchar](255) NOT NULL,CONSTRAINT [PK_UniqueSequence] PRIMARY KEY CLUSTERED ([Sequence] ASC)
                    WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON))";
            var repository = new EFAppConfigRepository("VirtoCommerce");

            repository.Database.ExecuteSqlCommand(sql);
        }
Esempio n. 6
0
 public void Dispose()
 {
     try
     {
         // Ensure LocalDb databases are deleted after use so that LocalDb doesn't throw if
         // the temp location in which they are stored is later cleaned.
         using (var context = new EFAppConfigRepository(_databaseName))
         {
             context.Database.Delete();
         }
     }
     finally
     {
         AppDomain.CurrentDomain.SetData("DataDirectory", _previousDataDirectory);
     }
 }
Esempio n. 7
0
        public void Run_sequences_performance()
        {
            var repository = new EFAppConfigRepository("VirtoCommerce");
            var sequence   = new SequenceService(repository);


            for (var i = 1; i < SequenceService.SequenceReservationRange; i++)
            {
                var result = sequence.GetNext("test");
                Debug.WriteLine(result);

                //This would fail if any duplicate generated
                Assert.IsFalse(GlobalNumbers.ContainsKey(result));
                GlobalNumbers.Add(result, result);

                const string sql = "INSERT UniqueSequence VALUES(@p0);";
                //This would fail if any duplicate generated beause we use primary key
                var sqlResult = repository.Database.ExecuteSqlCommand(sql, result);
                Assert.AreEqual(1, sqlResult);
            }
        }
        //[Fact]
        public void ef_memory_leak()
        {
            // this call causes memory leak for every entity framework request after
            var isAzure = AzureCommonHelper.IsAzureEnvironment();

            //CloudConfigurationManager.GetSetting("SchoolContext");

            Database.SetInitializer(new MySampleInitialize());

            new SchoolContext().Database.Initialize(false);
            for (int index = 1; index < 500; index++)
            {
                var db2 = new SchoolContext();
                var all = db2.Students.ToArray();
                db2.Dispose();
            }

            for (int index = 1; index < 500; index++)
            {
                var db2 = new EFAppConfigRepository();
                var all = db2.Localizations.ToArray();
                db2.Dispose();
            }
        }