Exemple #1
0
        /// <summary/>
        public void UpdateWritingSystemListField_RemovesWsCode()
        {
            int m_wsEn = Cache.WritingSystemFactory.GetWsFromStr("en");
            int m_wsFr = Cache.WritingSystemFactory.GetWsFromStr("fr");

            CoreWritingSystemDefinition enBlz;

            WritingSystemServices.FindOrCreateWritingSystem(Cache, null, "blz", false, false, out enBlz);

            var revIndex = Cache.ServiceLocator.GetInstance <IReversalIndexRepository>().FindOrCreateIndexForWs(m_wsEn);

            var entry1 = SenseOrEntryTests.CreateInterestingLexEntry(Cache);
            var msa1   = Cache.ServiceLocator.GetInstance <IMoStemMsaFactory>().Create();

            entry1.MorphoSyntaxAnalysesOC.Add(msa1);
            entry1.SensesOS.First().MorphoSyntaxAnalysisRA = msa1;

            var entry2 = SenseOrEntryTests.CreateInterestingLexEntry(Cache);
            var msa2   = Cache.ServiceLocator.GetInstance <IMoStemMsaFactory>().Create();

            entry2.MorphoSyntaxAnalysesOC.Add(msa2);
            entry2.SensesOS.First().MorphoSyntaxAnalysisRA = msa2;

            var testEntry = revIndex.FindOrCreateReversalEntry("first");

            testEntry.SensesRS.Add(entry1.SensesOS.First());
            testEntry.SensesRS.Add(entry2.SensesOS.First());

            testEntry.ReversalIndex.WritingSystem = "fr";
            testEntry.ReversalForm.set_String(m_wsFr, "fr");
            WritingSystemServices.UpdateWritingSystemFields(Cache, "fr", "blz");
            Assert.DoesNotThrow(() => WritingSystemServices.UpdateWritingSystemFields(Cache, "fr", null));
            Assert.That(testEntry.ReversalIndex.WritingSystem, Is.EqualTo("blz"));
            Assert.That(testEntry.ReversalIndex.ShortName, Is.EqualTo("Balantak"));
        }