Beispiel #1
0
 public void ChangingLangProjDefaultAnalysisWs_ChangesCacheDefaultAnalWs()
 {
     using (var cache = LcmCache.CreateCacheWithNewBlankLangProj(new TestProjectId(BackendProviderType.kMemoryOnly, null),
                                                                 "en", "fr", "en", m_ui, m_lcmDirectories, new LcmSettings()))
     {
         var wsEn = cache.DefaultAnalWs;
         Assert.That(cache.LangProject.DefaultAnalysisWritingSystem.Handle, Is.EqualTo(wsEn));
         CoreWritingSystemDefinition wsObjGerman = null;
         UndoableUnitOfWorkHelper.Do("undoit", "redoit", cache.ActionHandlerAccessor,
                                     () =>
         {
             WritingSystemServices.FindOrCreateWritingSystem(cache, TestDirectoryFinder.TemplateDirectory, "de", true, false, out wsObjGerman);
             Assert.That(cache.DefaultAnalWs, Is.EqualTo(wsEn));
             cache.LangProject.DefaultAnalysisWritingSystem = wsObjGerman;
             Assert.That(cache.DefaultAnalWs, Is.EqualTo(wsObjGerman.Handle));
         });
         UndoableUnitOfWorkHelper.Do("undoit", "redoit", cache.ActionHandlerAccessor,
                                     () =>
         {
             cache.LangProject.CurAnalysisWss = "en";
             Assert.That(cache.DefaultAnalWs, Is.EqualTo(wsEn));
         });
         cache.ActionHandlerAccessor.Undo();
         Assert.That(cache.DefaultAnalWs, Is.EqualTo(wsObjGerman.Handle));
         cache.ActionHandlerAccessor.Redo();
         Assert.That(cache.DefaultAnalWs, Is.EqualTo(wsEn));
     }
 }
Beispiel #2
0
        public void CacheCheckDisposedTest()
        {
            // This can't be in the minimalist class, because it disposes the cache.
            var cache = LcmCache.CreateCacheWithNewBlankLangProj(new TestProjectId(BackendProviderType.kMemoryOnly, null),
                                                                 "en", "fr", "en", m_ui, TestDirectoryFinder.LcmDirectories, new LcmSettings());
            // Init backend data provider
            var dataSetup = cache.ServiceLocator.GetInstance <IDataSetup>();

            dataSetup.LoadDomain(BackendBulkLoadDomain.All);
            cache.Dispose();
            Assert.That(() => cache.CheckDisposed(), Throws.TypeOf <ObjectDisposedException>());
        }
Beispiel #3
0
        public void CacheDisposedForLcmObject()
        {
            var cache = LcmCache.CreateCacheWithNewBlankLangProj(new TestProjectId(BackendProviderType.kMemoryOnly, null),
                                                                 "en", "fr", "en", m_ui, TestDirectoryFinder.LcmDirectories, new LcmSettings());
            // Init backend data provider
            var dataSetup = cache.ServiceLocator.GetInstance <IDataSetup>();

            dataSetup.LoadDomain(BackendBulkLoadDomain.All);
            var lp = cache.LanguageProject;

            cache.Dispose();
            Assert.IsFalse(lp.IsValidObject);
        }
Beispiel #4
0
        public void CacheIsDisposedTest()
        {
            // This can't be in the minimalist class, because it disposes the cache.
            var cache = LcmCache.CreateCacheWithNewBlankLangProj(new TestProjectId(BackendProviderType.kMemoryOnly, null),
                                                                 "en", "fr", "en", m_ui, TestDirectoryFinder.LcmDirectories, new LcmSettings());
            // Init backend data provider
            var dataSetup = cache.ServiceLocator.GetInstance <IDataSetup>();

            dataSetup.LoadDomain(BackendBulkLoadDomain.All);
            Assert.IsFalse(cache.IsDisposed, "Should not have been disposed.");
            cache.Dispose();
            Assert.IsTrue(cache.IsDisposed, "Should have been disposed.");
        }
Beispiel #5
0
 public void LcmObjectDeleted()
 {
     using (var cache = LcmCache.CreateCacheWithNewBlankLangProj(new TestProjectId(BackendProviderType.kMemoryOnly, null),
                                                                 "en", "fr", "en", m_ui, TestDirectoryFinder.LcmDirectories, new LcmSettings()))
     {
         // Init backend data provider
         var dataSetup = cache.ServiceLocator.GetInstance <IDataSetup>();
         dataSetup.LoadDomain(BackendBulkLoadDomain.All);
         var lp = cache.LanguageProject;
         cache.ActionHandlerAccessor.BeginNonUndoableTask();
         var peopleList = cache.ServiceLocator.GetInstance <ICmPossibilityListFactory>().Create();
         lp.PeopleOA = peopleList;
         lp.PeopleOA = null;
         cache.ActionHandlerAccessor.EndNonUndoableTask();
         Assert.IsFalse(peopleList.IsValidObject);
     }
 }
Beispiel #6
0
        public void ChangingLangProjDefaultPronunciationWs_ChangesCacheDefaultPronunciationWs()
        {
            using (var cache = LcmCache.CreateCacheWithNewBlankLangProj(new TestProjectId(BackendProviderType.kMemoryOnly, null),
                                                                        "en", "fr", "en", m_ui, m_lcmDirectories, new LcmSettings()))
            {
                var wsFr = cache.DefaultPronunciationWs;
                Assert.That(cache.LangProject.DefaultPronunciationWritingSystem.Handle, Is.EqualTo(wsFr));
                CoreWritingSystemDefinition wsObjGerman  = null;
                CoreWritingSystemDefinition wsObjSpanish = null;
                UndoableUnitOfWorkHelper.Do("undoit", "redoit", cache.ActionHandlerAccessor,
                                            () =>
                {
                    WritingSystemServices.FindOrCreateWritingSystem(cache, TestDirectoryFinder.TemplateDirectory, "de", false, true, out wsObjGerman);
                    Assert.That(cache.DefaultPronunciationWs, Is.EqualTo(wsFr));
                    cache.LangProject.DefaultVernacularWritingSystem = wsObjGerman;
                    cache.LangProject.CurrentPronunciationWritingSystems.Clear();
                    // Now it re-evaluates to the new default vernacular.
                    Assert.That(cache.DefaultPronunciationWs, Is.EqualTo(wsObjGerman.Handle));

                    // This no longer works..._IPA does not make a valid WS ID.
                    //IWritingSystem wsObjGermanIpa;
                    //WritingSystemServices.FindOrCreateWritingSystem(cache, "de__IPA", false, true, out wsObjGermanIpa);
                    //cache.LangProject.CurrentPronunciationWritingSystems.Clear();
                    //// Once there is an IPA one, we should prefer that
                    //Assert.That(cache.DefaultPronunciationWs, Is.EqualTo(wsObjGermanIpa.Handle));

                    // Unless we clear the list it does not regenerate.
                    WritingSystemServices.FindOrCreateWritingSystem(cache, TestDirectoryFinder.TemplateDirectory, "es", false, true, out wsObjSpanish);
                    // Once we've found a real pronunciation WS, changing the default vernacular should not change it.
                    Assert.That(cache.DefaultPronunciationWs, Is.EqualTo(wsObjGerman.Handle));
                });
                UndoableUnitOfWorkHelper.Do("undoit", "redoit", cache.ActionHandlerAccessor,
                                            () =>
                {
                    cache.LangProject.CurPronunWss = "es";
                    Assert.That(cache.DefaultPronunciationWs, Is.EqualTo(wsObjSpanish.Handle));
                });
                cache.ActionHandlerAccessor.Undo();
                Assert.That(cache.DefaultPronunciationWs, Is.EqualTo(wsObjGerman.Handle));
                cache.ActionHandlerAccessor.Redo();
                Assert.That(cache.DefaultPronunciationWs, Is.EqualTo(wsObjSpanish.Handle));
            }
        }
Beispiel #7
0
        /// <summary>
        /// Actually create the system.
        /// Called by subclass overrides of CreateCache(), with parameters that suit
        /// the subclass.
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="loadType"></param>
        /// <param name="settings"></param>
        /// <returns>a working LcmCache</returns>
        protected LcmCache BootstrapSystem(IProjectIdentifier projectId, BackendBulkLoadDomain loadType, LcmSettings settings)
        {
            LcmCache retval;

            if (m_internalRestart)
            {
                retval = LcmCache.CreateCacheFromExistingData(projectId, "en", new DummyLcmUI(), TestDirectoryFinder.LcmDirectories,
                                                              settings, new DummyProgressDlg());
            }
            else
            {
                retval = LcmCache.CreateCacheWithNewBlankLangProj(projectId, "en", "fr", "en", new DummyLcmUI(),
                                                                  TestDirectoryFinder.LcmDirectories, settings);
            }

            var dataSetup = retval.ServiceLocator.GetInstance <IDataSetup>();

            dataSetup.LoadDomain(loadType);
            return(retval);
        }