public async Task TestAddColumnToSchema() { await this.TestCreateSchema(); this.BaselineSchema.Columns["NewColumn"] = new ColumnSchema() { Name = "NewColumn", SqlType = SqlDbType.DateTime }; var plan = await this.Migrator.PlanMigration( connection : this.Connection, targetManager : this.Manager, targetSchema : this.BaselineSchema, options : this.Options ); Assert.IsNotNull(plan.Existing, "Existing schema should not be null"); Assert.AreEqual(1, plan.Steps.Count, "Only plan step should be create column"); Assert.AreEqual(MigrationAction.Create, plan.Steps[0].Action, "Only action should be create column"); Assert.AreEqual("NewColumn", plan.Steps[0].TargetName, "Only step should target the column"); Assert.AreEqual(MigrationTarget.Column, plan.Steps[0].TargetType, "Only step should target the column"); await this.Migrator.ExecuteMigration( targetManager : this.Manager, connection : this.Connection, plan : plan ); var migratedSchema = await this.Manager.GetSchema(this.Connection, this.BaselineSchema.Name); SchemaAssertions.AssertObjectSchemasEqual(this.BaselineSchema, migratedSchema); }
public async Task BaseTestCreateColumnForAllTypes() { var mapper = new TypeMapper(); var jumboSchema = new ObjectSchema() { Name = this.BaselineSchema.Name }; jumboSchema.Columns["Id"] = new ColumnSchema() { Name = "Id", KeyIndex = 1, SqlType = SqlDbType.Int }; foreach (var type in mapper.Mappings.SelectMany(m => m.Value)) { string name = $"Column{type.SqlType.ToString()}"; jumboSchema.Columns[name] = new ColumnSchema() { Name = name, Nullable = false, SqlType = type.SqlType, MaxLength = type.HasLength ? (int?)100 : null }; } await this.Manager.CreateObject(this.Connection, jumboSchema); var fetchedSchema = await this.Manager.GetSchema(this.Connection, jumboSchema.Name); Assert.IsNotNull(fetchedSchema, "Existant schema should return non-null"); SchemaAssertions.AssertObjectSchemasEqual(jumboSchema, fetchedSchema); }
public async Task TestCreateSchema() { var plan = await this.Migrator.PlanMigration( connection : this.Connection, targetManager : this.Manager, targetSchema : this.BaselineSchema, options : this.Options ); Assert.IsNull(plan.Existing, "Existing schema should be null"); SchemaAssertions.AssertObjectSchemasEqual(this.BaselineSchema, plan.Target); Assert.AreEqual(1, plan.Steps.Count, "Only plan step should be create"); Assert.AreEqual(MigrationAction.Create, plan.Steps[0].Action, "Only action should be create"); Assert.AreEqual(this.BaselineSchema.Name, plan.Steps[0].TargetName, "Only step should target the table"); Assert.AreEqual(MigrationTarget.Object, plan.Steps[0].TargetType, "Only step should target the table"); await this.Migrator.ExecuteMigration( targetManager : this.Manager, connection : this.Connection, plan : plan ); var migratedSchema = await this.Manager.GetSchema(this.Connection, this.BaselineSchema.Name); SchemaAssertions.AssertObjectSchemasEqual(this.BaselineSchema, migratedSchema); }
public async Task BaseTestGetSchemaCreatedSchema() { await this.Manager.CreateObject(this.Connection, this.BaselineSchema); var fetchedSchema = await this.Manager.GetSchema(this.Connection, this.BaselineSchema.Name); Assert.IsNotNull(fetchedSchema, "Existant schema should return non-null"); SchemaAssertions.AssertObjectSchemasEqual(this.BaselineSchema, fetchedSchema); }
public async Task TestGetSchemaIsCached() { await this.CachedManager.CreateObject(this.Connection, this.BaselineSchema); SchemaAssertions.AssertObjectSchemasEqual(this.BaselineSchema, this.SchemaCache.Get(this.BaselineSchema.Name)); await this.SqlLiteManager.DeleteObject(this.Connection, this.BaselineSchema.Name); var fetchedSchema = await this.CachedManager.GetSchema(this.Connection, this.BaselineSchema.Name); SchemaAssertions.AssertObjectSchemasEqual(this.BaselineSchema, fetchedSchema); }
public async Task TestUpdateSchemaIsUpdatedIntoCache() { await this.CachedManager.CreateObject(this.Connection, this.BaselineSchema); SchemaAssertions.AssertObjectSchemasEqual(this.BaselineSchema, this.SchemaCache.Get(this.BaselineSchema.Name)); var newCol = new ColumnSchema() { Name = "NewCol", SqlType = SqlDbType.Bit }; this.BaselineSchema.Columns["NewCol"] = newCol; await this.CachedManager.CreateColumn(this.Connection, this.BaselineSchema.Name, newCol); SchemaAssertions.AssertObjectSchemasEqual(this.BaselineSchema, this.SchemaCache.Get(this.BaselineSchema.Name)); }
public async Task BaseTestAddColumnOnSchema() { await this.Manager.CreateObject(this.Connection, this.BaselineSchema); var newColumn = new ColumnSchema() { Name = "NewColumn", SqlType = SqlDbType.Date }; this.BaselineSchema.Columns[newColumn.Name] = newColumn; await this.Manager.CreateColumn(this.Connection, this.BaselineSchema.Name, newColumn); var fetchedSchema = await this.Manager.GetSchema(this.Connection, this.BaselineSchema.Name); Assert.IsNotNull(fetchedSchema, "Existant schema should return non-null"); SchemaAssertions.AssertObjectSchemasEqual(this.BaselineSchema, fetchedSchema); }
public void TestParseObjectWithName() { var extractedSchema = this.Extractor.GetObjectSchema(typeof(TestObject), "TestTable"); SchemaAssertions.AssertObjectSchemasEqual(this.ExpectedSchema, extractedSchema); }