public void Action_WithPreviousMongoGrammarWithMatchingGuids_ShouldBeUpdatedFromFdoGrammar()
        {
            // Setup
            var      lfProject = _lfProj;
            FdoCache cache     = lfProject.FieldWorksProject.Cache;
            int      wsEn      = cache.WritingSystemFactory.GetWsFromStr("en");
            var      converter = new ConvertFdoToMongoOptionList(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
            sutFdoToMongo.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
        }
Пример #2
0
        public ConvertFdoToMongoOptionList ConvertOptionListFromFdo(ILfProject project, string listCode, ICmPossibilityList fdoOptionList, bool updateMongoList = true)
        {
            LfOptionList lfExistingOptionList = _conn.GetLfOptionListByCode(project, listCode);
            var          converter            = new ConvertFdoToMongoOptionList(lfExistingOptionList, _wsEn, listCode, _env.Logger, _cache.WritingSystemFactory);
            LfOptionList lfChangedOptionList  = converter.PrepareOptionListUpdate(fdoOptionList);

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