Esempio n. 1
0
        /// <summary>
        /// Run the basic test.
        /// </summary>
        public static void Main()
        {
            const string Table = "testtable";

            DateTime startTime = DateTime.Now;

            CreateDirectory(DirectoryPath);

            const int CacheSizeInBytes = 32 * 1024 * 0124;
            SystemParameters.DatabasePageSize = 8192;
            SystemParameters.CacheSizeMin = CacheSizeInBytes / SystemParameters.DatabasePageSize;
            SystemParameters.CacheSizeMax = CacheSizeInBytes / SystemParameters.DatabasePageSize;

            // Create an instance, session and database
            JET_INSTANCE instance = CreateInstance();
            JET_SESID sesid;
            JET_DBID dbid;
            Api.JetBeginSession(instance, out sesid, null, null);
            Api.JetCreateDatabase(sesid, Database, null, out dbid, CreateDatabaseGrbit.None);
            Api.JetCloseDatabase(sesid, dbid, CloseDatabaseGrbit.None);
            Api.JetDetachDatabase(sesid, Database);
            Api.JetAttachDatabase(sesid, Database, AttachDatabaseGrbit.None);
            Api.JetOpenDatabase(sesid, Database, null, out dbid, OpenDatabaseGrbit.None);

            // DDL creation
            // Creates the tables/columns/indexes used by the DDLTest
            var ddltests = new DdlTests(sesid, dbid, Table);
            ddltests.Create();

            // DMLTests
            // Create/Retrieve/Update/Delete records
            var dmltests = new DmlTests(instance, Database, Table);
            dmltests.Create();
            dmltests.Term();

            // DDL update
            // Delete a column/index and add a new index
            ddltests.Update();

            // Temp table tests
            var temptabletests = new TempTableTests(instance);
            temptabletests.Run();

            // Run recovery
            Api.JetStopServiceInstance(instance);
            Api.JetEndSession(sesid, EndSessionGrbit.None);
            try
            {
                Api.JetTerm2(instance, Windows7Grbits.Dirty);
            }
            catch (EsentDirtyShutdownException)
            {
            }

            RecoveryTests(Table);

            Directory.Delete(DirectoryPath, true);

            DateTime endTime = DateTime.Now;
            TimeSpan timespan = endTime - startTime;
            Console.WriteLine("Test completed in {0}", timespan);
        }
Esempio n. 2
0
        /// <summary>
        /// Run the basic test.
        /// </summary>
        public static void Main()
        {
            const string Table = "testtable";

            DateTime startTime = DateTime.Now;

            CreateDirectory(DirectoryPath);

            const int CacheSizeInBytes = 32 * 1024 * 0124;

            SystemParameters.DatabasePageSize = 8192;
            SystemParameters.CacheSizeMin     = CacheSizeInBytes / SystemParameters.DatabasePageSize;
            SystemParameters.CacheSizeMax     = CacheSizeInBytes / SystemParameters.DatabasePageSize;

            // Create an instance, session and database
            JET_INSTANCE instance = CreateInstance();
            JET_SESID    sesid;
            JET_DBID     dbid;

            Api.JetBeginSession(instance, out sesid, null, null);
            Api.JetCreateDatabase(sesid, Database, null, out dbid, CreateDatabaseGrbit.None);
            Api.JetCloseDatabase(sesid, dbid, CloseDatabaseGrbit.None);
            Api.JetDetachDatabase(sesid, Database);
            Api.JetAttachDatabase(sesid, Database, AttachDatabaseGrbit.None);
            Api.JetOpenDatabase(sesid, Database, null, out dbid, OpenDatabaseGrbit.None);

            // DDL creation
            // Creates the tables/columns/indexes used by the DDLTest
            var ddltests = new DdlTests(sesid, dbid, Table);

            ddltests.Create();

            // DMLTests
            // Create/Retrieve/Update/Delete records
            var dmltests = new DmlTests(instance, Database, Table);

            dmltests.Create();
            dmltests.Term();

            // DDL update
            // Delete a column/index and add a new index
            ddltests.Update();

            // Temp table tests
            var temptabletests = new TempTableTests(instance);

            temptabletests.Run();

            // Run recovery
            Api.JetStopServiceInstance(instance);
            Api.JetEndSession(sesid, EndSessionGrbit.None);
            try
            {
                Api.JetTerm2(instance, Windows7Grbits.Dirty);
            }
            catch (EsentDirtyShutdownException)
            {
            }

            RecoveryTests(Table);

            Directory.Delete(DirectoryPath, true);

            DateTime endTime  = DateTime.Now;
            TimeSpan timespan = endTime - startTime;

            Console.WriteLine("Test completed in {0}", timespan);
        }