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 Start()
        {
            if (!TestHelper.GetDlcPath(out string dlcPath))
            {
                return;
            }

            var ope = new UoeDatabaseOperator(dlcPath);

            var tgtDb = GetDb("start");

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

            Assert.AreEqual(DatabaseBusyMode.NotBusy, ope.GetBusyMode(tgtDb));

            var nextPort = UoeDatabaseOperator.GetNextAvailablePort();

            try {
                ope.Start(tgtDb, "localhost", nextPort.ToString(), new UoeProcessArgs().Append("-minport", "50000", "-maxport", "50100", "-L", "20000") as UoeProcessArgs);

                Assert.AreEqual(DatabaseBusyMode.MultiUser, ope.GetBusyMode(tgtDb));
            } finally {
                ope.Kill(tgtDb);
            }

            Assert.AreEqual(DatabaseBusyMode.NotBusy, ope.GetBusyMode(tgtDb));
        }
        public void AddAndRemoveExtents()
        {
            if (!TestHelper.GetDlcPath(out string dlcPath))
            {
                return;
            }

            var ope = new UoeDatabaseOperator(dlcPath);

            var tgtDb = GetDb("extents");

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

            var stPath = Path.Combine(TestFolder, "extents_add.st");

            File.WriteAllText(stPath, $"d \"Data Area\" \"{TestFolder}\"");

            ope.AddStructureDefinition(tgtDb, stPath);

            try {
                ope.Start(tgtDb);
                File.WriteAllText(stPath, $"d \"New Area\" \"{TestFolder}\"");
                ope.AddStructureDefinition(tgtDb, stPath);
            } finally {
                ope.Stop(tgtDb);
            }

            Assert.IsTrue(File.Exists(Path.Combine(TestFolder, "extents_7.d1")));
            Assert.IsTrue(File.Exists(Path.Combine(TestFolder, "extents_8.d1")));

            ope.RemoveStructureDefinition(tgtDb, "d", "Data Area");

            Assert.IsFalse(File.Exists(Path.Combine(TestFolder, "extents_7.d1")));
        }
        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);
            }
        }