Exemplo n.º 1
0
        public void Action_WithPreviousMongoGrammarWithMatchingGuids_ShouldBeUpdatedFromLcmGrammar()
        {
            // Setup
            var      lfProject = _lfProj;
            LcmCache cache     = lfProject.FieldWorksProject.Cache;
            int      wsEn      = cache.WritingSystemFactory.GetWsFromStr("en");
            var      converter = new ConvertLcmToMongoOptionList(null, wsEn,
                                                                 MagicStrings.LfOptionListCodeForGrammaticalInfo, new LfMerge.Core.Logging.NullLogger(),
                                                                 _cache.WritingSystemFactory);
            LfOptionList     lfGrammar   = converter.PrepareOptionListUpdate(cache.LanguageProject.PartsOfSpeechOA);
            LfOptionListItem itemForTest = lfGrammar.Items.First();
            Guid             g           = itemForTest.Guid.Value;

            itemForTest.Abbreviation = "Different abbreviation";
            itemForTest.Value        = "Different name";
            itemForTest.Key          = "Different key";
            _conn.UpdateMockOptionList(lfGrammar);

            // Exercise
            SutLcmToMongo.Run(lfProject);

            // Verify
            lfGrammar = _conn.GetLfOptionLists()
                        .FirstOrDefault(optionList => optionList.Code == MagicStrings.LfOptionListCodeForGrammaticalInfo);
            Assert.That(lfGrammar, Is.Not.Null);
            Assert.That(lfGrammar.Items, Is.Not.Empty);
            Assert.That(lfGrammar.Items.Count, Is.EqualTo(lfProject.FieldWorksProject.Cache.LanguageProject.AllPartsOfSpeech.Count));
            itemForTest = lfGrammar.Items.FirstOrDefault(x => x.Guid == g);
            Assert.That(itemForTest, Is.Not.Null);
            Assert.That(itemForTest.Abbreviation, Is.Not.EqualTo("Different abbreviation"));
            Assert.That(itemForTest.Value, Is.Not.EqualTo("Different name"));
            Assert.That(itemForTest.Key, Is.EqualTo("Different key"));             // NOTE: Is.EqualTo, because keys shouldn't be updated
        }
Exemplo n.º 2
0
        public ConvertLcmToMongoOptionList ConvertOptionListFromLcm(ILfProject project, string listCode, ICmPossibilityList lcmOptionList, bool updateMongoList = true)
        {
            LfOptionList lfExistingOptionList = _conn.GetLfOptionListByCode(project, listCode);
            var          converter            = new ConvertLcmToMongoOptionList(lfExistingOptionList, _wsEn, listCode, _env.Logger, _cache.WritingSystemFactory);
            LfOptionList lfChangedOptionList  = converter.PrepareOptionListUpdate(lcmOptionList);

            if (updateMongoList)
            {
                _conn.UpdateRecord(project, lfChangedOptionList, listCode);
            }
            return(new ConvertLcmToMongoOptionList(lfChangedOptionList, _wsEn, listCode, _env.Logger, _cache.WritingSystemFactory));
        }