Пример #1
0
		public void ConvertingTextSegments_InterleavedBt()
		{
			string filename = m_fileOs.MakeSfFile(Encoding.GetEncoding(EncodingConstants.kMagicCodePage), false, "MAT",
				@"\mt Matthew",
				@"\c 1",
				@"\v 1 This is my verse text",
				@"\rt my Back translation",
				@"\v 2 Second verse");
			m_settings.AddFile(filename, ImportDomain.Main, null, null);

			ImportMappingInfo mapping = m_settings.MappingForMarker(@"\rt", MappingSet.Main);
			mapping.StyleName = "Default Paragraph Characters";
			mapping.Domain = MarkerDomain.BackTrans;

			// Set the vernacular WS to use the UPPERCASE encoding converter
			VernacularWs.LegacyMapping = "UPPERCASE";

			// Save settings before enumerating, which will get the styles hooked up in the mapping list
			m_settings.SaveSettings();

			m_converters = MockRepository.GenerateStub<IEncConverters>();
			m_converters.Stub(x => x["UPPERCASE"]).Return(new DummyEncConverter());
			ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
				new ScrReference(40, 0, 0, ScrVers.English),
				new ScrReference(40, 1, 2, ScrVers.English));

			ISCTextSegment textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read id segment ");
			Assert.AreEqual(@"\id", textSeg.Marker);
			Assert.AreEqual("MAT ", textSeg.Text);
			Assert.AreEqual(40, textSeg.FirstReference.Book);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read mt segment");
			Assert.AreEqual(@"\mt", textSeg.Marker);
			Assert.AreEqual(@"MATTHEW ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read c segment");
			Assert.AreEqual(@"\c", textSeg.Marker);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read v 1");
			Assert.AreEqual(@"\v", textSeg.Marker);
			Assert.AreEqual("1", textSeg.LiteralVerseNum);
			Assert.AreEqual(@" THIS IS MY VERSE TEXT ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read btvt segment");
			Assert.AreEqual(@"\rt", textSeg.Marker);
			Assert.AreEqual(@"my Back translation ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read v 2");
			Assert.AreEqual(@"\v", textSeg.Marker);
			Assert.AreEqual("2", textSeg.LiteralVerseNum);
			Assert.AreEqual(@" SECOND VERSE ", textSeg.Text);

			Assert.IsNull(textEnum.Next());
		}
Пример #2
0
		public void ConvertingTextSegments_BTImportDomain()
		{
			string filename = m_fileOs.MakeSfFile(Encoding.GetEncoding(EncodingConstants.kMagicCodePage), false, "MAT",
				@"\mt Matthew",
				@"\c 1",
				@"\v 1",
				@"\vt my \uw retronica\uw* translation",
				@"\k keywordbt");
			m_settings.AddFile(filename, ImportDomain.BackTrans, "en", null);

			m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\uw ", @"\uw*", false,
				MappingTargetType.TEStyle, MarkerDomain.BackTrans, "Untranslated Word", "es"));
			m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\k", null, "Key Word"));

			// Set the English WS to use the UPPERCASE encoding converter
			Cache.ServiceLocator.WritingSystemManager.Get("en").LegacyMapping = "UPPERCASE";

			// Save settings before enumerating, which will get the styles hooked up in the mapping list
			m_settings.SaveSettings();

			m_converters = MockRepository.GenerateStub<IEncConverters>();
			m_converters.Stub(x => x["UPPERCASE"]).Return(new DummyEncConverter());
			ISCTextEnum textEnum = GetTextEnum(ImportDomain.BackTrans,
				new ScrReference(40, 0, 0, ScrVers.English),
				new ScrReference(40, 1, 2, ScrVers.English));

			ISCTextSegment textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read id segment ");
			Assert.AreEqual(@"\id", textSeg.Marker);
			Assert.AreEqual("MAT ", textSeg.Text);
			Assert.AreEqual(40, textSeg.FirstReference.Book);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read mt segment");
			Assert.AreEqual(@"\mt", textSeg.Marker);
			Assert.AreEqual(@"MATTHEW ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read c segment");
			Assert.AreEqual(@"\c", textSeg.Marker);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read v 1");
			Assert.AreEqual(@"\v", textSeg.Marker);
			Assert.AreEqual("1", textSeg.LiteralVerseNum);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read first vt segment");
			Assert.AreEqual(@"\vt", textSeg.Marker);
			Assert.AreEqual(@"MY ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read untranslated word segment (Spanish)");
			Assert.AreEqual(@"\uw ", textSeg.Marker);
			Assert.AreEqual(@"retronica", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to segment following untranslated word");
			Assert.AreEqual(@"\uw*", textSeg.Marker);
			Assert.AreEqual(@" TRANSLATION ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read keyword segment");
			Assert.AreEqual(@"\k", textSeg.Marker);
			Assert.AreEqual(@"KEYWORDBT ", textSeg.Text);

			Assert.IsNull(textEnum.Next());
		}
Пример #3
0
		public void ConvertingTextSegments_MainImportDomain()
		{
			string filename = m_fileOs.MakeSfFile(Encoding.GetEncoding(EncodingConstants.kMagicCodePage), false, "MAT",
				@"\mt Matthew",
				@"\c 1",
				@"\v 1",
				@"\vt This is \em my\em* verse text with a",
				@"\sp espanol",
				@"\k keyword",
				@"\f footnote text", // This tests the switch statement in GetEncodingConverterForMarkerDomain
				@"\spkwf raro", // This tests the need for & ~MarkerDomain.Footnote in ConvertSource
				@"\ft end of footnote",
				@"\btvt my \em Back\em* translation",
				@"\k keywordbt");
			m_settings.AddFile(filename, ImportDomain.Main, null, null);

			m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\em ", @"\em*", "Emphasis"));
			m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\k", null, "Key Word"));

			ImportMappingInfo mapping = m_settings.MappingForMarker(@"\sp", MappingSet.Main);
			mapping.StyleName = "Default Paragraph Characters";
			mapping.WsId = "es";
			mapping = m_settings.MappingForMarker(@"\f", MappingSet.Main);
			mapping.StyleName = ScrStyleNames.NormalFootnoteParagraph;

			mapping = m_settings.MappingForMarker(@"\spkwf", MappingSet.Main);
			mapping.StyleName = "Key Word";
			mapping.WsId = "es";
			mapping.Domain = MarkerDomain.Default | MarkerDomain.Footnote;

			mapping = m_settings.MappingForMarker(@"\ft", MappingSet.Main);
			mapping.StyleName = "Default Paragraph Characters";
			mapping.Domain = MarkerDomain.Default | MarkerDomain.Footnote;

			mapping = m_settings.MappingForMarker(@"\btvt", MappingSet.Main);
			mapping.Domain = MarkerDomain.BackTrans;

			// Set the vernacular WS to use the UPPERCASE encoding converter
			VernacularWs.LegacyMapping = "UPPERCASE";

			// Save settings before enumerating, which will get the styles hooked up in the mapping list
			m_settings.SaveSettings();

			m_converters = MockRepository.GenerateStub<IEncConverters>();
			m_converters.Stub(x => x["UPPERCASE"]).Return(new DummyEncConverter());
			ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
				new ScrReference(40, 0, 0, ScrVers.English),
				new ScrReference(40, 1, 2, ScrVers.English));

			ISCTextSegment textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read id segment ");
			Assert.AreEqual(@"\id", textSeg.Marker);
			Assert.AreEqual("MAT ", textSeg.Text);
			Assert.AreEqual(40, textSeg.FirstReference.Book);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read mt segment");
			Assert.AreEqual(@"\mt", textSeg.Marker);
			Assert.AreEqual(@"MATTHEW ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read c segment");
			Assert.AreEqual(@"\c", textSeg.Marker);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read v 1");
			Assert.AreEqual(@"\v", textSeg.Marker);
			Assert.AreEqual("1", textSeg.LiteralVerseNum);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read first vt segment");
			Assert.AreEqual(@"\vt", textSeg.Marker);
			Assert.AreEqual(@"THIS IS ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read emphasis segment");
			Assert.AreEqual(@"\em ", textSeg.Marker);
			Assert.AreEqual(@"MY", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read emphasis segment");
			Assert.AreEqual(@"\em*", textSeg.Marker);
			Assert.AreEqual(@" VERSE TEXT WITH A ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read Spanish segment");
			Assert.AreEqual(@"\sp", textSeg.Marker);
			Assert.AreEqual(@"espanol ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read keyword segment");
			Assert.AreEqual(@"\k", textSeg.Marker);
			Assert.AreEqual(@"KEYWORD ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read footnote text segment");
			Assert.AreEqual(@"\f", textSeg.Marker);
			Assert.AreEqual(@"FOOTNOTE TEXT ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read Spanish keyword in footnote segment");
			Assert.AreEqual(@"\spkwf", textSeg.Marker);
			Assert.AreEqual(@"raro ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read end of footnote segment");
			Assert.AreEqual(@"\ft", textSeg.Marker);
			Assert.AreEqual(@"END OF FOOTNOTE ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read btvt segment");
			Assert.AreEqual(@"\btvt", textSeg.Marker);
			Assert.AreEqual(@"my ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, @"Unable to read BT \em segment");
			Assert.AreEqual(@"\em ", textSeg.Marker);
			Assert.AreEqual(@"Back", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, @"Unable to read BT \em segment");
			Assert.AreEqual(@"\em*", textSeg.Marker);
			Assert.AreEqual(@" translation ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read BT keyword segment");
			Assert.AreEqual(@"\k", textSeg.Marker);
			Assert.AreEqual(@"keywordbt ", textSeg.Text);

			Assert.IsNull(textEnum.Next());
		}