Exemplo n.º 1
0
        public void MultiMessageSynchronize_DifferentCache()
        {
            m_mainWnd.Expect("PreSynchronize", new IsAnything());
            m_mainWnd.ExpectAndReturn("Synchronize", true, new IsAnything());
            m_app.MainWindows.Add((IFwMainWnd)m_mainWnd.MockInstance);

            LcmCache differentCache = LcmCache.CreateCache(FDOBackendProviderType.kMemoryOnly, BackendBulkLoadDomain.All, null);

            try
            {
                DynamicMock otherMainWnd = new DynamicMock(typeof(IFwMainWnd));
                otherMainWnd.SetupResult("Cache", differentCache);
                otherMainWnd.Expect("PreSynchronize", new IsAnything());
                otherMainWnd.ExpectAndReturn("Synchronize", true, new IsAnything());
                m_app.MainWindows.Add((IFwMainWnd)otherMainWnd.MockInstance);

                m_app.SuppressSynchronize(Cache);
                m_app.Synchronize(SyncMsg.ksyncUndoRedo, Cache);
                m_app.Synchronize(SyncMsg.ksyncUndoRedo, differentCache);

                // This should call (Pre)Synchronize once for each main window
                m_app.ResumeSynchronize(Cache);

                m_mainWnd.Verify();
                otherMainWnd.Verify();
            }
            finally
            {
                differentCache.Dispose();
            }
        }
Exemplo n.º 2
0
        /// <summary/>
        protected virtual void Dispose(bool fDisposing)
        {
            Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType() + " *******");
            if (fDisposing && !IsDisposed)
            {
                // dispose managed and unmanaged objects
                if (m_lexEntries != null)
                {
                    m_lexEntries.Clear();
                }

                if (m_writingSystems != null)
                {
                    m_writingSystems.Clear();
                }
            }
            m_lexEntries     = null;
            m_writingSystems = null;
            // Write all data and dispose of the flex cache
            try
            {
                m_cache?.ServiceLocator.GetInstance <IUndoStackManager>().StopSaveTimer();
                m_cache?.ServiceLocator.GetInstance <IUndoStackManager>().Save();
            }
            finally
            {
                m_cache?.Dispose();
                m_cache = null;
            }
            IsDisposed = true;
        }
Exemplo n.º 3
0
 public void TearDown()
 {
     m_propertyTable.Dispose();
     m_propertyTable = null;
     m_mediator.Dispose();
     m_mediator = null;
     m_cache.Dispose();
     m_cache = null;
 }
Exemplo n.º 4
0
 private void DisposeLcmCacheIfUnused(LcmCache fdoCache)
 {
     if (m_lexiconCache.All(lexicon => lexicon.Cache != fdoCache))
     {
         m_cacheCache.Remove(fdoCache.ProjectId.Name);
         fdoCache.ServiceLocator.GetInstance <IUndoStackManager>().Save();
         fdoCache.Dispose();
     }
 }
Exemplo n.º 5
0
 public void TearDown()
 {
     m_lexicon.Dispose();
     m_cache.Dispose();
     m_threadHelper.Dispose();
 }
Exemplo n.º 6
0
        public void FwNewLangProjectModel_VerifyCreateNewLangProject()
        {
            LcmCache cache = null;

            var testProject = new FwNewLangProjectModel(true)
            {
                LoadProjectNameSetup = () => { },
                LoadVernacularSetup  = () => { },
                LoadAnalysisSetup    = () => { },
                AnthroModel          = new FwChooseAnthroListModel {
                    CurrentList = FwChooseAnthroListModel.ListChoice.UserDef
                }
            };

            try
            {
                testProject.ProjectName = DbName;
                testProject.Next();
                testProject.SetDefaultWs(new LanguageInfo {
                    LanguageTag = "fr"
                });
                testProject.Next();
                testProject.SetDefaultWs(new LanguageInfo {
                    LanguageTag = "de"
                });
                using (var threadHelper = new ThreadHelper())
                {
                    testProject.CreateNewLangProj(new DummyProgressDlg(), threadHelper);
                }

                Assert.IsTrue(DbExists(DbName));

                // despite of the name is DummyProgressDlg no real dialog (doesn't derive from Control), so
                // we don't need a 'using'
                cache = LcmCache.CreateCacheFromExistingData(
                    new TestProjectId(BackendProviderType.kXMLWithMemoryOnlyWsMgr, DbFilename(DbName)), "en", new DummyLcmUI(),
                    FwDirectoryFinder.LcmDirectories, new LcmSettings(), new DummyProgressDlg());
                CheckInitialSetOfPartsOfSpeech(cache);

                Assert.AreEqual(2, cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.Count);
                Assert.AreEqual("German", cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.First().LanguageName);
                Assert.AreEqual("English", cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.Last().LanguageName);
                Assert.AreEqual(2, cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Count);
                Assert.AreEqual("German", cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.LanguageName);
                Assert.AreEqual("English", cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Last().LanguageName,
                                "English should be selected as an analysis writing system even if the user tried to remove it");
                Assert.AreEqual(1, cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Count);
                Assert.AreEqual("French", cache.ServiceLocator.WritingSystems.VernacularWritingSystems.First().LanguageName);
                Assert.AreEqual(1, cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Count);
                Assert.AreEqual("French", cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.LanguageName);
            }
            finally
            {
                // Blow away the database to clean things up
                if (cache != null)
                {
                    cache.Dispose();
                }
                DestroyDb(DbName, false);
            }
        }