public void DisposeTest() { PluginDebuggerGDB_Accessor target = new PluginDebuggerGDB_Accessor(dte_, properties_); string existingGDB = "DisposeTest_GDB"; try { target.gdbProcess_ = TestUtilities.StartProcessForKilling(existingGDB, 20); string existingInitFileName = Path.GetTempFileName(); target.gdbInitFileName_ = existingInitFileName; target.Dispose(); // Check that the pre-existing gdb process was killed and its init file cleaned up. Assert.IsFalse( TestUtilities.DoesProcessExist("python.exe", existingGDB), "Failed to kill existing GDB process"); Assert.IsFalse( File.Exists(existingInitFileName), "Failed to delete existing temp gdb init file"); } finally { // Clean up file if not erased. if (!string.IsNullOrEmpty(target.gdbInitFileName_) && File.Exists(target.gdbInitFileName_)) { File.Delete(target.gdbInitFileName_); } // Kill the gdb process if not killed. if (target.gdbProcess_ != null && !target.gdbProcess_.HasExited) { target.gdbProcess_.Kill(); target.gdbProcess_.Dispose(); } } }