public void LoadSchemaOverrides(Type containerType) { lock (_lock) { if (_collectionConfigured) { throw new ConfigurationCannotBeChangedException(); } _overrides.Add(SnapshotDefinitionLoader.Load(containerType)); } }
public void LoadSchemaOverrides(Assembly assembly) { lock (_lock) { if (_collectionConfigured) { throw new ConfigurationCannotBeChangedException(); } _overrides.Add(SnapshotDefinitionLoader.Load(assembly)); } }
public void DefinitionsAreLoadedFromEnclosingType() { //Act var definition = SnapshotDefinitionLoader.Load(GetType()); //Assert var output = new Output(); TableDefinitionReporter.Report(definition.Tables, output); output.Report.Verify(); }
public void DefinitionsAreLoadedFromAssembly() { //Arrange var definition = SnapshotDefinitionLoader.Load(GetType(), t => t.Name.StartsWith("A_")); //Act var loaded = DefinitionSetMerger.Merge(definition, null).ToList(); //Assert var output = new Output(); TableDefinitionReporter.Report(loaded, output); output.Report.Verify(); }
public void DefinitionsAreFilteredWhenLoadedFromEnclosingType() { //Arrange var assembly = GetType().Assembly; //Act var definition = SnapshotDefinitionLoader.Load(GetType(), t => t != typeof(TableDef)); //Assert var output = new Output(); TableDefinitionReporter.Report(definition.Tables, output); output.Report.Verify(); }
public void DefinitionsAreLoadedFromAssembly() { //Arrange var assembly = GetType().Assembly; //Act var definition = SnapshotDefinitionLoader.Load(assembly); //Assert var output = new Output(); TableDefinitionReporter.Report(definition.Tables, output); output.Report.Verify(); }
public void TableDefinitionsCanBeApplied() { //Arrange var definitionSet = SnapshotDefinitionLoader.Load(GetType()); var snapshots = new SnapshotCollection(); //Act snapshots.ApplyDefinitions(definitionSet); //Assert var output = new Output(); snapshots.GetSchemaReport(output, true); output.Report.Verify(); }
public void AppliedDefinitionsAreMerged() { //Arrange var definitionSet = SnapshotDefinitionLoader.Load(GetType()); var snapshots = new SnapshotCollection(); snapshots.DefineTable("LocalTable").CompareKey("Name"); //Act snapshots.ApplyDefinitions(definitionSet); //Assert var output = new Output(); snapshots.GetSchemaReport(output, true); 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(); }