public void OeExecution_Test_DbConnection_ok()
        {
            if (!GetEnvExecution(out UoeExecutionEnv env))
            {
                return;
            }
            env.UseProgressCharacterMode = true;

            // generate temp base
            var db   = new UoeDatabaseOperator(env.DlcDirectoryPath);
            var dbPn = new UoeDatabaseLocation(Path.Combine(TestFolder, "test1.db"));

            db.Create(dbPn);
            Assert.IsTrue(dbPn.Exists());

            // generate temp base
            var dbPn2 = new UoeDatabaseLocation(Path.Combine(TestFolder, "test2.db"));

            db.Create(dbPn2);
            Assert.IsTrue(dbPn2.Exists());

            // try if connected well and can manage aliases
            env.DatabaseConnections = new [] { db.GetDatabaseConnection(dbPn), db.GetDatabaseConnection(dbPn2) };
            env.DatabaseAliases     = new List <IUoeExecutionDatabaseAlias> {
                new UoeExecutionDatabaseAlias {
                    DatabaseLogicalName = "test1",
                    AliasLogicalName    = "alias1"
                },
                new UoeExecutionDatabaseAlias {
                    DatabaseLogicalName = "test1",
                    AliasLogicalName    = "alias2"
                },
                new UoeExecutionDatabaseAlias {
                    DatabaseLogicalName = "test2",
                    AliasLogicalName    = "alias3"
                }
            };
            using (var exec = new UoeExecutionCustomTest(env)) {
                exec.NeedDatabaseConnection = true;
                exec.ProgramContent         = @"
                DEFINE VARIABLE li_db AS INTEGER NO-UNDO.
                REPEAT li_db = 1 TO NUM-ALIASES:
                    PUT UNFORMATTED ALIAS(li_db) SKIP.
                END.";
                exec.ExecuteNoWait();
                exec.WaitForExit();
                Assert.IsFalse(exec.ExecutionHandledExceptions, "ok");
                Assert.AreEqual("dictdb alias1 alias2 alias3", new StringBuilder(exec.Output).CliCompactWhitespaces().ToString());
            }
            env.Dispose();
        }
        public void TruncateLog()
        {
            if (!TestHelper.GetDlcPath(out string dlcPath))
            {
                return;
            }

            var ope = new UoeDatabaseOperator(dlcPath);
            var db  = GetDb("trunclog");

            ope.Create(db);
            Assert.IsTrue(db.Exists());

            ope.TruncateLog(db);

            try {
                ope.Start(db);

                var oldSize = new FileInfo(Path.Combine(TestFolder, "trunclog.lg")).Length;

                ope.TruncateLog(db);

                var newSize = new FileInfo(Path.Combine(TestFolder, "trunclog.lg")).Length;

                Assert.AreNotEqual(oldSize, newSize);

                var cs = ope.GetDatabaseConnection(db);
                Assert.IsFalse(cs.SingleUser);
                Assert.IsTrue(string.IsNullOrEmpty(cs.Service));
            } finally {
                ope.Kill(db);
            }
        }
        public void GetConnectionString()
        {
            if (!TestHelper.GetDlcPath(out string dlcPath))
            {
                return;
            }

            var ope = new UoeDatabaseOperator(dlcPath);
            var db  = GetDb("connec");

            ope.Create(db);

            Assert.IsTrue(ope.GetDatabaseConnection(db).SingleUser);
            Assert.IsTrue(string.IsNullOrEmpty(ope.GetDatabaseConnection(db).Service));
            Assert.AreEqual(null, ope.GetDatabaseConnection(db).LogicalName);
            Assert.AreEqual("test", ope.GetDatabaseConnection(db, "test").LogicalName);

            try {
                ope.Start(db);

                Assert.IsFalse(ope.GetDatabaseConnection(db).SingleUser);
                Assert.IsTrue(string.IsNullOrEmpty(ope.GetDatabaseConnection(db).Service));
            } finally {
                ope.Kill(db);
            }

            try {
                ope.Start(db, null, UoeDatabaseOperator.GetNextAvailablePort().ToString());

                Assert.IsFalse(ope.GetDatabaseConnection(db).SingleUser);
                Assert.IsFalse(string.IsNullOrEmpty(ope.GetDatabaseConnection(db).Service));
                Assert.IsFalse(string.IsNullOrEmpty(ope.GetDatabaseConnection(db).HostName));
            } finally {
                ope.Kill(db);
            }
        }