Esempio n. 1
0
        private void ApplyConfig()
        {
            foreach (var schema in _schemas.Values)
            {
                SnapshotTableDefiner.Define(_collection, schema);
            }

            foreach (var definitionSet in _overrides)
            {
                _collection.ApplyDefinitions(definitionSet);
            }
        }
Esempio n. 2
0
        public void BasicTableStructureIsLoaded()
        {
            //Arrange
            var collection = new SnapshotCollection();

            //Act
            SnapshotTableDefiner.Define(collection, _schema);

            //Assert
            var output = new Output();

            collection.GetSchemaReport(output, true);
            output.Report.Verify();
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
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%'");
        }
Esempio n. 5
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]");
        }
Esempio n. 6
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();
        }
Esempio n. 7
0
        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();
        }