예제 #1
0
        public void DumpDf()
        {
            if (!TestHelper.GetDlcPath(out string dlcPath))
            {
                return;
            }

            var db     = GetDb("dumpdf");
            var dfPath = Path.Combine(TestFolder, $"{db.PhysicalName}.df");

            // create .df
            File.WriteAllText(dfPath, "ADD SEQUENCE \"sequence1\"\n  INITIAL 0\n  INCREMENT 1\n  CYCLE-ON-LIMIT no\n\nADD TABLE \"table1\"\n  AREA \"Schema Area\"\n  DESCRIPTION \"table one\"\n  DUMP-NAME \"table1\"\n\nADD FIELD \"field1\" OF \"table1\" AS character \n  DESCRIPTION \"field one\"\n  FORMAT \"x(8)\"\n  INITIAL \"\"\n  POSITION 2\n  MAX-WIDTH 16\n  ORDER 10\n\nADD INDEX \"idx_1\" ON \"table1\" \n  AREA \"Schema Area\"\n  PRIMARY\n  INDEX-FIELD \"field1\" ASCENDING\n");

            using (var dataAdmin = new UoeDatabaseAdministrator(dlcPath)) {
                dataAdmin.CreateWithDf(db, dfPath);

                var dfPathOut = Path.Combine(TestFolder, "dumpdf_out.df");
                dataAdmin.DumpSchemaDefinition(UoeDatabaseConnection.NewSingleUserConnection(db), dfPathOut);

                Assert.IsTrue(File.Exists(dfPathOut));
                Assert.IsTrue(File.ReadAllText(dfPathOut).Contains("field1"));

                var dumpOut = Path.Combine(TestFolder, "dump_custom.txt");
                dataAdmin.DumpCustomInfoExtraction(UoeDatabaseConnection.NewSingleUserConnection(db), dumpOut);

                Assert.IsTrue(File.Exists(dumpOut));
                Assert.IsTrue(File.ReadAllText(dumpOut).Contains("field1"));
            }
        }