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

            foreach (var definitionSet in _overrides)
            {
                _collection.ApplyDefinitions(definitionSet);
            }
        }
예제 #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();
        }
예제 #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();
        }
예제 #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%'");
        }
예제 #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]");
        }
예제 #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();
        }
예제 #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();
        }