Пример #1
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();
                }

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

                Unpacker.RemoveParatextTestProjects();
            }
            m_testTeApp = null;

            base.Dispose(disposing);
        }
Пример #2
0
        /// <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"></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_regData != null)
                {
                    m_regData.RestoreRegistryData();
                }

                Unpacker.RemoveParatextTestProjects();
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_regData = null;

            base.Dispose(disposing);
        }
Пример #3
0
        public void CleanUpFixture()
        {
            if (m_regData != null)
            {
                m_regData.RestoreRegistryData();
            }

            Unpacker.RemoveParatextTestProjects();
        }
Пример #4
0
        public void Test_LoadECObjectForSO()
        {
            CheckDisposed();

            RegistryData rootDir = null;

            try
            {
                rootDir = new RegistryData(Registry.LocalMachine,
                                           @"SOFTWARE\SIL\FieldWorks",
                                           "rootDir",
                                           Unpacker.RootDir);
            }
            finally
            {
                if (rootDir != null)
                {
                    rootDir.RestoreRegistryData();
                }
            }
        }
Пример #5
0
        public void SelectProjectResetsValues()
        {
            Unpacker.UnpackTEVTitusWithUnmappedStyle();
            RegistryData regData = Unpacker.PrepareRegistryForPTData();

            try
            {
                m_dummyParaDlg.SimulateShowDialog();

                // Edit the suffix and short name in vernacular
                m_dummyParaDlg.SimulateEditingSuffix("abc");
                m_dummyParaDlg.SimulateEditingShortName("bla");

                // Select project from combo box

                // Check that values in dialog get reset to values from Paratext project file
            }
            finally
            {
                regData.RestoreRegistryData();
                Unpacker.RemoveParatextTestProjects();
            }
        }
Пример #6
0
        public void LoadP6ProjectForAnnotationOnlyImportWithOnlyScriptureProjectSet()
        {
            CheckDisposed();

            ScrObjWrapper wrapper  = new ScrObjWrapper();
            ScrImportSet  settings = new ScrImportSet();

            Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(settings);

            Unpacker.UnPackParatextTestProjects();
            RegistryData regData = Unpacker.PrepareRegistryForPTData();

            try
            {
                settings.ImportTypeEnum        = TypeOfImport.Paratext6;
                settings.ParatextScrProj       = "KAM";
                settings.StartRef              = new BCVRef(1, 1, 1);
                settings.EndRef                = new BCVRef(66, 22, 21);
                settings.ImportAnnotations     = true;
                settings.ImportBackTranslation = false;
                settings.ImportTranslation     = false;
                wrapper.LoadScriptureProject(settings);
                string       sText, sMarker;
                ImportDomain domain;
                Assert.IsTrue(wrapper.GetNextSegment(out sText, out sMarker, out domain));
                Assert.AreEqual(3, wrapper.ExternalPictureFolders.Count);
                Assert.AreEqual(@"C:\~IWTEST~\KAM\Figures", wrapper.ExternalPictureFolders[0]);
            }
            finally
            {
                if (regData != null)
                {
                    regData.RestoreRegistryData();
                }
                Unpacker.RemoveParatextTestProjects();
            }
        }
Пример #7
0
        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();
            }
        }
Пример #8
0
        public void TestTheRegistryDataClass()
        {
            CheckDisposed();

            RegistryData newPath, newElement, newValue, keyWithNoValue, partialTree, oneMore;

            newPath = newElement = newValue = keyWithNoValue = partialTree = oneMore = null;

            try
            {
                newPath = new RegistryData(Registry.LocalMachine,
                                           @"SOFTWARE\TEST_Undefined_Path",
                                           "TEST_NewPath",
                                           "asdfasdfasdfasdf");

                newElement = new RegistryData(Registry.LocalMachine,
                                              "SOFTWARE",
                                              "TEST_NewElement",
                                              "asdfasdfasdfasdf");

                newValue = new RegistryData(Registry.LocalMachine,
                                            @"SOFTWARE\SIL\FieldWorks",
                                            "RootDir",
                                            "asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf");

                keyWithNoValue = new RegistryData(Registry.LocalMachine,
                                                  "SOFTWARE",
                                                  "EmptyString",
                                                  "SomeData....");

                partialTree = new RegistryData(Registry.LocalMachine,
                                               @"SOFTWARE\SIL\FieldWorks\test1\test2\test3\test4",
                                               "DataKey",
                                               "DataValue");

                oneMore = new RegistryData(Registry.LocalMachine,
                                           @"SOFTWARE\SIL\FieldWorks\test1",
                                           "Test1KeyItem",
                                           "DataValue");
            }
            finally
            {
                if (newPath != null)
                {
                    newPath.RestoreRegistryData();
                }

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

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

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

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

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