private SpikesMigrationsDb CreateDbContext(string connectionStringName = null) { var context = new SpikesMigrationsDb(connectionStringName); _trash.Add(context); return(context); }
public void CanUpgradeToLatestVs_AutodMigrations() { SpikesMigrationsDb db = CreateDbContext(); var initializer = SpikesMultiMigrateDbToLastestVersion.UsingAutoMigrations(); initializer.InitializeDatabase(db); }
public void CanFetchFakes() { using (var db = new SpikesMigrationsDb("SpikesMigrationsDb")) { List <FakeEntity> fakes = db.FakeEntities.ToList(); Assert.That(fakes, Is.Not.Empty); } }
public void Setup() { var db = new SpikesMigrationsDb("SpikesMigrationsDb"); if (db.Database.Exists()) { db.Database.Delete(); } }
public void Setup() { Database.SetInitializer(new NullDatabaseInitializer <SpikesMigrationsDb>()); using (var db = new SpikesMigrationsDb()) { if (db.Database.Exists()) { db.Database.Delete(); } } }
public void Setup() { Database.SetInitializer <SpikesMigrationsDb>(new SpikesMultiMigrateDbToLastestVersion()); using (var db = new SpikesMigrationsDb()) { if (db.Database.Exists()) { db.Database.Delete(); } db.Database.Initialize(false); } }
public void CanGetDatabaseMigrations() { // given SpikesMigrationsDb db = CreateDbContext(); var initializer = SpikesMultiMigrateDbToLastestVersion.UsingAutoMigrations(); initializer.InitializeDatabase(db); // when, then var migrator = new DbMigrator(new AutoConfiguration()); IEnumerable <string> migrations = migrator.GetDatabaseMigrations(); Assert.That(migrations, Is.Not.Empty); }
public void Setup() { Database.SetInitializer(new NullDatabaseInitializer <SpikesMigrationsDb>()); using (var db = new SpikesMigrationsDb("SpikesMigrationsDb")) { if (db.Database.Exists()) { db.Database.Delete(); } var initializer = SpikesMultiMigrateDbToLastestVersion.UsingAutoMigrations(); initializer.InitializeDatabase(db); } }
public void CanInsertSubclassedInstances() { // when using (var db = new SpikesMigrationsDb("SpikesMigrationsDb")) { var dataRole = new DataUserRole { DataRoleProp = "Data 1", Name = "DataRole1", Key = 1 }; var featureRole = new FeatureUserRole { FeatureRoleProp = "Feature 1", Name = "FeatureRole1" }; db.UserRoles.AddRange(new UserRole[] { dataRole, featureRole }); db.SaveChanges(); } // then using (var db = new SpikesMigrationsDb("SpikesMigrationsDb")) { Assert.That(db.UserRoles.ToList().Count, Is.EqualTo(2)); } }
public void CanLoadPolymorphicNavigationProperty() { // given using (var db = new SpikesMigrationsDb("SpikesMigrationsDb")) { var dataRole = new DataUserRole { DataRoleProp = "Data 1", Name = "DataRole1", Key = 2 }; db.UserRoles.Add(dataRole); var asset = new Asset { RequiredUserRole = dataRole, Reference = "Asset1", Title = "Asset 1" }; db.Assets.Add(asset); db.SaveChanges(); } // when, then using (var db = new SpikesMigrationsDb("SpikesMigrationsDb")) { var loadedAsset = db.Assets.First(); Assert.That(loadedAsset.RequiredUserRole, Is.InstanceOf <DataUserRole>()); } }