/// <summary>
        /// Correct way to deal with FixtureTearDown for class that derive from BaseTest.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (m_testTeApp != null)
                {
                    m_testTeApp.ExitAppplication();
                    m_testTeApp.Dispose();
                }

                if (m_regData != null)
                {
                    m_regData.RestoreRegistryData();
                }

                Unpacker.RemoveParatextTestProjects();
            }
            m_testTeApp = null;

            base.Dispose(disposing);
        }
Exemple #2
0
        /// <summary>
        /// Correct way to deal with FixtureTearDown for class that derive from BaseTest.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (m_testTeApp != null)
                {
                    m_testTeApp.ExitAppplication();
                    m_testTeApp.Dispose();
                }
            }
            m_testTeApp = null;

            base.Dispose(disposing);
        }
        public void CleanUp()
        {
            CheckDisposed();

            bool wipedOutStuff = false;

            if (m_fMainWindowOpened)
            {
                try
                {
                    // Undo everything that we can undo - checking to make sure we are not
                    // in an infinite loop
                    int undoCount = 0;
                    while (m_firstMainWnd.Cache.CanUndo)
                    {
                        if (++undoCount <= 10)
                        {
                            m_firstMainWnd.SimulateEditUndoClick();
                            Application.DoEvents();
                        }
                        else
                        {
                            // Do a complete clean up and re-init so next test can run
                            // without impact from this test.
                            wipedOutStuff = true;
                            if (m_testTeApp != null)
                            {
                                m_testTeApp.ExitAppplication();
                                m_testTeApp.Dispose();
                                m_testTeApp = null;
                            }

                            if (m_regData != null)
                            {
                                m_regData.RestoreRegistryData();
                            }
                            Unpacker.RemoveParatextTestProjects();

                            return;
                        }
                    }
                    m_firstMainWnd.Cache.ActionHandlerAccessor.Commit();
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Got exception in UndoRedoTests.CleanUp: "
                                                       + e.Message);
                }
            }
            if (!wipedOutStuff)
            {
                if (m_testTeApp != null)
                {
                    m_testTeApp.ExitAppplication();
                    m_testTeApp.Dispose();
                    m_testTeApp = null;
                }

                if (m_regData != null)
                {
                    m_regData.RestoreRegistryData();
                }
                Unpacker.RemoveParatextTestProjects();
            }
        }