public async Task SetupAlreadyExists() { var TestObject = new SQLServerSchemaGenerator(Canister.Builder.Bootstrapper.ResolveAll <ISourceBuilder>(), Canister.Builder.Bootstrapper.ResolveAll <ICommandBuilder>(), Canister.Builder.Bootstrapper.Resolve <IConfiguration>(), Helper, Helper); var Source = await TestObject.GetSourceStructureAsync(new Connection(Configuration, SqlClientFactory.Instance, "", "Default")).ConfigureAwait(false); Source.Tables[0].AddColumn <int>("Column B", System.Data.DbType.Int32); await TestObject.SetupAsync(Source, new Connection(Configuration, SqlClientFactory.Instance, "", "Default")).ConfigureAwait(false); }
public async Task GenerateSchemaNoChanges() { var TestObject = new SQLServerSchemaGenerator(Canister.Builder.Bootstrapper.ResolveAll <ISourceBuilder>(), Canister.Builder.Bootstrapper.ResolveAll <ICommandBuilder>(), Canister.Builder.Bootstrapper.Resolve <IConfiguration>(), Helper, Helper); var Source = await TestObject.GetSourceStructureAsync(new Connection(Configuration, SqlClientFactory.Instance, "", "Default")).ConfigureAwait(false); var Result = TestObject.GenerateSchema(Source, Source); Assert.NotNull(Result); Assert.Empty(Result); }
public async Task GetSourceStructure() { var TestObject = new SQLServerSchemaGenerator(Canister.Builder.Bootstrapper.ResolveAll <ISourceBuilder>(), Canister.Builder.Bootstrapper.ResolveAll <ICommandBuilder>(), Canister.Builder.Bootstrapper.Resolve <IConfiguration>(), Helper, Helper); var Source = await TestObject.GetSourceStructureAsync(new Connection(Configuration, SqlClientFactory.Instance, "", "Default")).ConfigureAwait(false); Assert.Equal(6, Source.Tables.Count); Assert.Empty(Source.Functions); Assert.Equal("TestDatabase", Source.Name); Assert.Empty(Source.StoredProcedures); Assert.Empty(Source.Views); }
public async Task SchemaGenerationTimeSpan() { var TestObject = new SQLServerSchemaGenerator(Canister.Builder.Bootstrapper.ResolveAll <ISourceBuilder>(), Canister.Builder.Bootstrapper.ResolveAll <ICommandBuilder>(), Canister.Builder.Bootstrapper.Resolve <IConfiguration>(), Helper, Helper); var Source = await TestObject.GetSourceStructureAsync(new Connection(Configuration, SqlClientFactory.Instance, "", "Default2")).ConfigureAwait(false); var Destination = new Modeler.Providers.Source("Default2"); var Table = Destination.AddTable("AllReferencesAndID_", "dbo"); Table.AddColumn <TimeSpan>("TimeSpanValue_", typeof(TimeSpan).To <DbType>()); var Results = TestObject.GenerateSchema(Destination, Source); Assert.Empty(Results); }
public async Task GenerateSchemaChanges() { var TestObject = new SQLServerSchemaGenerator(Canister.Builder.Bootstrapper.ResolveAll <ISourceBuilder>(), Canister.Builder.Bootstrapper.ResolveAll <ICommandBuilder>(), Canister.Builder.Bootstrapper.Resolve <IConfiguration>(), Helper, Helper); var Source = await TestObject.GetSourceStructureAsync(new Connection(Configuration, SqlClientFactory.Instance, "", "Default")).ConfigureAwait(false); var Desired = Source.Copy(); Desired.Tables[0].AddColumn <int>("Column B", System.Data.DbType.Int32); var Result = TestObject.GenerateSchema(Desired, Source); Assert.NotNull(Result); Assert.Single(Result); Assert.Equal("ALTER TABLE [dbo].[Attachment] ADD [Column B] Int", Result[0]); }
public async Task SchemaGenerationForeignKeysAlreadyExist() { var TestObject = new SQLServerSchemaGenerator(Canister.Builder.Bootstrapper.ResolveAll <ISourceBuilder>(), Canister.Builder.Bootstrapper.ResolveAll <ICommandBuilder>(), Canister.Builder.Bootstrapper.Resolve <IConfiguration>(), Helper, Helper); var Source = await TestObject.GetSourceStructureAsync(new Connection(Configuration, SqlClientFactory.Instance, "", "Default2")).ConfigureAwait(false); var Destination = new Modeler.Providers.Source("Default2"); var Table = Destination.AddTable("ConcreteClass3_", "dbo"); var Column1 = Table.AddColumn <int>("IInterface1_ID_", typeof(int).To <DbType>()); var Table2 = Destination.AddTable("IInterface1_", "dbo"); Table2.AddColumn <int>("ID_", typeof(int).To <DbType>()); Column1.AddForeignKey("IInterface1_", "ID_"); Table.SetupForeignKeys(); var Results = TestObject.GenerateSchema(Destination, Source); Assert.Empty(Results); }
public async Task SetupDoesntExists() { var TestObject = new SQLServerSchemaGenerator(Canister.Builder.Bootstrapper.ResolveAll <ISourceBuilder>(), Canister.Builder.Bootstrapper.ResolveAll <ICommandBuilder>(), Canister.Builder.Bootstrapper.Resolve <IConfiguration>(), Helper, Helper); var Source = await TestObject.GetSourceStructureAsync(new Connection(Configuration, SqlClientFactory.Instance, "", "Default")).ConfigureAwait(false); Source.Tables[0].AddColumn <int>("Column B", System.Data.DbType.Int32); Source.Name = "TestDatabase2"; await TestObject.SetupAsync(Source, new Connection(Configuration, SqlClientFactory.Instance, "", "DefaultNew")).ConfigureAwait(false); await TestObject.SourceExistsAsync("TestDatabase2", new Connection(Configuration, SqlClientFactory.Instance, "", "DefaultNew")).ConfigureAwait(false); using var TempConnection = SqlClientFactory.Instance.CreateConnection(); TempConnection.ConnectionString = MasterString; using var TempCommand = TempConnection.CreateCommand(); try { TempCommand.CommandText = "ALTER DATABASE TestDatabase2 SET OFFLINE WITH ROLLBACK IMMEDIATE\r\nALTER DATABASE TestDatabase2 SET ONLINE\r\nDROP DATABASE TestDatabase2"; TempCommand.Open(); TempCommand.ExecuteNonQuery(); } finally { TempCommand.Close(); } }