Exemple #1
0
 public void LoadSchemaOverrides(Type containerType)
 {
     lock (_lock)
     {
         if (_collectionConfigured)
         {
             throw new ConfigurationCannotBeChangedException();
         }
         _overrides.Add(SnapshotDefinitionLoader.Load(containerType));
     }
 }
Exemple #2
0
 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();
        }
Exemple #4
0
        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();
        }
Exemple #7
0
        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();
        }
Exemple #8
0
        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();
        }
Exemple #9
0
        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%'");
        }
Exemple #10
0
        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]");
        }
Exemple #11
0
        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();
        }