public void InvalidDatabaseNameThrows() { //Arrange DbController.Run(CreateTables); //Act Action action = () => SchemaStructureLoader.Load(DbController.Server, "Wrong", "Test"); //Assert action.Should().Throw<DatabaseNotFoundException>().Where(e => e.Server == DbController.Server && e.Database == "Wrong"); }
public void RelationshipsAreExtracted() { //Arrange DbController.Run(CreateRelatedTables); //Act var result = SchemaStructureLoader.Load(DbController.Server, DbController.TestDbName, "Test"); //Assert var output = new Output(); result.Report(output); output.Report.Verify(); }
public void BasicTableStructureIsLoaded() { //Arrange DbController.Run(CreateTables); //Act var result = SchemaStructureLoader.Load(DbController.Server, DbController.TestDbName, "Test"); //Assert var output = new Output(); result.Report(output); output.Report.Verify(); }
public void TableContentsAreAddedToSnapshot() { //Arrange var collection = new SnapshotCollection(); var schema = SchemaStructureLoader.Load(DbController.Server, DbController.TestDbName, "Test"); var builder = collection.NewSnapshot("Test"); SnapshotTableDefiner.Define(collection, schema); //Act DbSnapshotMaker.Make(DbController.ConnectionString, builder, new [] { schema }, collection); //Assert var output = new Output(); collection.GetSnapshotReport("Test", output); output.Report.Verify(); }
public void ExcludedColumnsAreNotGenerated() { //Arrange var collection = new SnapshotCollection(); var schema = SchemaStructureLoader.Load(DbController.Server, DbController.TestDbName, "Test"); SnapshotTableDefiner.Define(collection, schema); var definitions = SnapshotDefinitionLoader.Load(GetType()); collection.ApplyDefinitions(definitions); var table = schema.Tables.Single(t => t.Name == "[Test].[B_Related]"); //Act var select = SnapshotTableSelectBuilder.Build(table, collection.GetTableDefinition(table.Name)); //Assert select.Should().Be("SELECT * FROM [Test].[B_Related] WHERE [Name] LIKE 'First%'"); }
public void BasicSelectIsBuilt() { //Arrange var collection = new SnapshotCollection(); var schema = SchemaStructureLoader.Load(DbController.Server, DbController.TestDbName, "Test"); SnapshotTableDefiner.Define(collection, schema); var definitions = SnapshotDefinitionLoader.Load(GetType()); collection.ApplyDefinitions(definitions); var table = schema.Tables.First(); //Act var select = SnapshotTableSelectBuilder.Build(table, collection.GetTableDefinition(table.Name)); //Assert select.Should().Be("SELECT * FROM [Test].[A_Main]"); }
public void CustomWhereClauseIsLoadedFromDefinition() { //Arrange var collection = new SnapshotCollection(); var schema = SchemaStructureLoader.Load(DbController.Server, DbController.TestDbName, "Test"); var builder = collection.NewSnapshot("Test"); SnapshotTableDefiner.Define(collection, schema); var definitions = SnapshotDefinitionLoader.Load(GetType()); collection.ApplyDefinitions(definitions); //Act DbSnapshotMaker.Make(DbController.ConnectionString, builder, new [] { schema }, collection); //Assert var output = new Output(); collection.GetSnapshotReport("Test", output); output.Report.Verify(); }
public void ExcludedColumnsAreNotAddedToSnapshot() { //Arrange var collection = new SnapshotCollection(); var schema = SchemaStructureLoader.Load(DbController.Server, DbController.TestDbName, "Test"); var builder = collection.NewSnapshot("Test"); SnapshotTableDefiner.Define(collection, schema); collection.DefineTable("[Test].[B_Related]").Exclude("Name"); //Act DbSnapshotMaker.Make(DbController.ConnectionString, builder, new [] { schema }, collection); //Assert var output = new Output(); output.WrapLine("The Name column should not be present in [Test].[B_Related] below:"); output.WriteLine(); collection.GetSnapshotReport("Test", output); output.Report.Verify(); }
public void ConfigureSchema(string schema) { var connectionStringBuilder = new SqlConnectionStringBuilder(_connectionString); _schemas[schema] = SchemaStructureLoader.Load(connectionStringBuilder.DataSource, connectionStringBuilder.InitialCatalog, schema); }
public TestSnapshotTableDefiner() { DbController.TearDown(); DbController.Run(CreateRelatedTables); _schema = SchemaStructureLoader.Load(DbController.Server, DbController.TestDbName, "Test"); }