public void AzureSqlDatabase_ReadModel_can_be_configured_using_a_migration() { var databaseSettings = Settings.Get <AzureSqlDatabaseSettings>(); databaseSettings.DatabaseName = "ItsCqrsMigrationsTestReadModels"; var connectionString = databaseSettings.BuildConnectionString(); using (var context = new MigrationsTestReadModels(connectionString, typeof(OrderTallyEntityModelConfiguration))) { new ReadModelDatabaseInitializer <MigrationsTestReadModels>().InitializeDatabase(context); var migrator = new AzureSqlDbMigrator( new AzureSqlDatabaseServiceObjective("Premium", "P1", 10 * 1024), migrationVersion: new Version("0.0.42.1")); context.EnsureDatabaseIsUpToDate(migrator); var sku = context.GetAzureSqlDatabaseServiceObjective(); sku.Edition.Should().Be("Premium"); sku.ServiceObjective.Should().Be("P1"); context.OpenConnection() .GetLatestAppliedMigrationVersions() .Should() .Contain(v => v.MigrationVersion.ToString() == "0.0.42.1"); } }
public void AzureSqlDatabase_can_be_configured_during_creation() { var databaseSettings = Settings.Get <AzureSqlDatabaseSettings>(); databaseSettings.DatabaseName = "ItsCqrsPremiumDatabase"; var connectionString = databaseSettings.BuildConnectionString(); var sqlAzureDatabaseProperties = new AzureSqlDatabaseServiceObjective("Premium", "P1", 10 * 1024); using (var context = new MigrationsTestReadModels(connectionString, typeof(OrderTallyEntityModelConfiguration))) using (Disposable.Create(() => { // Drop the expensive database context.Database.Connection.Close(); context.Database.Delete(); })) { new ReadModelDatabaseInitializer <MigrationsTestReadModels>() .WithAzureSqlDatabaseServiceObjective(sqlAzureDatabaseProperties) .InitializeDatabase(context); var sku = context.GetAzureSqlDatabaseServiceObjective(); sku.Edition.Should().Be("Premium"); sku.ServiceObjective.Should().Be("P1"); } }