public override void FixtureSetup()
        {
            CheckDisposed();
            base.FixtureSetup();

            m_mappingList = new ScrMappingList(MappingSet.Main, null);
        }
Beispiel #2
0
        public void AddInfoWithNullMarker()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Main, null, null);

            Assert.That(() => list.Add(new ImportMappingInfo(null, null, null)),
                        Throws.TypeOf <ArgumentException>());
        }
Beispiel #3
0
        public void LoadParatextMappings_MarkMappingsInUse()
        {
            FwStyleSheet stylesheet = new FwStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            ScrMappingList mappingList = new ScrMappingList(MappingSet.Main, stylesheet);

            mappingList.Add(new ImportMappingInfo(@"\hahaha", @"\*hahaha", false,
                                                  MappingTargetType.TEStyle, MarkerDomain.Default, "laughing",
                                                  null, null, true, ImportDomain.Main));
            mappingList.Add(new ImportMappingInfo(@"\bthahaha", @"\*bthahaha", false,
                                                  MappingTargetType.TEStyle, MarkerDomain.Default, "laughing",
                                                  "en", null, true, ImportDomain.Main));

            Unpacker.UnPackParatextTestProjects();
            IParatextAdapter sut = new ParatextProxy();

            Assert.IsTrue(sut.LoadProjectMappings("TEV", mappingList, ImportDomain.Main));

            Assert.IsTrue(mappingList[@"\c"].IsInUse);
            Assert.IsTrue(mappingList[@"\p"].IsInUse);
            Assert.IsFalse(mappingList[@"\ipi"].IsInUse);
            Assert.IsFalse(mappingList[@"\hahaha"].IsInUse,
                           "In-use flag should have been cleared before re-scanning when the P6 project changed.");
            Assert.IsTrue(mappingList[@"\bthahaha"].IsInUse,
                          "In-use flag should not have been cleared before re-scanning when the P6 project changed because it was in use by the BT.");
        }
Beispiel #4
0
        public void LoadParatextMappings_Normal()
        {
            if (ScriptureProvider.VersionInUse >= new Version(8, 0))
            {
                Assert.Ignore("This test uses data that is only valid for Paratext7. The test fails with Paratext8 installed.");
            }
            Unpacker.UnPackParatextTestProjects();

            var stylesheet = new LcmStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings);
            importSettings.ParatextScrProj = "KAM";
            ParatextHelper.LoadProjectMappings(importSettings);

            ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main);

            // Test to see that the projects are set correctly
            Assert.AreEqual(44, mappingList.Count);

            Assert.AreEqual(MarkerDomain.Default, mappingList[@"\c"].Domain);
            Assert.AreEqual(MarkerDomain.Default, mappingList[@"\v"].Domain);
            Assert.AreEqual(@"\f*", mappingList[@"\f"].EndMarker);
            Assert.IsTrue(mappingList[@"\p"].IsInUse);
            Assert.IsFalse(mappingList[@"\tb2"].IsInUse);
        }
Beispiel #5
0
        public void LoadParatextMappings_MarkMappingsInUse()
        {
            if (ScriptureProvider.VersionInUse >= new Version(8, 0))
            {
                Assert.Ignore("This test uses data that is only valid for Paratext7. The test fails with Paratext8 installed.");
            }
            var stylesheet = new LcmStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings);
            importSettings.ParatextScrProj = "TEV";
            ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main);

            Assert.NotNull(mappingList, "Setup Failure, no mapping list returned for the domain.");
            mappingList.Add(new ImportMappingInfo(@"\hahaha", @"\*hahaha", false,
                                                  MappingTargetType.TEStyle, MarkerDomain.Default, "laughing",
                                                  null, null, true, ImportDomain.Main));
            mappingList.Add(new ImportMappingInfo(@"\bthahaha", @"\*bthahaha", false,
                                                  MappingTargetType.TEStyle, MarkerDomain.Default, "laughing",
                                                  "en", null, true, ImportDomain.Main));

            Unpacker.UnPackParatextTestProjects();

            ParatextHelper.LoadProjectMappings(importSettings);

            Assert.IsTrue(mappingList[@"\c"].IsInUse);
            Assert.IsTrue(mappingList[@"\p"].IsInUse);
            Assert.IsFalse(mappingList[@"\ipi"].IsInUse);
            Assert.IsFalse(mappingList[@"\hahaha"].IsInUse,
                           "In-use flag should have been cleared before re-scanning when the P6 project changed.");
            Assert.IsTrue(mappingList[@"\bthahaha"].IsInUse,
                          "In-use flag should not have been cleared before re-scanning when the P6 project changed because it was in use by the BT.");
        }
Beispiel #6
0
        public void AddBlankMarker()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Main, null, null);

            Assert.That(() => list.Add(new ImportMappingInfo(string.Empty, string.Empty, string.Empty)),
                        Throws.TypeOf <ArgumentException>());
        }
Beispiel #7
0
        public void AddDefaultMappingIfNeeded_btNotFromTeStyle()
        {
            IVwStylesheet stylesheet = MockRepository.GenerateStrictMock <IVwStylesheet>();

            ScrMappingList list = new ScrMappingList(MappingSet.Main, stylesheet, TestTeStylesPath);

            list.Add(new ImportMappingInfo(@"\h", null, false, MappingTargetType.TitleShort,
                                           MarkerDomain.Default, null, null));
            list.AddDefaultMappingIfNeeded(@"\bth", ImportDomain.Main, true);
            list.Add(new ImportMappingInfo(@"\vt", null, false, MappingTargetType.DefaultParaChars,
                                           MarkerDomain.Default, null, null));
            list.AddDefaultMappingIfNeeded(@"\btvt", ImportDomain.Main, true);
            Assert.AreEqual(4, list.Count);

            // Test that \bth maps automatically to the corresponding vernacular import property
            // in the Back-trans marker domain.
            ImportMappingInfo info = list[@"\bth"];

            Assert.AreEqual(MarkerDomain.BackTrans, info.Domain);
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TitleShort, info.MappingTarget);

            // Test that \btvt maps automatically to Default Paragraph Characters
            // in the Back-trans marker domain.
            info = list[@"\btvt"];
            Assert.AreEqual(MarkerDomain.BackTrans, info.Domain);
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.DefaultParaChars, info.MappingTarget);
        }
        public void AddDefaultMappingIfNeeded_btNotFromTeStyle()
        {
            DynamicMock mockStylesheet = new DynamicMock(typeof(IVwStylesheet));

            mockStylesheet.Strict = true;

            ScrMappingList list = new ScrMappingList(MappingSet.Main, (IVwStylesheet)mockStylesheet.MockInstance);

            list.Add(new ImportMappingInfo(@"\h", null, false, MappingTargetType.TitleShort,
                                           MarkerDomain.Default, null, null));
            list.AddDefaultMappingIfNeeded(@"\bth", ImportDomain.Main, true);
            list.Add(new ImportMappingInfo(@"\vt", null, false, MappingTargetType.DefaultParaChars,
                                           MarkerDomain.Default, null, null));
            list.AddDefaultMappingIfNeeded(@"\btvt", ImportDomain.Main, true);
            Assert.AreEqual(4, list.Count);

            // Test that \bth maps automatically to the corresponding vernacular import property
            // in the Back-trans marker domain.
            ImportMappingInfo info = list[@"\bth"];

            Assert.AreEqual(MarkerDomain.BackTrans, info.Domain);
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TitleShort, info.MappingTarget);

            // Test that \btvt maps automatically to Default Paragraph Characters
            // in the Back-trans marker domain.
            info = list[@"\btvt"];
            Assert.AreEqual(MarkerDomain.BackTrans, info.Domain);
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.DefaultParaChars, info.MappingTarget);
        }
Beispiel #9
0
        public void LoadParatextMappings_MarkMappingsInUse()
        {
            var stylesheet = new FwStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            importSettings.ParatextScrProj = "TEV";
            ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main);

            mappingList.Add(new ImportMappingInfo(@"\hahaha", @"\*hahaha", false,
                                                  MappingTargetType.TEStyle, MarkerDomain.Default, "laughing",
                                                  null, null, true, ImportDomain.Main));
            mappingList.Add(new ImportMappingInfo(@"\bthahaha", @"\*bthahaha", false,
                                                  MappingTargetType.TEStyle, MarkerDomain.Default, "laughing",
                                                  "en", null, true, ImportDomain.Main));

            Unpacker.UnPackParatextTestProjects();

            ParatextHelper.LoadProjectMappings(importSettings);

            Assert.IsTrue(mappingList[@"\c"].IsInUse);
            Assert.IsTrue(mappingList[@"\p"].IsInUse);
            Assert.IsFalse(mappingList[@"\ipi"].IsInUse);
            Assert.IsFalse(mappingList[@"\hahaha"].IsInUse,
                           "In-use flag should have been cleared before re-scanning when the P6 project changed.");
            Assert.IsTrue(mappingList[@"\bthahaha"].IsInUse,
                          "In-use flag should not have been cleared before re-scanning when the P6 project changed because it was in use by the BT.");
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Shuts down the FDO cache
        /// </summary>
        /// <remarks>This method is called after each test</remarks>
        /// ------------------------------------------------------------------------------------
        public override void TestTearDown()
        {
            m_builder.Dispose();
            m_builder     = null;
            m_settings    = null;
            m_mappingList = null;

            base.TestTearDown();
        }
        public void Index_OutOfRange()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Notes, null);

            list.Add(new ImportMappingInfo(@"\a", null, false, MappingTargetType.TEStyle, MarkerDomain.Note, ScrStyleNames.Remark, null));

            // Access the second element which should throw an exception
            ImportMappingInfo info = list[1];
        }
Beispiel #12
0
        public void Index_OutOfRange()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Notes, null, null);

            list.Add(new ImportMappingInfo(@"\a", null, false, MappingTargetType.TEStyle, MarkerDomain.Note, ScrStyleNames.Remark, null));

            // Access the second element which should throw an exception
            Assert.That(() => list[1], Throws.TypeOf <ArgumentOutOfRangeException>());
        }
        public override void Exit()
        {
            CheckDisposed();

            m_builder.Dispose();
            m_builder     = null;
            m_settings    = null;
            m_mappingList = null;

            base.Exit();
        }
Beispiel #14
0
        public void LoadParatextMappings_MissingStyleFile()
        {
            FwStyleSheet stylesheet = new FwStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            ScrMappingList mappingList = new ScrMappingList(MappingSet.Main, stylesheet);

            Unpacker.UnPackMissingFileParatextTestProjects();
            IParatextAdapter sut = new ParatextProxy();

            Assert.IsFalse(sut.LoadProjectMappings("NSF", mappingList, ImportDomain.Main));
        }
        public void LookupByKey()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Notes, null);

            list.Add(new ImportMappingInfo(@"\aa", null, false, MappingTargetType.TEStyle, MarkerDomain.Note, ScrStyleNames.Remark, null));
            list.Add(new ImportMappingInfo(@"\bb", null, false, MappingTargetType.TEStyle, MarkerDomain.Note, ScrStyleNames.Remark, null));
            list.Add(new ImportMappingInfo(@"\cc", null, false, MappingTargetType.TEStyle, MarkerDomain.Note, ScrStyleNames.Remark, null));

            ImportMappingInfo info = list[@"\bb"];

            Assert.AreEqual(@"\bb", info.BeginMarker);
            Assert.AreEqual(list[1], info);
        }
        /// <summary>
        /// This class creates text, it must delete it here when UNDO is commanded
        /// so it can update InterestingTexts.
        /// </summary>

/*		public override void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
 *              {
 *                      if (cvDel != 1)
 *                              return;
 *                      SaveOnChangeRecord();
 *                      SuppressSaveOnChangeRecord = true;
 *                      try
 *                      {
 *                              m_list.DeleteCurrentObject();
 *                      }
 *                      finally
 *                      {
 *                              SuppressSaveOnChangeRecord = false;
 *                      }
 *                      GetInterestingTextList().UpdateInterestingTexts();
 *              } */

        #region IBookImporter Members
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Imports the specified book.
        /// </summary>
        /// <param name="bookNum">The canonical book number.</param>
        /// <param name="owningForm">Form that can be used as the owner of progress dialogs and
        /// message boxes.</param>
        /// <param name="importBt">True to import only the back translation, false to import
        /// only the main translation</param>
        /// <returns>
        /// The ScrBook created to hold the imported data
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public IScrBook Import(int bookNum, Form owningForm, bool importBt)
        {
            IScripture scr = Cache.LangProject.TranslatedScriptureOA;
            bool       haveSomethingToImport = NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor, () =>
            {
                IScrImportSet importSettings   = scr.FindOrCreateDefaultImportSettings(TypeOfImport.Paratext6);
                importSettings.StyleSheet      = ScriptureStylesheet;
                IScrText paratextProj          = ParatextHelper.GetAssociatedProject(Cache.ProjectId);
                importSettings.ParatextScrProj = paratextProj.Name;
                importSettings.StartRef        = new BCVRef(bookNum, 0, 0);
                int chapter           = paratextProj.Versification.LastChapter(bookNum);
                importSettings.EndRef = new BCVRef(bookNum, chapter, paratextProj.Versification.LastVerse(bookNum, chapter));
                if (!importBt)
                {
                    importSettings.ImportTranslation     = true;
                    importSettings.ImportBackTranslation = false;
                }
                else
                {
                    List <IScrText> btProjects = ParatextHelper.GetBtsForProject(paratextProj).ToList();
                    if (btProjects.Count > 0 && (string.IsNullOrEmpty(importSettings.ParatextBTProj) ||
                                                 !btProjects.Any(st => st.Name == importSettings.ParatextBTProj)))
                    {
                        importSettings.ParatextBTProj = btProjects[0].Name;
                    }
                    if (string.IsNullOrEmpty(importSettings.ParatextBTProj))
                    {
                        return(false);
                    }
                    importSettings.ImportTranslation     = false;
                    importSettings.ImportBackTranslation = true;
                }
                ParatextHelper.LoadProjectMappings(importSettings);
                ScrMappingList importMap     = importSettings.GetMappingListForDomain(ImportDomain.Main);
                ImportMappingInfo figureInfo = importMap[@"\fig"];
                if (figureInfo != null)
                {
                    figureInfo.IsExcluded = true;
                }
                importSettings.SaveSettings();
                return(true);
            });

            if (haveSomethingToImport && ReflectionHelper.GetBoolResult(ReflectionHelper.GetType("TeImportExport.dll",
                                                                                                 "SIL.FieldWorks.TE.TeImportManager"), "ImportParatext", owningForm, ScriptureStylesheet,
                                                                        (FwApp)m_mediator.PropertyTable.GetValue("App")))
            {
                return(scr.FindBook(bookNum));
            }
            return(null);
        }
        public void SetMappings_Main()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Main, null);

            list.Add(new ImportMappingInfo(@"\a", null, false, MappingTargetType.TEStyle, MarkerDomain.Default, ScrStyleNames.NormalParagraph, null));
            list.Add(new ImportMappingInfo(@"\a", null, false, MappingTargetType.TEStyle, MarkerDomain.BackTrans, ScrStyleNames.NormalParagraph, "es"));
            list.Add(new ImportMappingInfo(@"\b", null, false, MappingTargetType.TEStyle, MarkerDomain.Default, ScrStyleNames.NormalParagraph, null));
            list.Add(new ImportMappingInfo(@"\c", null, false, MappingTargetType.TEStyle, MarkerDomain.Default, "wrong style for chapter", null));
            list.Add(new ImportMappingInfo(@"\v", null, false, MappingTargetType.TEStyle, MarkerDomain.Default, "wrong style for verse", null));
            list.Add(new ImportMappingInfo(@"\id", null, false, MappingTargetType.TEStyle, MarkerDomain.Default, "id should be null", null));
            list.Add(new ImportMappingInfo(@"\btp", null, false, MappingTargetType.TEStyle, MarkerDomain.BackTrans, ScrStyleNames.NormalParagraph, null));

            Assert.AreEqual(6, list.Count);

            ImportMappingInfo mapping = list[0];

            Assert.AreEqual(@"\a", mapping.BeginMarker);
            Assert.IsNull(mapping.EndMarker);
            Assert.AreEqual(ScrStyleNames.NormalParagraph, mapping.StyleName);
            Assert.AreEqual(MarkerDomain.Default, mapping.Domain);
            Assert.IsFalse(mapping.IsExcluded);
            Assert.IsFalse(mapping.IsInline);
            Assert.AreEqual(MappingTargetType.TEStyle, mapping.MappingTarget);
            Assert.AreEqual("es", mapping.IcuLocale);

            mapping = list[1];
            Assert.AreEqual(@"\b", mapping.BeginMarker);
            Assert.AreEqual(MarkerDomain.Default, mapping.Domain);

            mapping = list[2];
            Assert.AreEqual(@"\btp", mapping.BeginMarker);
            Assert.AreEqual(MarkerDomain.BackTrans, mapping.Domain);

            mapping = list[3];
            Assert.AreEqual(@"\c", mapping.BeginMarker);
            Assert.AreEqual(ScrStyleNames.ChapterNumber, mapping.StyleName);
            Assert.AreEqual(MarkerDomain.Default, mapping.Domain);

            mapping = list[4];
            Assert.AreEqual(@"\id", mapping.BeginMarker);
            Assert.IsNull(mapping.StyleName);
            Assert.AreEqual(MarkerDomain.Default, mapping.Domain);

            mapping = list[5];
            Assert.AreEqual(@"\v", mapping.BeginMarker);
            Assert.AreEqual(ScrStyleNames.VerseNumber, mapping.StyleName);
            Assert.AreEqual(MarkerDomain.Default, mapping.Domain);
        }
        public void Delete()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Main, null);

            list.Add(new ImportMappingInfo(@"\aa", null, false, MappingTargetType.TEStyle, MarkerDomain.Default, ScrStyleNames.Remark, null));
            list.Add(new ImportMappingInfo(@"\bb", null, false, MappingTargetType.TEStyle, MarkerDomain.Default, ScrStyleNames.Remark, null));
            list.Add(new ImportMappingInfo(@"\cc", null, false, MappingTargetType.TEStyle, MarkerDomain.BackTrans, ScrStyleNames.Remark, null));

            Assert.AreEqual(3, list.Count);

            list.Delete(list[1]);
            Assert.AreEqual(2, list.Count);

            Assert.AreEqual(@"\aa", list[0].BeginMarker);
            Assert.AreEqual(@"\cc", list[1].BeginMarker);
        }
        public void Enumerator()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Notes, null);

            list.Add(new ImportMappingInfo(@"\aa", null, false, MappingTargetType.TEStyle, MarkerDomain.Note, ScrStyleNames.Remark, null));
            list.Add(new ImportMappingInfo(@"\bb", null, false, MappingTargetType.TEStyle, MarkerDomain.Note, ScrStyleNames.Remark, null));
            list.Add(new ImportMappingInfo(@"\cc", null, false, MappingTargetType.TEStyle, MarkerDomain.Note, ScrStyleNames.Remark, null));

            int i = 0;

            foreach (ImportMappingInfo info in list)
            {
                Assert.AreEqual(list[i++], info);
            }
            Assert.AreEqual(3, i);
        }
        public override void FixtureSetup()
        {
            base.FixtureSetup();
            IWritingSystem wsSpanish;

            Cache.ServiceLocator.WritingSystemManager.GetOrSet("es", out wsSpanish);
            IWritingSystem wsGerman;

            Cache.ServiceLocator.WritingSystemManager.GetOrSet("de", out wsGerman);
            NonUndoableUnitOfWorkHelper.Do(m_actionHandler, () =>
            {
                Cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.Add(wsSpanish);
                Cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Add(wsSpanish);
                Cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.Add(wsGerman);
                Cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Add(wsGerman);
            });
            m_mappingList = new ScrMappingList(MappingSet.Main, null);
        }
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_mappingList = null;

            base.Dispose(disposing);
        }
        public void HasChanged()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Main, null);

            list.Add(new ImportMappingInfo(@"\aa", null, false, MappingTargetType.TEStyle, MarkerDomain.Default, ScrStyleNames.Remark, null));
            list.Add(new ImportMappingInfo(@"\bb", null, false, MappingTargetType.TEStyle, MarkerDomain.Default, ScrStyleNames.Remark, null));
            list.Add(new ImportMappingInfo(@"\cc", null, false, MappingTargetType.TEStyle, MarkerDomain.BackTrans, ScrStyleNames.Remark, null));
            Assert.IsTrue((bool)ReflectionHelper.GetProperty(list, "HasChanged"));

            Assert.AreEqual(3, list.Count);

            ReflectionHelper.SetProperty(list[0], "HasChanged", false);
            ReflectionHelper.SetProperty(list[1], "HasChanged", false);
            ReflectionHelper.SetProperty(list[2], "HasChanged", false);
            Assert.IsFalse((bool)ReflectionHelper.GetProperty(list, "HasChanged"));

            list.Delete(list[1]);
            Assert.AreEqual(2, list.Count);
            Assert.IsTrue((bool)ReflectionHelper.GetProperty(list, "HasChanged"));
        }
Beispiel #23
0
        public void LoadParatextMappings_Normal()
        {
            Unpacker.UnPackParatextTestProjects();
            IParatextAdapter sut = new ParatextProxy();

            FwStyleSheet stylesheet = new FwStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            ScrMappingList mappingList = new ScrMappingList(MappingSet.Main, stylesheet);

            Assert.IsTrue(sut.LoadProjectMappings("KAM", mappingList, ImportDomain.Main));

            // Test to see that the projects are set correctly
            Assert.AreEqual(44, mappingList.Count);

            Assert.AreEqual(MarkerDomain.Default, mappingList[@"\c"].Domain);
            Assert.AreEqual(MarkerDomain.Default, mappingList[@"\v"].Domain);
            Assert.AreEqual(@"\f*", mappingList[@"\f"].EndMarker);
            Assert.IsTrue(mappingList[@"\p"].IsInUse);
            Assert.IsFalse(mappingList[@"\tb2"].IsInUse);
        }
Beispiel #24
0
        public void AddDefaultMappingIfNeeded_btMappingsWithNonDefaultMappings()
        {
            IVwStylesheet stylesheet = MockRepository.GenerateStub <IVwStylesheet>();

            stylesheet.Stub(x => x.GetContext("Emphasis")).Return((int)ContextValues.General);
            stylesheet.Stub(x => x.GetType("Emphasis")).Return((int)StyleType.kstCharacter);

            ScrMappingList list = new ScrMappingList(MappingSet.Main, stylesheet, TestTeStylesPath);

            list.Add(new ImportMappingInfo(@"\p", null, "Emphasis"));
            list.AddDefaultMappingIfNeeded(@"\btp", ImportDomain.Main, true);
            Assert.AreEqual(2, list.Count);

            // Test that \btp maps automatically to the corresponding vernacular style ("Emphasis")
            // but does not map into the Back-trans marker domain because Emphasis is a character style.
            ImportMappingInfo info = list[@"\btp"];

            Assert.AreEqual(MarkerDomain.Default, info.Domain, @"\btp should not map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.AreEqual("Emphasis", info.StyleName);
        }
        public void AddDefaultMappingIfNeeded_btMappingsWithNonDefaultMappings()
        {
            DynamicMock mockStylesheet = new DynamicMock(typeof(IVwStylesheet));

            mockStylesheet.SetupResultForParams("GetContext", (int)ContextValues.General, "Emphasis");
            mockStylesheet.SetupResultForParams("GetType", (int)StyleType.kstCharacter, "Emphasis");

            ScrMappingList list = new ScrMappingList(MappingSet.Main, (IVwStylesheet)mockStylesheet.MockInstance);

            list.Add(new ImportMappingInfo(@"\p", null, "Emphasis"));
            list.AddDefaultMappingIfNeeded(@"\btp", ImportDomain.Main, true);
            Assert.AreEqual(2, list.Count);

            // Test that \btp maps automatically to the corresponding vernacular style ("Emphasis")
            // but does not map into the Back-trans marker domain because Emphasis is a character style.
            ImportMappingInfo info = list[@"\btp"];

            Assert.AreEqual(MarkerDomain.Default, info.Domain, @"\btp should not map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.AreEqual("Emphasis", info.StyleName);
        }
Beispiel #26
0
        public void LoadParatextMappings_Normal()
        {
            Unpacker.UnPackParatextTestProjects();

            var stylesheet = new FwStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            importSettings.ParatextScrProj = "KAM";
            ParatextHelper.LoadProjectMappings(importSettings);

            ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main);

            // Test to see that the projects are set correctly
            Assert.AreEqual(44, mappingList.Count);

            Assert.AreEqual(MarkerDomain.Default, mappingList[@"\c"].Domain);
            Assert.AreEqual(MarkerDomain.Default, mappingList[@"\v"].Domain);
            Assert.AreEqual(@"\f*", mappingList[@"\f"].EndMarker);
            Assert.IsTrue(mappingList[@"\p"].IsInUse);
            Assert.IsFalse(mappingList[@"\tb2"].IsInUse);
        }
Beispiel #27
0
        public void AddDefaultMappingIfNeeded_FigureMarkers()
        {
            IVwStylesheet stylesheet = MockRepository.GenerateMock <IVwStylesheet>();

            ScrMappingList list = new ScrMappingList(MappingSet.Main, stylesheet, TestTeStylesPath);

            list.AddDefaultMappingIfNeeded(@"\cap", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\cat", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\gmb", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\gmbj", ImportDomain.Main, true);
            Assert.AreEqual(4, list.Count);

            ImportMappingInfo info = list[@"\cap"];

            Assert.AreEqual(MarkerDomain.Default, info.Domain);
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.FigureCaption, info.MappingTarget);
            Assert.IsNull(info.StyleName);

            info = list[@"\cat"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain);
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.FigureFilename, info.MappingTarget);
            Assert.IsNull(info.StyleName);

            info = list[@"\gmb"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain);
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.FigureFilename, info.MappingTarget);
            Assert.IsNull(info.StyleName);

            info = list[@"\gmbj"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain);
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.FigureCaption, info.MappingTarget);
            Assert.IsNull(info.StyleName);
        }
        public void AddDefaultMappingIfNeeded_FigureMarkers()
        {
            DynamicMock mockStylesheet = new DynamicMock(typeof(IVwStylesheet));

            ScrMappingList list = new ScrMappingList(MappingSet.Main, (IVwStylesheet)mockStylesheet.MockInstance);

            list.AddDefaultMappingIfNeeded(@"\cap", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\cat", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\gmb", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\gmbj", ImportDomain.Main, true);
            Assert.AreEqual(4, list.Count);

            ImportMappingInfo info = list[@"\cap"];

            Assert.AreEqual(MarkerDomain.Default, info.Domain);
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.FigureCaption, info.MappingTarget);
            Assert.IsNull(info.StyleName);

            info = list[@"\cat"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain);
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.FigureFilename, info.MappingTarget);
            Assert.IsNull(info.StyleName);

            info = list[@"\gmb"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain);
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.FigureFilename, info.MappingTarget);
            Assert.IsNull(info.StyleName);

            info = list[@"\gmbj"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain);
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.FigureCaption, info.MappingTarget);
            Assert.IsNull(info.StyleName);
        }
        public void SetMappings_Notes()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Notes, null);

            list.Add(new ImportMappingInfo(@"\a", null, false, MappingTargetType.TEStyle, MarkerDomain.Note, ScrStyleNames.Remark, null));
            list.Add(new ImportMappingInfo(@"\b", null, false, MappingTargetType.TEStyle, MarkerDomain.Default, ScrStyleNames.Remark, null));
            try
            {
                list.Add(new ImportMappingInfo(@"\q", null, false, MappingTargetType.TEStyle, MarkerDomain.BackTrans, ScrStyleNames.NormalParagraph, null));
                Assert.Fail("Illegal mapping (to BackTrans domain) was not caught");
            }
            catch (ArgumentException) {}

            Assert.AreEqual(2, list.Count);

            ImportMappingInfo mapping = list[0];

            Assert.AreEqual(@"\a", mapping.BeginMarker);
            Assert.AreEqual(MarkerDomain.Default, mapping.Domain);

            mapping = list[1];
            Assert.AreEqual(@"\b", mapping.BeginMarker);
            Assert.AreEqual(MarkerDomain.Default, mapping.Domain);
        }
        public void AddBlankMarker()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Main, null);

            list.Add(new ImportMappingInfo(string.Empty, string.Empty, string.Empty));
        }