Example #1
0
        public void DocumentTestUniqueConstraint(SqlEngineVersion version)
        {
            var db = new TestDatabaseUniqueConstraint();

            db.SetVersions(version.GetTypeMapper());
            var documenter = new Documenter(DataDefinitionDocumenterTestsHelper.CreateTestDocumenterContext(version), version, "TestDatabaseUniqueConstraint");

            documenter.Document(db);
        }
Example #2
0
        public void DocumentTestForeignKeyComposite(SqlEngineVersion version)
        {
            var db = new ForeignKeyComposite();

            db.SetVersions(version.GetTypeMapper());
            var documenter = new Documenter(DataDefinitionDocumenterTestsHelper.CreateTestDocumenterContext(version), version, "ForeignKeyComposite");

            documenter.Document(db);
        }
Example #3
0
        public void DocumentTestIndexMultiColumnAndInclude(SqlEngineVersion version)
        {
            var db = new TestDatabaseIndexMultiColumnAndInclude();

            db.SetVersions(version.GetTypeMapper());
            var documenter = new Documenter(DataDefinitionDocumenterTestsHelper.CreateTestDocumenterContext(version), version, "TestDatabaseIndexMultiColumnAndInclude");

            documenter.Document(db);
        }
Example #4
0
        public void TableCustomizerTest(SqlEngineVersion version)
        {
            var db = new TestDatabaseFks();

            db.SetVersions(version.GetTypeMapper());
            var documenter = new Documenter(DataDefinitionDocumenterTestsHelper.CreateTestDocumenterContext(version, new TableCustomizer()), version, "TestDatabaseFks");

            documenter.Document(db);
        }
        public void CircularDdA0B1C1_B2C2(SqlEngineVersion version)
        {
            var dd = new CircularDdA0B1C1_B2C2();

            dd.SetVersions(version.GetTypeMapper());

            var documenter = new Documenter(DataDefinitionDocumenterTestsHelper.CreateTestDocumenterContext(version), version, "CircularDdA0B1C1_B2C2");

            documenter.Document(dd);
        }
        public void CircularFKDetectorABC_X(SqlEngineVersion version)
        {
            var dd = new CircularDdABC_X();

            dd.SetVersions(version.GetTypeMapper());

            var documenter = new Documenter(DataDefinitionDocumenterTestsHelper.CreateTestDocumenterContext(version), version, "CircularDdABC_X");

            documenter.Document(dd);

            // TODO move to dd test
            // CircularFKDetector.DectectCircularFKs(dd.GetTables());
            // var cs = dd.GetTables().Select(t => t.Properties.OfType<CircularFK>()).ToList();
        }
Example #7
0
        public void TableCustomizerFromCsv()
        {
            using (var file =
                       new StreamWriter("TestDatabaseFks.DbTools.Patterns.csv"))
            {
                file.WriteLine("PatternSchema;PatternTableName;PatternExceptSchema;PatternExceptTableName;ShouldSkipIfMatch;CategoryIfMatch;BackGroundColorIfMatch");
                file.WriteLine(";Parent;;;0;Parent;606060");
                file.WriteLine(";Child;;;1");
                file.WriteLine(";*ildC*;;;0;TestCategory");
            }

            var db = new TestDatabaseFks();

            db.SetVersions(GenericVersion.Generic1.GetTypeMapper());
            var patternMatching = PatternMatchingTableCustomizerFromPatterns.FromCsv("TestDatabaseFks", null);
            var documenter      = new Documenter(DataDefinitionDocumenterTestsHelper.CreateTestDocumenterContext(GenericVersion.Generic1, patternMatching), GenericVersion.Generic1, "TestDatabaseFks");

            documenter.Document(db);
        }
Example #8
0
        public void Document(
            [Option(LongName = "connectionString", ShortName = "c")]
            string connectionString,
            [Option(LongName = "sqlType", ShortName = "t")]
            string sqlType,
            [Option(LongName = "patternFileName", ShortName = "p")]
            string patternFileName,
            [Option(LongName = "flags", ShortName = "f")]
            List <string> flags)
        {
            var version = SqlEngineVersions.GetVersion(sqlType);

            var connString = new NamedConnectionString(
                version.GetType().Name,
                version.ProviderName,
                connectionString,
                version.VersionString);

            var context = CreateContext(version);

            var sqlExecuter  = SqlExecuterFactory.CreateSqlExecuter(connString, context);
            var databaseName = sqlExecuter.GetDatabase();

            var ddlReader = DataDefinitionReaderFactory.CreateDataDefinitionReader(connString, context, null);

            var dd = ddlReader.GetDatabaseDefinition();

            var documenterContext = CreateDocumenterContext(context, patternFileName);

            if (flags != null)
            {
                SetSettingsFromFlags(flags, documenterContext.DocumenterSettings);
            }

            var documenter = new Documenter(documenterContext, version, databaseName, null);

            documenter.Document(dd);
        }