Exemplo n.º 1
0
		public void TestCreateFileIdLineOnly_ASCII()
		{
			CheckDisposed();
			using (TempSFFileMaker testFileMaker = new TempSFFileMaker())
			{
				string filename = testFileMaker.CreateFile("EPH", null);

				// Check the file contents.
				using (BinaryReader file = new BinaryReader(new FileStream(filename, FileMode.Open)))
				{
					byte[] fileContents = file.ReadBytes((int)file.BaseStream.Length);
					int i = 0;
					Assert.AreEqual(92, fileContents[i++]);
					Assert.AreEqual(105, fileContents[i++]);
					Assert.AreEqual(100, fileContents[i++]);
					Assert.AreEqual(32, fileContents[i++]);
					Assert.AreEqual(69, fileContents[i++]);
					Assert.AreEqual(80, fileContents[i++]);
					Assert.AreEqual(72, fileContents[i++]);
					Assert.AreEqual(s_cr, fileContents[i++]);
					Assert.AreEqual(s_lf, fileContents[i++]);
					file.Close();
				}
			}
		}
Exemplo n.º 2
0
        public void EncodeLine_Backslashes()
        {
            byte[] line = TempSFFileMaker.EncodeLine("abc" + @"\\" + "def", Encoding.ASCII);
            Assert.AreEqual(10, line.Length);
            int i = 0;

            Assert.AreEqual('a', line[i++]);
            Assert.AreEqual('b', line[i++]);
            Assert.AreEqual('c', line[i++]);
            Assert.AreEqual('\\', line[i++]);
            Assert.AreEqual('\\', line[i++]);
            Assert.AreEqual('d', line[i++]);
            Assert.AreEqual('e', line[i++]);
            Assert.AreEqual('f', line[i++]);
            Assert.AreEqual(s_cr, line[i++]);
            Assert.AreEqual(s_lf, line[i++]);

            TempSFFileMaker testFileMaker = new TempSFFileMaker();
            string          filename      = testFileMaker.CreateFile("EPH", new[] { @"\v 1 c:\abc\def" }, Encoding.UTF8, false);

            using (TextReader reader = FileUtils.OpenFileForRead(filename, Encoding.UTF8))
            {
                Assert.AreEqual(@"\id EPH", reader.ReadLine());
                Assert.AreEqual(@"\v 1 c:\abc\def", reader.ReadLine());
            }
        }
Exemplo n.º 3
0
        public void TestCreateFile_UnicodeBOM()
        {
            TempSFFileMaker testFileMaker = new TempSFFileMaker();
            string          filename      = testFileMaker.CreateFile("EPH", null, Encoding.Unicode, true);

            // Check the file contents.
            using (BinaryReader file = FileUtils.OpenFileForBinaryRead(filename, Encoding.Unicode))
            {
                byte[] fileContents = file.ReadBytes((int)file.BaseStream.Length);
                int    i            = 0;
                Assert.AreEqual(0xff, fileContents[i++]);
                Assert.AreEqual(0xfe, fileContents[i++]);
                Assert.AreEqual(92, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(105, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(100, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(32, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(69, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(80, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(72, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(s_cr, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(s_lf, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
            }
        }
Exemplo n.º 4
0
        public void TestCreateFileIdLineOnly_ASCII()
        {
            CheckDisposed();
            using (TempSFFileMaker testFileMaker = new TempSFFileMaker())
            {
                string filename = testFileMaker.CreateFile("EPH", null);

                // Check the file contents.
                using (BinaryReader file = new BinaryReader(new FileStream(filename, FileMode.Open)))
                {
                    byte[] fileContents = file.ReadBytes((int)file.BaseStream.Length);
                    int    i            = 0;
                    Assert.AreEqual(92, fileContents[i++]);
                    Assert.AreEqual(105, fileContents[i++]);
                    Assert.AreEqual(100, fileContents[i++]);
                    Assert.AreEqual(32, fileContents[i++]);
                    Assert.AreEqual(69, fileContents[i++]);
                    Assert.AreEqual(80, fileContents[i++]);
                    Assert.AreEqual(72, fileContents[i++]);
                    Assert.AreEqual(s_cr, fileContents[i++]);
                    Assert.AreEqual(s_lf, fileContents[i++]);
                    file.Close();
                }
            }
        }
Exemplo n.º 5
0
        public void EncodeLine_Backslashes()
        {
            CheckDisposed();
            byte[] line = TempSFFileMaker.EncodeLine("abc" + @"\\" + "def", Encoding.ASCII);
            Assert.AreEqual(10, line.Length);
            int i = 0;

            Assert.AreEqual('a', line[i++]);
            Assert.AreEqual('b', line[i++]);
            Assert.AreEqual('c', line[i++]);
            Assert.AreEqual('\\', line[i++]);
            Assert.AreEqual('\\', line[i++]);
            Assert.AreEqual('d', line[i++]);
            Assert.AreEqual('e', line[i++]);
            Assert.AreEqual('f', line[i++]);
            Assert.AreEqual(s_cr, line[i++]);
            Assert.AreEqual(s_lf, line[i++]);

            using (TempSFFileMaker testFileMaker = new TempSFFileMaker())
            {
                string filename = testFileMaker.CreateFile("EPH", new string[] { @"\v 1 c:\abc\def" }, Encoding.UTF8, false);
                using (StreamReader reader = new StreamReader(filename))
                {
                    Assert.AreEqual(@"\id EPH", reader.ReadLine());
                    Assert.AreEqual(@"\v 1 c:\abc\def", reader.ReadLine());
                }
            }
        }
Exemplo n.º 6
0
		public void LoadParatext5Project()
		{
			CheckDisposed();

			ScrObjWrapper wrapper = new ScrObjWrapper();
			ScrImportSet settings = new ScrImportSet();
			Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(settings);
			settings.ImportTypeEnum = TypeOfImport.Paratext5;
			settings.StartRef = new BCVRef(1, 1, 1);
			settings.EndRef = new BCVRef(66, 22, 21);
			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string fileName = fileMaker.CreateFile("EXO",
					new string[] {@"\mt Exodus", @"\c 1", @"\v 1 This is fun!"});
				settings.AddFile(fileName, ImportDomain.Main, null, 0);

				wrapper.LoadScriptureProject(settings);
				Assert.IsFalse(wrapper.BooksPresent.Contains(1));
				Assert.IsTrue(wrapper.BooksPresent.Contains(2));
				string sText, sMarker;
				ImportDomain domain;
				Assert.IsTrue(wrapper.GetNextSegment(out sText, out sMarker, out domain));
				Assert.AreEqual(fileName, wrapper.CurrentFileName);
				Assert.AreEqual(1, wrapper.CurrentLineNumber);
				Assert.AreEqual(new BCVRef(2, 1, 0), wrapper.SegmentFirstRef);
				Assert.AreEqual(new BCVRef(2, 1, 0), wrapper.SegmentLastRef);
				Assert.AreEqual(2, wrapper.ExternalPictureFolders.Count);
				Assert.AreEqual(Cache.LangProject.ExternalLinkRootDir,
					wrapper.ExternalPictureFolders[0]);
				Assert.AreEqual(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
					wrapper.ExternalPictureFolders[1]);
			}
		}
Exemplo n.º 7
0
		public void TestCreateFileNullSILBookId()
		{
			CheckDisposed();
			using (TempSFFileMaker testFileMaker = new TempSFFileMaker())
			{
				testFileMaker.CreateFile(null, null);
			}
		}
Exemplo n.º 8
0
 public void TestCreateFileNullSILBookId()
 {
     CheckDisposed();
     using (TempSFFileMaker testFileMaker = new TempSFFileMaker())
     {
         testFileMaker.CreateFile(null, null);
     }
 }
Exemplo n.º 9
0
        public void EncodeLine_ASCII()
        {
            byte[] line = TempSFFileMaker.EncodeLine("abcd", Encoding.ASCII);
            Assert.AreEqual(6, line.Length);
            int i = 0;

            Assert.AreEqual(97, line[i++]);
            Assert.AreEqual(98, line[i++]);
            Assert.AreEqual(99, line[i++]);
            Assert.AreEqual(100, line[i++]);
            Assert.AreEqual(s_cr, line[i++]);
            Assert.AreEqual(s_lf, line[i++]);
        }
Exemplo n.º 10
0
        public void EncodeLine_UTF8()
        {
            byte[] line = TempSFFileMaker.EncodeLine("abc" + '\u1234', Encoding.UTF8);
            Assert.AreEqual(8, line.Length);
            int i = 0;

            Assert.AreEqual(97, line[i++]);
            Assert.AreEqual(98, line[i++]);
            Assert.AreEqual(99, line[i++]);
            Assert.AreEqual(0xe1, line[i++]);
            Assert.AreEqual(0x88, line[i++]);
            Assert.AreEqual(0xb4, line[i++]);
            Assert.AreEqual(s_cr, line[i++]);
            Assert.AreEqual(s_lf, line[i++]);
        }
Exemplo n.º 11
0
        public void EncodeLine_BigEndianUnicode()
        {
            byte[] line = TempSFFileMaker.EncodeLine("abc" + '\u1234', Encoding.BigEndianUnicode);
            Assert.AreEqual(12, line.Length);
            int i = 0;

            Assert.AreEqual(0, line[i++]);
            Assert.AreEqual(97, line[i++]);
            Assert.AreEqual(0, line[i++]);
            Assert.AreEqual(98, line[i++]);
            Assert.AreEqual(0, line[i++]);
            Assert.AreEqual(99, line[i++]);
            Assert.AreEqual(0x12, line[i++]);
            Assert.AreEqual(0x34, line[i++]);
            Assert.AreEqual(0, line[i++]);
            Assert.AreEqual(s_cr, line[i++]);
            Assert.AreEqual(0, line[i++]);
            Assert.AreEqual(s_lf, line[i++]);
        }
Exemplo n.º 12
0
		public void TestCreateFileIdLineOnly_ASCII()
		{
			TempSFFileMaker testFileMaker = new TempSFFileMaker();
			string filename = testFileMaker.CreateFile("EPH", null);

			// Check the file contents.
			using (BinaryReader file = FileUtils.OpenFileForBinaryRead(filename, Encoding.ASCII))
			{
				byte[] fileContents = file.ReadBytes((int)file.BaseStream.Length);
				int i = 0;
				Assert.AreEqual(92, fileContents[i++]);
				Assert.AreEqual(105, fileContents[i++]);
				Assert.AreEqual(100, fileContents[i++]);
				Assert.AreEqual(32, fileContents[i++]);
				Assert.AreEqual(69, fileContents[i++]);
				Assert.AreEqual(80, fileContents[i++]);
				Assert.AreEqual(72, fileContents[i++]);
				Assert.AreEqual(s_cr, fileContents[i++]);
				Assert.AreEqual(s_lf, fileContents[i++]);
			}
		}
Exemplo n.º 13
0
        public void TestCreateFileThreeLines_ASCII()
        {
            TempSFFileMaker testFileMaker = new TempSFFileMaker();
            string          filename      = testFileMaker.CreateFile("EPH", new string[] { @"\mt test", @"\p" });

            // Check the file contents.
            using (BinaryReader file = FileUtils.OpenFileForBinaryRead(filename, Encoding.ASCII))
            {
                byte[] fileContents = file.ReadBytes((int)file.BaseStream.Length);
                int    i            = 0;
                Assert.AreEqual(92, fileContents[i++]);
                Assert.AreEqual(105, fileContents[i++]);
                Assert.AreEqual(100, fileContents[i++]);
                Assert.AreEqual(32, fileContents[i++]);
                Assert.AreEqual(69, fileContents[i++]);
                Assert.AreEqual(80, fileContents[i++]);
                Assert.AreEqual(72, fileContents[i++]);
                Assert.AreEqual(s_cr, fileContents[i++]);
                Assert.AreEqual(s_lf, fileContents[i++]);

                Assert.AreEqual(92, fileContents[i++]);
                Assert.AreEqual(109, fileContents[i++]);
                Assert.AreEqual(116, fileContents[i++]);
                Assert.AreEqual(32, fileContents[i++]);
                Assert.AreEqual(116, fileContents[i++]);
                Assert.AreEqual(101, fileContents[i++]);
                Assert.AreEqual(115, fileContents[i++]);
                Assert.AreEqual(116, fileContents[i++]);
                Assert.AreEqual(s_cr, fileContents[i++]);
                Assert.AreEqual(s_lf, fileContents[i++]);

                Assert.AreEqual(92, fileContents[i++]);
                Assert.AreEqual(112, fileContents[i++]);
                Assert.AreEqual(s_cr, fileContents[i++]);
                Assert.AreEqual(s_lf, fileContents[i++]);
            }
        }
Exemplo n.º 14
0
		public void TestCheckForOverlaps_KeepFile2()
		{
			// Add temp file to the project
			using (TempSFFileMaker filemaker = new TempSFFileMaker())
			{
				ScrImportFileInfo f1 = new ScrImportFileInfo(
					filemaker.CreateFile("MAT", new string[] {@"\c 1", @"\c 2", @"\c 3"}),
					m_mappingList, ImportDomain.Main, null, 0, false);

				m_expectedRemovedFiles.Add(f1);

				ScrImportFileInfo f2 = new ScrImportFileInfo(
					filemaker.CreateFile("MAT", new string[] {@"\c 3", @"\c 4", @"\c 5"}),
					m_mappingList, ImportDomain.Main, null, 0, false);

				ScrImportFileInfo f3 = new ScrImportFileInfo(
					filemaker.CreateFile("MAT", new string[] {@"\c 6", @"\c 7"}),
					m_mappingList, ImportDomain.Main, null, 0, false);

				ScrImportFileInfo f4 = new ScrImportFileInfo("c:\\Idontexist.blurb",
					m_mappingList, ImportDomain.Main, null, 0, false);

				m_resolver.ExpectAndReturn("ChooseFileToRemove", f1, f2, f1);

				m_fileList.Add(f1);
				m_fileList.Add(f2);
				m_fileList.Add(f3);
				m_fileList.Add(f4);

				Assert.AreEqual(3, m_fileList.Count);
				Assert.AreEqual(f2, m_fileList[0]);
				Assert.AreEqual(f3, m_fileList[1]);
				Assert.AreEqual(f4, m_fileList[2]);
			}
			m_resolver.Verify();
			Assert.AreEqual(m_expectedRemovedFiles.Count, m_callCountForVerifyFileRemoved);
		}
Exemplo n.º 15
0
		public void IgnoreDeletedDataFile()
		{
			CheckDisposed();

			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string sFilename = fileMaker.CreateFile("GEN",
					new string[] {@"\mt Genesis", @"\c 1", @"\v 1 My verse"}, Encoding.UTF8, true);
				m_settings.AddFile(sFilename, ImportDomain.Main, null, 0);
				sFilename = fileMaker.CreateFile("EXO",
					new string[] {@"\mt Exodus", @"\c 1", @"\v 1 Delete me!"}, Encoding.UTF8, true);
				m_settings.AddFile(sFilename, ImportDomain.Main, null, 0);
				Assert.AreEqual(2, m_settings.GetImportFiles(ImportDomain.Main).Count);
				FileInfo exodusFile = new FileInfo(sFilename);

				// now delete exodus and read the segments
				exodusFile.Delete();
				Assert.AreEqual(2, m_settings.GetImportFiles(ImportDomain.Main).Count);
				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(1, 0, 0, Paratext.ScrVers.English), new ScrReference(1, 1, 1, Paratext.ScrVers.English));

				// assume that we will not get an error reading segments.
				while (textEnum.Next() != null)
					;
			}
		}
Exemplo n.º 16
0
		public void TestCreateFileNullSILBookId()
		{
			TempSFFileMaker testFileMaker = new TempSFFileMaker();
			testFileMaker.CreateFile(null, null);
		}
Exemplo n.º 17
0
        public void TestCreateFileNullSILBookId()
        {
            TempSFFileMaker testFileMaker = new TempSFFileMaker();

            testFileMaker.CreateFile(null, null);
        }
Exemplo n.º 18
0
		public void InlineAfterLineMaker()
		{
			CheckDisposed();

			m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\it ", @"\it*", "Emphasis"));
			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string fileName = fileMaker.CreateFile("MAT",
					new string[] {	@"\mt \it Matthew\it*",
									 @"\c 1", @"\v 1"},
					Encoding.UTF8, false);
				m_settings.AddFile(fileName, ImportDomain.Main, null, 0);

				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(40, 0, 0, Paratext.ScrVers.English), new ScrReference(40, 1, 16, Paratext.ScrVers.English));

				ISCTextSegment textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 1");

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

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

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 3");
				Assert.AreEqual(@"\it*", textSeg.Marker);
				Assert.AreEqual(@" ", textSeg.Text);
			}
		}
Exemplo n.º 19
0
		public void EncodeLine_Backslashes()
		{
			byte[] line = TempSFFileMaker.EncodeLine("abc" + @"\\" + "def", Encoding.ASCII);
			Assert.AreEqual(10, line.Length);
			int i = 0;
			Assert.AreEqual('a', line[i++]);
			Assert.AreEqual('b', line[i++]);
			Assert.AreEqual('c', line[i++]);
			Assert.AreEqual('\\', line[i++]);
			Assert.AreEqual('\\', line[i++]);
			Assert.AreEqual('d', line[i++]);
			Assert.AreEqual('e', line[i++]);
			Assert.AreEqual('f', line[i++]);
			Assert.AreEqual(s_cr, line[i++]);
			Assert.AreEqual(s_lf, line[i++]);

			TempSFFileMaker testFileMaker = new TempSFFileMaker();
			string filename = testFileMaker.CreateFile("EPH", new[] { @"\v 1 c:\abc\def" }, Encoding.UTF8, false);
			using (TextReader reader = FileUtils.OpenFileForRead(filename, Encoding.UTF8))
			{
				Assert.AreEqual(@"\id EPH", reader.ReadLine());
				Assert.AreEqual(@"\v 1 c:\abc\def", reader.ReadLine());
			}
		}
Exemplo n.º 20
0
		public void TestExcludeBeforeIDLine()
		{
			CheckDisposed();

			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string fileName = fileMaker.CreateFileNoID(
					new string[] {
									 @"\_sh",
									 @"\id EPH",
									 @"\mt Ephesians",
									 @"\c 1",
									 @"\v 1 hello there"});
				m_settings.AddFile(fileName, ImportDomain.Main, null, 0);

				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(49, 0, 0, Paratext.ScrVers.English), new ScrReference(49, 1, 1, Paratext.ScrVers.English));

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

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg);
				Assert.AreEqual(@"\mt", textSeg.Marker);
				Assert.AreEqual(49001000, textSeg.FirstReference.BBCCCVVV);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg);
				Assert.AreEqual(@"\c", textSeg.Marker);
				Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg);
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV);
				Assert.AreEqual(" hello there ", textSeg.Text);

				Assert.IsNull(textEnum.Next());
			}
		}
Exemplo n.º 21
0
		public void SOMustSupportTextAfterVerseAndChapterNum()
		{
			CheckDisposed();

			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string fileName = fileMaker.CreateFile("MAT",
					new string[] {	@"\mt Matthew",
									 @"\c 1 First Chapter",
									 @"\v 1. Verse text",
									 @"\v 2-3aForgot space!",
									 // added 8/6
									 @"\v 2-3ab.Missing Space",
									 @"\v 2-3.abMissing Space",
									 @"\v 2-3a.bMissing Space",
									 @"\v 2-3.a.b.Missing Space",
									 @"\v 5-blah",
									 @"\v 6- blah",
									 @"\v 7.a,8.a,9a. testing",
									 "\\v 8\u200f-\u200f9 Text with RTL",
									 "\\v 10\u201011 Text with unicode hyphen"},
					Encoding.UTF8, false);
				m_settings.AddFile(fileName, ImportDomain.Main, null, 0);

				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(40, 0, 0, Paratext.ScrVers.English), new ScrReference(40, 1, 16, Paratext.ScrVers.English));

				ISCTextSegment textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 1");
				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 segment 2");
				Assert.AreEqual(@"\mt", textSeg.Marker);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(0, textSeg.FirstReference.Verse);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 2");
				Assert.AreEqual(@"\c", textSeg.Marker);
				Assert.AreEqual(" First Chapter ", textSeg.Text);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(1, textSeg.FirstReference.Verse);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 3");
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(@" Verse text ", textSeg.Text);
				Assert.AreEqual(@"1.", textSeg.LiteralVerseNum);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(1, textSeg.FirstReference.Verse);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 4");
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(@"aForgot space! ", textSeg.Text);
				Assert.AreEqual(@"2-3", textSeg.LiteralVerseNum);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(2, textSeg.FirstReference.Verse);
				Assert.AreEqual(1, textSeg.LastReference.Chapter);
				Assert.AreEqual(3, textSeg.LastReference.Verse);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 5");
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(@"ab.Missing Space ", textSeg.Text);
				Assert.AreEqual(@"2-3", textSeg.LiteralVerseNum);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(2, textSeg.FirstReference.Verse);
				Assert.AreEqual(1, textSeg.LastReference.Chapter);
				Assert.AreEqual(3, textSeg.LastReference.Verse);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 6");
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(@"abMissing Space ", textSeg.Text);
				Assert.AreEqual(@"2-3.", textSeg.LiteralVerseNum);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(2, textSeg.FirstReference.Verse);
				Assert.AreEqual(1, textSeg.LastReference.Chapter);
				Assert.AreEqual(3, textSeg.LastReference.Verse);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 7");
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(@"bMissing Space ", textSeg.Text);
				Assert.AreEqual(@"2-3a.", textSeg.LiteralVerseNum);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(2, textSeg.FirstReference.Verse);
				Assert.AreEqual(1, textSeg.LastReference.Chapter);
				Assert.AreEqual(3, textSeg.LastReference.Verse);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 8");
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(@"a.b.Missing Space ", textSeg.Text);
				Assert.AreEqual(@"2-3.", textSeg.LiteralVerseNum);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(2, textSeg.FirstReference.Verse);
				Assert.AreEqual(1, textSeg.LastReference.Chapter);
				Assert.AreEqual(3, textSeg.LastReference.Verse);
				// lower 3 bits represent the versification
				Assert.AreEqual(0, textSeg.LastReference.Segment);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 9");
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(@"-blah ", textSeg.Text);
				Assert.AreEqual(@"5", textSeg.LiteralVerseNum);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(5, textSeg.FirstReference.Verse);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 10");
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(@" blah ", textSeg.Text);
				Assert.AreEqual(@"6-", textSeg.LiteralVerseNum);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(6, textSeg.FirstReference.Verse);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 11");
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(@"a,8.a,9a. testing ", textSeg.Text);
				Assert.AreEqual(@"7.", textSeg.LiteralVerseNum);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(7, textSeg.FirstReference.Verse);
				Assert.AreEqual(1, textSeg.LastReference.Chapter);
				Assert.AreEqual(7, textSeg.LastReference.Verse);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 12");
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(" Text with RTL ", textSeg.Text);
				Assert.AreEqual("8\u200f-\u200f9", textSeg.LiteralVerseNum);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(8, textSeg.FirstReference.Verse);
				Assert.AreEqual(1, textSeg.LastReference.Chapter);
				Assert.AreEqual(9, textSeg.LastReference.Verse);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 13");
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(" Text with unicode hyphen ", textSeg.Text);
				Assert.AreEqual("10\u201011", textSeg.LiteralVerseNum);
				Assert.AreEqual(1, textSeg.FirstReference.Chapter);
				Assert.AreEqual(10, textSeg.FirstReference.Verse);
				Assert.AreEqual(1, textSeg.LastReference.Chapter);
				Assert.AreEqual(11, textSeg.LastReference.Verse);
			}
		}
Exemplo n.º 22
0
		public void TestExcludeByRange()
		{
			CheckDisposed();

			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string fileName = fileMaker.CreateFile("EPH",
					new string[] {@"\mt Ephesians",
									 @"\c 1",
									 @"\v 1 hello there",
									 @"\id PHP",
									 @"\c 1",
									 @"\v 1 verse 1 of phillipians",
									 @"\v 2 here is verse 2",
									 @"\id COL",
									 @"\c 1",
									 @"\v 1 colossians start",
									 @"\v 2 more stuff"});
				m_settings.AddFile(fileName, ImportDomain.Main, null, 0);

				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(50, 0, 0, Paratext.ScrVers.English), new ScrReference(50, 1, 1, Paratext.ScrVers.English));

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

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg);
				Assert.AreEqual(@"\c", textSeg.Marker);
				Assert.AreEqual(50001001, textSeg.FirstReference.BBCCCVVV);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg);
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(50001001, textSeg.FirstReference.BBCCCVVV);
				Assert.AreEqual(" verse 1 of phillipians ", textSeg.Text);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg);
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(50001002, textSeg.FirstReference.BBCCCVVV);
				Assert.AreEqual(" here is verse 2 ", textSeg.Text);

				Assert.IsNull(textEnum.Next());
			}
		}
Exemplo n.º 23
0
		public void TestInlineVerseNumberAfterParaMarker()
		{
			CheckDisposed();

			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string fileName = fileMaker.CreateFileNoID(
					new string[] {
									 @"\id EPH",
									 @"\mt Ephesians",
									 @"\c 1",
									 @"\p \v 1 hello there"});
				// The import type for Individual Paratext 6 files is Paratext 5.
				m_settings.ImportTypeEnum = TypeOfImport.Paratext5;
				m_settings.AddFile(fileName, ImportDomain.Main, null, 0);

				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(49, 0, 0, Paratext.ScrVers.English), new ScrReference(49, 1, 1, Paratext.ScrVers.English));

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

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg);
				Assert.AreEqual(@"\mt", textSeg.Marker);
				Assert.AreEqual("Ephesians ", textSeg.Text);
				Assert.AreEqual(49001000, textSeg.FirstReference.BBCCCVVV);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg);
				Assert.AreEqual(@"\c", textSeg.Marker);
				Assert.AreEqual(" ", textSeg.Text);
				Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg);
				Assert.AreEqual(@"\p", textSeg.Marker);
				Assert.AreEqual(string.Empty, textSeg.Text);
				Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg);
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(49001001, textSeg.FirstReference.BBCCCVVV);
				Assert.AreEqual(" hello there ", textSeg.Text);

				Assert.IsNull(textEnum.Next());
			}
		}
Exemplo n.º 24
0
		public void FigureEntries_good_WithEndMarker()
		{
			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				// Note that ending \fig* is optional even if it is in mapping.
				string sFilename = fileMaker.CreateFile("ROM",
					new string[] {	 @"\mt Romans",
									 @"\c 1",
									 @"\v 1 Hello",
									 @"\fig stuff1|stuff2|stuff3|stuff4|stuff5|stuff6\fig* etc.",
									 @"\fig stuff1|stuff2|stuff3|stuff4|stuff5|stuff6"},
					Encoding.UTF8, false);

				m_mappingList.Add(new ImportMappingInfo(@"\fig", @"\fig*", false,
					MappingTargetType.Figure, MarkerDomain.Default, null, null));

				ScrImportFileInfo fileInfo = new ScrImportFileInfo(sFilename, m_mappingList,
					ImportDomain.Main, null, 0, true);
				// Use strict checking to make sure no error occurs.
				fileInfo.PerformStrictScan();
			}
		}
Exemplo n.º 25
0
		public void TestSfBackToBackInlineMarkers()
		{
			CheckDisposed();

			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string filename = fileMaker.CreateFile("EPH",
					new string[] {@"\c 1", @"\v 1 This |iis|r |ua|r nice test."});
				m_settings.AddFile(filename, ImportDomain.Main, null, 0);
				Assert.AreEqual(3, m_settings.GetMappingListForDomain(ImportDomain.Main).Count);
				m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo("|i", "|r", "Emphasis"));
				m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo("|u", "|r", "Key Word"));
				Assert.AreEqual(5, m_settings.GetMappingListForDomain(ImportDomain.Main).Count);

				ImportMappingInfo mapping = m_settings.MappingForMarker(@"|i", MappingSet.Main);
				Assert.AreEqual(@"|i", mapping.BeginMarker);
				Assert.AreEqual(@"|r", mapping.EndMarker);
				Assert.AreEqual(true, mapping.IsInline);

				mapping = m_settings.MappingForMarker(@"|u", MappingSet.Main);
				Assert.AreEqual(@"|u", mapping.BeginMarker);
				Assert.AreEqual(@"|r", mapping.EndMarker);
				Assert.AreEqual(true, mapping.IsInline);

				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(49, 0, 0, Paratext.ScrVers.English), new ScrReference(49, 1, 1, Paratext.ScrVers.English) );

				ISCTextSegment textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 1");
				Assert.AreEqual(@"\id", textSeg.Marker);
				Assert.AreEqual("EPH ", textSeg.Text);

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

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

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 4");
				Assert.AreEqual("|i", textSeg.Marker);
				Assert.AreEqual("is", textSeg.Text);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 5");
				Assert.AreEqual("|r", textSeg.Marker);
				Assert.AreEqual(" ", textSeg.Text);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 6");
				Assert.AreEqual("|u", textSeg.Marker);
				Assert.AreEqual("a", textSeg.Text);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment 7");
				Assert.AreEqual("|r", textSeg.Marker);
				Assert.AreEqual(" nice test. ", textSeg.Text);
			}
		}
Exemplo n.º 26
0
		public void DataFileInvalid_NonExcludedMarkersBeforeIdLine()
		{
			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string sFilename = fileMaker.CreateFileNoID(
					new string[] {@"\rem Ignore",
									 @"\mt Genesis",
									 @"\id GEN",
									 @"\c 1",
									 @"\v 1 Valid"});

				// Try it first without strict checking to make sure it does not throw an exception
				ScrImportFileInfo fileInfo = new ScrImportFileInfo(sFilename, m_mappingList, ImportDomain.Main, null, 0);

				// Now use strict checking to make sure the error occurs.
				try
				{
					fileInfo.PerformStrictScan();
					Assert.Fail("Failed to throw an exception.");
				}
				catch (ScriptureUtilsException e)
				{
					Assert.AreEqual(SUE_ErrorCode.UnexcludedDataBeforeIdLine, e.ErrorCode);
				}
			}
		}
Exemplo n.º 27
0
		public void OverlapWhenOneFileContainsSubset()
		{
			using (TempSFFileMaker filemaker = new TempSFFileMaker())
			{
				string fileName1 = filemaker.CreateFile("MAT", new string[] {@"\c 3",  @"\c 4", @"\c 5", @"\c 6"});
				ScrImportFileInfo map1 = new ScrImportFileInfo(fileName1, m_mappingList,
					ImportDomain.Main, null, 0);

				string fileName2 = filemaker.CreateFile("MAT", new string[] {@"\c 4", @"\c 5"});
				ScrImportFileInfo map2 = new ScrImportFileInfo(fileName2, m_mappingList,
					ImportDomain.Main, null, 0);

				Assert.IsTrue(ScrImportFileInfo.CheckForOverlap(map1, map2));
				Assert.IsTrue(ScrImportFileInfo.CheckForOverlap(map2, map1));
			}
		}
Exemplo n.º 28
0
		public void FigureEntries_excluded()
		{
			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string sFilename = fileMaker.CreateFile("ROM",
					new string[] {	 @"\mt Romans",
									 @"\c 1",
									 @"\v 1 Hello",
									 @"\fig stuff1|stuff2|stuff3|stuff4|stuff5"},
					Encoding.UTF8, false);

				m_mappingList.Add(new ImportMappingInfo(@"\fig", null, true, MappingTargetType.Figure, MarkerDomain.Default, null, null));

				new ScrImportFileInfo(sFilename, m_mappingList, ImportDomain.Main, null, 0, true);
			}
		}
Exemplo n.º 29
0
		public void FigureEntries_bad_tooFewTokens()
		{
			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string sFilename = fileMaker.CreateFile("ROM",
					new string[] {	 @"\mt Romans",
									 @"\c 1",
									 @"\v 1 Hello",
									 @"\fig stuff1|stuff2|stuff3|stuff4|stuff5"},
					Encoding.UTF8, false);

				m_mappingList.Add(new ImportMappingInfo(@"\fig", null, false, MappingTargetType.Figure, MarkerDomain.Default, null, null));

				// Try it first without strict checking to make sure it does not throw an exception
				ScrImportFileInfo fileInfo = new ScrImportFileInfo(sFilename, m_mappingList, ImportDomain.Main, null, 0);

				try
				{
					// Use strict checking to make sure the error occurs.
					fileInfo.PerformStrictScan();
				}
				catch (ScriptureUtilsException e)
				{
					Assert.AreEqual(SUE_ErrorCode.BadFigure, e.ErrorCode);
					return;
				}
				Assert.Fail("The expected exception did not happen");
			}
		}
Exemplo n.º 30
0
		public void DeletedDataFile()
		{
			CheckDisposed();

			string sFilename = null;
			try
			{
				using (TempSFFileMaker fileMaker = new TempSFFileMaker())
				{
					sFilename = fileMaker.CreateFile("GEN",
						new string[] {@"\mt Genesis", @"\c 1", @"\v 1 My verse"});
					m_settings.AddFile(sFilename, ImportDomain.Main, null, 0);
					FileInfo file = new FileInfo(sFilename);
					ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
						new ScrReference(1, 0, 0, Paratext.ScrVers.English), new ScrReference(1, 1, 1, Paratext.ScrVers.English));
					file.Delete();

					// calling Next will cause the file to be read
					textEnum.Next();
				}
			}
			catch (ScriptureUtilsException e)
			{
				Assert.AreEqual(e.ErrorCode, SUE_ErrorCode.FileError);
				return;	// correct error
			}
			Assert.Fail("The deleted data file was not detected.");
		}
Exemplo n.º 31
0
		public void FigureEntries_good_SplitAcrossLine_LineWithMarkerFollowing()
		{
			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string sFilename = fileMaker.CreateFile("ROM",
					new string[] {@"\mt Romans",
						@"\c 1",
						@"\v 1 Hello",
						@"\fig stuff1|stuff2|stuff3|stuff that",
						@"is for 4|stuff5|stuff6",
						@"\v 2 This is Paul."},
					Encoding.UTF8, false);

				m_mappingList.Add(new ImportMappingInfo(@"\fig", null, false, MappingTargetType.Figure, MarkerDomain.Default, null, null));

				ScrImportFileInfo fileInfo = new ScrImportFileInfo(sFilename, m_mappingList,
					ImportDomain.Main, null, 0, true);
				// Use strict checking to make sure no error occurs.
				fileInfo.PerformStrictScan();
			}
		}
Exemplo n.º 32
0
		public void NoRelevantData()
		{
			CheckDisposed();

			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string sFilename = fileMaker.CreateFile("GEN", new string[] {@"\mt Genesis",
																				@"\c 1", @"\v 1 My verse"});
				m_settings.AddFile(sFilename, ImportDomain.Main, null, 0);
				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(2, 0, 0, Paratext.ScrVers.English), new ScrReference(2, 1, 1, Paratext.ScrVers.English));

				Assert.IsNull(textEnum.Next(), "Should be no segments to read");
			}
		}
Exemplo n.º 33
0
		public void NoOverlapInOneBook()
		{
			using (TempSFFileMaker filemaker = new TempSFFileMaker())
			{
				string fileName1 = filemaker.CreateFile("MAT", new string[] {@"\c 1", @"\c 2", @"\c 3", @"\c 4"});
				ScrImportFileInfo map1 = new ScrImportFileInfo(fileName1, m_mappingList,
					ImportDomain.Main, null, 0);

				string fileName2 = filemaker.CreateFile("MAT", new string[] {@"\c 5", @"\c 6", @"\c 8", @"\c 18"});
				ScrImportFileInfo map2 = new ScrImportFileInfo(fileName2, m_mappingList,
					ImportDomain.Main, null, 0);

				Assert.IsFalse(ScrImportFileInfo.CheckForOverlap(map1, map2));
				Assert.IsFalse(ScrImportFileInfo.CheckForOverlap(map2, map1));
			}
		}
Exemplo n.º 34
0
		public void LineNumbers()
		{
			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string sFilename = fileMaker.CreateFile("GEN", new string[] { @"\c 1", @"\v 1",
					@"\vt First line", @"second line", @"third line", @"\vt next marker" });
				m_settings.AddFile(sFilename, ImportDomain.Main, null, 0);
				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(1, 0, 0, Paratext.ScrVers.English), new ScrReference(1, 1, 1, Paratext.ScrVers.English));

				ISCTextSegment text = textEnum.Next(); // id line
				text = textEnum.Next();	// Chapter one
				text = textEnum.Next(); // Verse one
				text = textEnum.Next(); // First to third line
				text = textEnum.Next();	// next marker

				Assert.AreEqual(7, text.CurrentLineNumber);
			}
		}
Exemplo n.º 35
0
		public void OverlapInTwoMaps()
		{
			using (TempSFFileMaker filemaker = new TempSFFileMaker())
			{
				string fileName1 = filemaker.CreateFile("MAT", new string[] {@"\c 1", @"\c 2", @"\c 3",
																			@"\id MRK", @"\c 1", @"\c 2", @"\c 3"});
				ScrImportFileInfo map1 = new ScrImportFileInfo(fileName1, m_mappingList,
					ImportDomain.Main, null, 0);

				string fileName2 = filemaker.CreateFile("MRK", new string[] {@"\c 3",
																				@"\id LUK", @"\c 1", @"\c 2", @"\c 3"});
				ScrImportFileInfo map2 = new ScrImportFileInfo(fileName2, m_mappingList,
					ImportDomain.Main, null, 0);

				Assert.IsTrue(ScrImportFileInfo.CheckForOverlap(map1, map2));
				Assert.IsTrue(ScrImportFileInfo.CheckForOverlap(map2, map1));
			}
		}
Exemplo n.º 36
0
		public void IgnoreBackslashesInDataForOther()
		{
			CheckDisposed();

			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string fileName = fileMaker.CreateFile("EPH",
					new string[] {@"\mt \it fun \it* Mi\\abi \taki", @"\c 1", @"\v 1"});
				m_settings.AddFile(fileName, ImportDomain.Main, null, 0);

				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(49, 0, 0, Paratext.ScrVers.English), new ScrReference(49, 1, 1, Paratext.ScrVers.English));

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

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read second segment");
				Assert.AreEqual(@"\mt", textSeg.Marker);
				Assert.AreEqual(@"\it fun \it* Mi\\abi \taki ", textSeg.Text);
			}
		}
Exemplo n.º 37
0
		public void DataFileInvalid_InvalidBook()
		{
			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string sFilename = fileMaker.CreateFileNoID(
					new string[] {@"\id Hmmm",
									 @"\mt Genesis",
									 @"\id GEN",
									 @"\c 1",
									 @"\v 1 Valid"});

				try
				{
					new ScrImportFileInfo(sFilename, m_mappingList, ImportDomain.Main, null, 0, true);
					Assert.Fail("Failed to throw an exception.");
				}
				catch (ScriptureUtilsException e)
				{
					Assert.AreEqual(SUE_ErrorCode.InvalidBookID, e.ErrorCode);
				}
				catch
				{
					Assert.Fail("Wrong exception detected.");
				}
			}
		}
Exemplo n.º 38
0
		public void TreatBackslashesInDataAsInlineMarkersForP5()
		{
			CheckDisposed();

			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string fileName = fileMaker.CreateFile("EPH",
					new string[] {@"\mt \it fun\it* Mi\\abi \taki", @"\c 1", @"\v 1"});
				m_settings.AddFile(fileName, ImportDomain.Main, null, 0);
				m_settings.ImportTypeEnum = TypeOfImport.Paratext5;

				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(49, 0, 0, Paratext.ScrVers.English), new ScrReference(49, 1, 1, Paratext.ScrVers.English));

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

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

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

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

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

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, @"Unable to read \taki segment");
				Assert.AreEqual(@"\taki", textSeg.Marker);
				Assert.AreEqual(@" ", textSeg.Text);
			}
		}
Exemplo n.º 39
0
		public void TwoFigureEntries_good_NotScanningInline()
		{
			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				// Note that ending \fig* is optional even if it is in mapping.
				string sFilename = fileMaker.CreateFile("ROM",
					new string[] {	 @"\c 1",
									 @"\v 1 Hello",
									 @"\fig stuff1|stuff2|stuff3|stuff4|stuff5|stuff6\fig*",
									 @"\new will I be seen?",
									 @"\v 2 I'm a verse, too.",
									 @"\btfig stuff1|stuff2|stuff3|stuff4|stuff5|stuff6\btfig*"},
					Encoding.UTF8, false);

				m_mappingList.Add(new ImportMappingInfo(@"\fig", @"\fig*", false,
					MappingTargetType.Figure, MarkerDomain.Default, null, null));

				ScrImportFileInfo fileInfo = new ScrImportFileInfo(sFilename, m_mappingList,
					ImportDomain.Main, null, 0, false);

				m_mappingList.Delete(m_mappingList[@"\new"]);
				Assert.IsNull(m_mappingList[@"\new"]);

				// Use strict checking to make sure no error occurs.
				fileInfo.PerformStrictScan();

				Assert.IsNotNull(m_mappingList[@"\new"]);
			}
		}
Exemplo n.º 40
0
		public void HandleP5InlineMarkerWithNoExplicitEndMarker()
		{
			CheckDisposed();

			using (TempSFFileMaker fileMaker = new TempSFFileMaker())
			{
				string fileName = fileMaker.CreateFile("EPH",
					new string[] {@"\mt fun \f + \ft footnote \f*", @"\c 1", @"\v 1"});
				m_settings.ImportTypeEnum = TypeOfImport.Paratext5;
				m_settings.AddFile(fileName, ImportDomain.Main, null, 0);

				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(49, 0, 0, Paratext.ScrVers.English), new ScrReference(49, 1, 1, Paratext.ScrVers.English));

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

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

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

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

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