コード例 #1
0
ファイル: Tests.cs プロジェクト: zippy1981/plane-disaster
        public void TestCompactMdb()
        {
            string fileName = Path.Combine(_tempDirectory, _tempFilePrefix + ".mdb");
            OleDba oleDba = null;

            try
            {
                CreateMdb(fileName);

                oleDba = new OleDba();
                oleDba.ConnectMDB(fileName);
                PopulateOleDba(oleDba);
                oleDba.Disconnect();

                JetSqlUtil.CompactMDB(fileName);

                oleDba.ConnectMDB();
                oleDba.ExecuteSqlCommand(_sqlDropTable);
                oleDba.Disconnect();
            }
            finally
            {
                if (oleDba != null && oleDba.Connected)
                {
                    oleDba.Disconnect();
                    oleDba.Dispose();
                }
                File.Delete(fileName);
                Assert.IsFalse(File.Exists(fileName), "Failed to delete " + fileName);
            }
        }
コード例 #2
0
ファイル: Tests.cs プロジェクト: zippy1981/plane-disaster
        public void TestProcedureSupport()
        {
            string fileBaseName = Path.Combine(_tempDirectory, _tempFilePrefix);
            OleDba oleDba = null;

            try {
                CreateMdb(fileBaseName + ".mdb");

                oleDba = new OleDba();
                try {
                    Assert.IsTrue(oleDba.SupportsProcedures);
                    Assert.Fail("OleDba.SupportsProcedures should throw a InvalidOperationException if no database is connected.");
                }
                catch(InvalidOperationException) {}

                oleDba.ConnectMDB(fileBaseName + ".mdb");
                Assert.IsTrue(oleDba.SupportsProcedures);;
            }
            finally
            {
                if (oleDba != null && oleDba.Connected)
                {
                    oleDba.Disconnect();
                    oleDba.Dispose();
                }
                File.Delete(fileBaseName + ".mdb");
                Assert.IsFalse(File.Exists(fileBaseName + ".mdb"), "Failed to delete " + fileBaseName + ".mdb");
            }
        }