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_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); }