public static SetLightweightConfiguration ( Microsoft.Isam.Esent.Interop.Instance instance ) : void | ||
instance | Microsoft.Isam.Esent.Interop.Instance | The instance to configure. |
Результат | void |
public void VerifyJetSetSessionContextAllowsThreadMigration() { using (var instance = new Instance("JetSetSessionContext")) { SetupHelper.SetLightweightConfiguration(instance); instance.Init(); using (var session = new Session(instance)) { // Without the calls to JetSetSessionContext/JetResetSessionContext // this will generate a session sharing violation. var context = new IntPtr(Any.Int32); var thread = new Thread(() => { Thread.BeginThreadAffinity(); Api.JetSetSessionContext(session, context); Api.JetBeginTransaction(session); Api.JetResetSessionContext(session); Thread.EndThreadAffinity(); }); thread.Start(); thread.Join(); Api.JetSetSessionContext(session, context); Api.JetCommitTransaction(session, CommitTransactionGrbit.None); Api.JetResetSessionContext(session); } } }
public void GetDatabaseFileInfoOnVista() { if (!EsentVersion.SupportsVistaFeatures) { return; } string directory = SetupHelper.CreateRandomDirectory(); string database = Path.Combine(directory, "test.db"); using (var instance = new Instance("VistaJetGetDatabaseFileInfo")) { SetupHelper.SetLightweightConfiguration(instance); instance.Init(); using (var session = new Session(instance)) { JET_DBID dbid; Api.JetCreateDatabase(session, database, string.Empty, out dbid, CreateDatabaseGrbit.None); } } JET_DBINFOMISC dbinfomisc; Api.JetGetDatabaseFileInfo(database, out dbinfomisc, JET_DbInfo.Misc); Assert.AreEqual(SystemParameters.DatabasePageSize, dbinfomisc.cbPageSize); Cleanup.DeleteDirectoryWithRetry(directory); }
/// <summary> /// Create an instance and abandon it. Garbage collection should /// be able to finalize the instance. /// </summary> private static void CreateOneInstance() { var instance = new Instance("finalize_me"); SetupHelper.SetLightweightConfiguration(instance); instance.Init(); }
/// <summary> /// Init and term an instance. This is used to make sure the instance /// is always cleaned up when the thread is terminated. If the cleanup /// is missed the next instance create will fail. /// </summary> /// <param name="instanceName"> /// The name of the instance to create. /// </param> private static void InstanceInitTermThread(string instanceName) { try { while (true) { using (var instance = new Instance(instanceName)) { SetupHelper.SetLightweightConfiguration(instance); instance.Init(); instance.Term(); } } } catch (ThreadAbortException) { // Actually letting the thread abort will fail the test, exit // gracefully instead. Thread.ResetAbort(); } catch (EsentErrorException ex) { Console.WriteLine("Got exception {0}", ex); Assert.Fail("Got exception {0}", ex); } }
public void JetInstanceThrowsExceptionWhenInstanceIsClosed() { var instance = new Instance("closed"); SetupHelper.SetLightweightConfiguration(instance); instance.Init(); instance.Term(); JET_INSTANCE x = instance.JetInstance; }
public void Setup() { Cleanup.DeleteDirectoryWithRetry(TestDirectory); Directory.CreateDirectory(TestDirectory); this.testInstance = new Instance("HowDoI"); SetupHelper.SetLightweightConfiguration(this.testInstance); this.testInstance.Init(); this.testSession = new Session(this.testInstance); Api.JetCreateDatabase(this.testSession, TestDatabase, null, out this.testDbid, CreateDatabaseGrbit.OverwriteExisting); }
public void TestJetConfigureProcessForCrashDump() { if (!EsentVersion.SupportsWindows7Features) { return; } using (var instance = new Instance("TestJetConfigureProcessForCrashDump")) { SetupHelper.SetLightweightConfiguration(instance); instance.Init(); Windows7Api.JetConfigureProcessForCrashDump(CrashDumpGrbit.Maximum); } }
public void CreateDatabase2WithAsciiPath() { using (var instance = new Instance("asciidbcreate")) { SetupHelper.SetLightweightConfiguration(instance); instance.Parameters.CreatePathIfNotExist = true; instance.Init(); using (var session = new Session(instance)) { JET_DBID dbid; Api.JetCreateDatabase2(session, this.database, 1024, out dbid, CreateDatabaseGrbit.None); Assert.IsTrue(File.Exists(this.database)); } } }
public void DetachDatabaseWithAsciiPath() { using (var instance = new Instance("asciidbdetach")) { SetupHelper.SetLightweightConfiguration(instance); instance.Parameters.CreatePathIfNotExist = true; instance.Init(); using (var session = new Session(instance)) { JET_DBID dbid; Api.JetCreateDatabase(session, this.database, string.Empty, out dbid, CreateDatabaseGrbit.None); Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None); Api.JetDetachDatabase(session, this.database); } } }
public void CreateDatabase2WithUnicodePath() { if (!EsentVersion.SupportsUnicodePaths) { return; } using (var instance = new Instance("unicodedbcreate")) { SetupHelper.SetLightweightConfiguration(instance); instance.Parameters.CreatePathIfNotExist = true; instance.Init(); using (var session = new Session(instance)) { JET_DBID dbid; Api.JetCreateDatabase2(session, this.database, 512, out dbid, CreateDatabaseGrbit.None); Assert.IsTrue(File.Exists(this.database)); } } }
public void DetachDatabaseWithUnicodePath() { if (!EsentVersion.SupportsUnicodePaths) { return; } using (var instance = new Instance("unicodedbdetach")) { SetupHelper.SetLightweightConfiguration(instance); instance.Parameters.CreatePathIfNotExist = true; instance.Init(); using (var session = new Session(instance)) { JET_DBID dbid; Api.JetCreateDatabase(session, this.database, String.Empty, out dbid, CreateDatabaseGrbit.None); Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None); Api.JetDetachDatabase(session, this.database); } } }
public void EsentExceptionIsThrownOnApiError() { using (var instance = new Instance("EsentExceptionHasErrorCode")) { SetupHelper.SetLightweightConfiguration(instance); instance.Init(); using (var session = new Session(instance)) { try { // The session shouldn't be in a transaction so this will // generate an error. Api.JetCommitTransaction(session, CommitTransactionGrbit.None); Assert.Fail("Should have thrown an exception"); } catch (EsentErrorException ex) { Assert.AreEqual(JET_err.NotInTransaction, ex.Error); } } } }
/// <summary> /// Initializes a new instance of the <see cref="InstanceWrapper"/> class. /// </summary> public InstanceWrapper() { this.instance = new Instance("InstanceWrapper"); SetupHelper.SetLightweightConfiguration(this.instance); }