コード例 #1
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.");
        }
コード例 #2
0
        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);
        }
コード例 #3
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);
        }
コード例 #4
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.");
        }
コード例 #5
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.");
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
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>());
        }
コード例 #9
0
        public void AddInfoWithNullMarker()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Main, null, null);

            Assert.That(() => list.Add(new ImportMappingInfo(null, null, null)),
                        Throws.TypeOf <ArgumentException>());
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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];
        }
コード例 #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>());
        }
コード例 #13
0
        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"));
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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);
        }
コード例 #16
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);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        public void AddNullMappingInfo()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Main, null, null);

            Assert.That(() => list.Add(null), Throws.TypeOf <ArgumentNullException>());
        }
コード例 #19
0
        public void AddBlankMarker()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Main, null);

            list.Add(new ImportMappingInfo(string.Empty, string.Empty, string.Empty));
        }
コード例 #20
0
        public void AddInfoWithNullMarker()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Main, null);

            list.Add(new ImportMappingInfo(null, null, null));
        }
コード例 #21
0
        public void AddNullMappingInfo()
        {
            ScrMappingList list = new ScrMappingList(MappingSet.Main, null);

            list.Add(null);
        }
コード例 #22
0
        public void AddDefaultMappingIfNeeded_btMappings()
        {
            DynamicMock mockStylesheet = new DynamicMock(typeof(IVwStylesheet));

            mockStylesheet.SetupResultForParams("GetContext", (int)ContextValues.Note, ScrStyleNames.NormalFootnoteParagraph);
            mockStylesheet.SetupResultForParams("GetContext", (int)ContextValues.Text, ScrStyleNames.NormalParagraph);
            mockStylesheet.SetupResultForParams("GetContext", (int)ContextValues.General, "Emphasis");
            mockStylesheet.SetupResultForParams("GetContext", (int)ContextValues.Annotation, ScrStyleNames.Remark);
            mockStylesheet.SetupResultForParams("GetType", (int)StyleType.kstParagraph, ScrStyleNames.NormalFootnoteParagraph);
            mockStylesheet.SetupResultForParams("GetType", (int)StyleType.kstParagraph, ScrStyleNames.NormalParagraph);
            mockStylesheet.SetupResultForParams("GetType", (int)StyleType.kstCharacter, "Emphasis");
            mockStylesheet.SetupResultForParams("GetType", (int)StyleType.kstParagraph, ScrStyleNames.Remark);

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

            list.AddDefaultMappingIfNeeded(@"\bt", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\btc", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\btf", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\btp", ImportDomain.Main, true);
            list.Add(new ImportMappingInfo(@"\emph", null, "Emphasis"));
            list.AddDefaultMappingIfNeeded(@"\btemph", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\btrem", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\bty", ImportDomain.Main, true);
            Assert.AreEqual(8, list.Count);

            // Test that \bt does not map automatically as a Back-trans marker.
            ImportMappingInfo info = list[@"\bt"];

            Assert.AreEqual(MarkerDomain.Default, info.Domain, @"\bt should not map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.IsNull(info.StyleName);

            // Test that \btc does not map automatically as a Back-trans marker (this is a special exception to the rul).
            info = list[@"\btc"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain, @"\btc should not map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.IsNull(info.StyleName);

            // Test that \btf maps automatically as a Back-trans marker.
            info = list[@"\btf"];
            Assert.AreEqual(MarkerDomain.BackTrans | MarkerDomain.Footnote, info.Domain, @"\btf should map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.AreEqual(ScrStyleNames.NormalFootnoteParagraph, info.StyleName);

            // Test that \btp maps automatically as a Back-trans marker.
            info = list[@"\btp"];
            Assert.AreEqual(MarkerDomain.BackTrans, info.Domain, @"\btp should map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.AreEqual(ScrStyleNames.NormalParagraph, info.StyleName);

            // Test that \btemph maps automatically to the corresponding vernacular style but does not map
            // into the Back-trans marker domain because \emph is a character style.
            info = list[@"\btemph"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain, @"\btemph should not map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.AreEqual("Emphasis", info.StyleName);

            // Test that \btrem does not map automatically as a Back-trans marker (because \rem is a Note style).
            info = list[@"\btrem"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain, @"\btrem should not map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.IsNull(info.StyleName);

            // Test that \bty does not map automatically as a Back-trans marker (because \y has no default mapping).
            info = list[@"\bty"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain, @"\bty should not map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.IsNull(info.StyleName);
        }
コード例 #23
0
        public void AddDefaultMappingIfNeeded_btMappings()
        {
            IVwStylesheet stylesheet = MockRepository.GenerateStub <IVwStylesheet>();

            stylesheet.Stub(x => x.GetContext(ScrStyleNames.NormalFootnoteParagraph)).Return((int)ContextValues.Note);
            stylesheet.Stub(x => x.GetContext(ScrStyleNames.NormalParagraph)).Return((int)ContextValues.Text);
            stylesheet.Stub(x => x.GetContext("Emphasis")).Return((int)ContextValues.General);
            stylesheet.Stub(x => x.GetContext(ScrStyleNames.Remark)).Return((int)ContextValues.Annotation);

            stylesheet.Stub(x => x.GetType(ScrStyleNames.NormalFootnoteParagraph)).Return((int)StyleType.kstParagraph);
            stylesheet.Stub(x => x.GetType(ScrStyleNames.NormalParagraph)).Return((int)StyleType.kstParagraph);
            stylesheet.Stub(x => x.GetType("Emphasis")).Return((int)StyleType.kstCharacter);
            stylesheet.Stub(x => x.GetType(ScrStyleNames.Remark)).Return((int)StyleType.kstParagraph);

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

            list.AddDefaultMappingIfNeeded(@"\bt", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\btc", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\btf", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\btp", ImportDomain.Main, true);
            list.Add(new ImportMappingInfo(@"\emph", null, "Emphasis"));
            list.AddDefaultMappingIfNeeded(@"\btemph", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\btrem", ImportDomain.Main, true);
            list.AddDefaultMappingIfNeeded(@"\bty", ImportDomain.Main, true);
            Assert.AreEqual(8, list.Count);

            // Test that \bt does not map automatically as a Back-trans marker.
            ImportMappingInfo info = list[@"\bt"];

            Assert.AreEqual(MarkerDomain.Default, info.Domain, @"\bt should not map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.IsNull(info.StyleName);

            // Test that \btc does not map automatically as a Back-trans marker (this is a special exception to the rul).
            info = list[@"\btc"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain, @"\btc should not map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.IsNull(info.StyleName);

            // Test that \btf maps automatically as a Back-trans marker.
            info = list[@"\btf"];
            Assert.AreEqual(MarkerDomain.BackTrans | MarkerDomain.Footnote, info.Domain, @"\btf should map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.AreEqual(ScrStyleNames.NormalFootnoteParagraph, info.StyleName);

            // Test that \btp maps automatically as a Back-trans marker.
            info = list[@"\btp"];
            Assert.AreEqual(MarkerDomain.BackTrans, info.Domain, @"\btp should map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.AreEqual(ScrStyleNames.NormalParagraph, info.StyleName);

            // Test that \btemph maps automatically to the corresponding vernacular style but does not map
            // into the Back-trans marker domain because \emph is a character style.
            info = list[@"\btemph"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain, @"\btemph should not map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.AreEqual("Emphasis", info.StyleName);

            // Test that \btrem does not map automatically as a Back-trans marker (because \rem is a Note style).
            info = list[@"\btrem"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain, @"\btrem should not map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.IsNull(info.StyleName);

            // Test that \bty does not map automatically as a Back-trans marker (because \y has no default mapping).
            info = list[@"\bty"];
            Assert.AreEqual(MarkerDomain.Default, info.Domain, @"\bty should not map automatically as a Back-trans marker");
            Assert.IsFalse(info.IsExcluded);
            Assert.AreEqual(MappingTargetType.TEStyle, info.MappingTarget);
            Assert.IsNull(info.StyleName);
        }