/// ------------------------------------------------------------------------------------ /// <summary> /// Executes in two distinct scenarios. /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// If subclasses override this method, they should call the base implementation. /// </remarks> /// ------------------------------------------------------------------------------------ protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_fileMaker != null) { m_fileMaker.Dispose(); } if (m_myCtrl != null) { m_myCtrl.Dispose(); } if (m_myDlg != null) { m_myDlg.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_fileMaker = null; m_myCtrl = null; m_myDlg = null; m_ccFileName = null; m_mapFileName = null; base.Dispose(disposing); }
/// <summary> /// Clean up after running all the tests. /// </summary> public override void FixtureTeardown() { EncConverters encConverters; // Dispose managed resources here. if (m_myCtrl != null) { encConverters = m_myCtrl.Converters; m_myCtrl.Dispose(); m_myCtrl = null; } else { encConverters = new EncConverters(); } if (m_myDlg != null) { m_myDlg.Dispose(); m_myDlg = null; } try { // Delete any temp files that have been created. if (!String.IsNullOrEmpty(m_ccFileName)) { File.Delete(m_ccFileName); m_ccFileName = null; } if (!String.IsNullOrEmpty(m_mapFileName)) { File.Delete(m_mapFileName); m_mapFileName = null; } if (!String.IsNullOrEmpty(m_bogusFileName)) { File.Delete(m_bogusFileName); m_bogusFileName = null; } } catch { // for some reason deleting the temporary files occasionally fails - not sure // why. If this happens we just ignore it and continue. } // Remove any encoding converters that we may have created during this test run. RemoveTestConverters(encConverters, "Installed mappings after test teardown:"); base.FixtureTeardown(); }