Beispiel #1
0
        public override void TestSetup()
        {
            base.TestSetup();

            m_mockFileOs = new MockFileOS();
            FileUtils.Manager.SetFileAdapter(m_mockFileOs);
            string fileGen = m_mockFileOs.MakeSfFile("GEN", @"\c 1");
            string fileRev = m_mockFileOs.MakeSfFile("REV", @"\c 1");

            m_settings = m_scr.FindOrCreateDefaultImportSettings(TypeOfImport.Other);
            m_settings.AddFile(fileGen, ImportDomain.Main, null, null);
            m_settings.AddFile(fileRev, ImportDomain.Main, null, null);
            m_dlg = new DummyImportDialog(null, Cache, m_settings);
        }
        public void LoadParatext5Project()
        {
            using (ScrObjWrapper wrapper = new ScrObjWrapper())
            {
                IScrImportSet settings = m_scr.FindOrCreateDefaultImportSettings(TypeOfImport.Paratext5);
                settings.StartRef = new BCVRef(1, 1, 1);
                settings.EndRef   = new BCVRef(66, 22, 21);
                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, null);

                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.LinkedFilesRootDir, wrapper.ExternalPictureFolders[0]);
                Assert.AreEqual(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
                                wrapper.ExternalPictureFolders[1]);
            }
        }
Beispiel #3
0
        public void AddFileAndCheckAccessibility_Locked()
        {
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            Cache.LanguageProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings);
            importSettings.ImportTypeEnum = TypeOfImport.Other;

            var fileOs = new MockFileOS();

            try
            {
                FileUtils.Manager.SetFileAdapter(fileOs);
                string filename = fileOs.MakeSfFile("EPH", @"\c 1", @"\v 1");
                fileOs.LockFile(filename);

                IScrImportFileInfo info = importSettings.AddFile(filename, ImportDomain.Main, null, null);
                Assert.AreEqual(Encoding.ASCII, info.FileEncoding);
                Assert.AreEqual(1, importSettings.GetImportFiles(ImportDomain.Main).Count);
                StringCollection notFound;
                Assert.IsFalse(importSettings.ImportProjectIsAccessible(out notFound));
                Assert.AreEqual(1, notFound.Count);
                Assert.AreEqual(filename, notFound[0]);
            }
            finally
            {
                FileUtils.Manager.Reset();
            }
        }
Beispiel #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Populate settings as if user had used the Import Wizard to choose a SF project
		/// and set up mappings appropriate for TOB data files.
		/// </summary>
		/// <param name="settings">The settings object to be populated</param>
		/// ------------------------------------------------------------------------------------
		static public void MakeSFImportTestSettings(IScrImportSet settings)
		{
			settings.ImportTypeEnum = TypeOfImport.Other;

			// add a bogus file to the project
			settings.AddFile(DriveUtil.BootDrive + @"IDontExist.txt", ImportDomain.Main, null, null);

			// Set up the mappings
			SetUpMappings(settings);
		}
		public override void TestSetup()
		{
			base.TestSetup();

			m_mockFileOs = new MockFileOS();
			FileUtils.Manager.SetFileAdapter(m_mockFileOs);
			string fileGen = m_mockFileOs.MakeSfFile("GEN", @"\c 1");
			string fileRev = m_mockFileOs.MakeSfFile("REV", @"\c 1");
			m_settings = m_scr.FindOrCreateDefaultImportSettings(TypeOfImport.Other);
			m_settings.AddFile(fileGen, ImportDomain.Main, null, null);
			m_settings.AddFile(fileRev, ImportDomain.Main, null, null);
			m_dlg = new DummyImportDialog(null, Cache, m_settings);
		}
Beispiel #6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Test to see if the ImportProjectIsAccessible method works for projects other than
        /// Paratext 6.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void ImportProjectIsAccessible_helper(IScrImportSet importSettings)
        {
            var fileOs = new MockFileOS();

            try
            {
                FileUtils.Manager.SetFileAdapter(fileOs);
                string scrFile1       = fileOs.MakeSfFile("GEN", @"\p", @"\c 1", @"\v 1", @"\v 2");
                string scrFile2       = fileOs.MakeSfFile("EXO", @"\p", @"\c 1", @"\v 1", @"\v 2");
                string scrFile3       = fileOs.MakeSfFile("LEV", @"\p", @"\c 1", @"\v 1", @"\v 2");
                string btFileDef      = fileOs.MakeSfFile("GEN", @"\p", @"\c 3", @"\v 1");
                string btFileSpan     = fileOs.MakeSfFile("GEN", @"\p", @"\c 3", @"\v 1");
                string annotFileCons  = fileOs.MakeSfFile("GEN", @"\p", @"\c 3", @"\v 1");
                string annotFileTrans = fileOs.MakeSfFile("GEN", @"\p", @"\c 3", @"\v 1");

                importSettings.AddFile(scrFile1, ImportDomain.Main, null, null);
                importSettings.AddFile(scrFile2, ImportDomain.Main, null, null);
                importSettings.AddFile(scrFile3, ImportDomain.Main, null, null);
                importSettings.AddFile(btFileDef, ImportDomain.BackTrans, null, null);
                importSettings.AddFile(btFileSpan, ImportDomain.BackTrans, "es", null);
                var annDefnRepo = Cache.ServiceLocator.GetInstance <ICmAnnotationDefnRepository>();
                importSettings.AddFile(annotFileCons, ImportDomain.Annotations, null,
                                       annDefnRepo.ConsultantAnnotationDefn);
                importSettings.AddFile(annotFileTrans, ImportDomain.Annotations, null,
                                       annDefnRepo.TranslatorAnnotationDefn);

                StringCollection filesNotFound;
                Assert.IsTrue(importSettings.ImportProjectIsAccessible(out filesNotFound));
                Assert.AreEqual(0, filesNotFound.Count);
                importSettings.SaveSettings();

                // Blow away some project files: should still return true, but should
                // report missing files.
                FileUtils.Delete(scrFile2);
                FileUtils.Delete(scrFile3);
                FileUtils.Delete(btFileDef);
                FileUtils.Delete(annotFileCons);
                FileUtils.Delete(annotFileTrans);

                // Now that we've saved the settings, we'll "revert" in order to re-load from the DB
                importSettings.RevertToSaved();

                Assert.IsTrue(importSettings.ImportProjectIsAccessible(out filesNotFound));
                Assert.AreEqual(5, filesNotFound.Count);

                Assert.IsTrue(filesNotFound.Contains(scrFile2));
                Assert.IsTrue(filesNotFound.Contains(scrFile3));
                Assert.IsTrue(filesNotFound.Contains(btFileDef));
                Assert.IsTrue(filesNotFound.Contains(annotFileCons));
                Assert.IsTrue(filesNotFound.Contains(annotFileTrans));

                importSettings.SaveSettings();

                // Blow away the rest of the project files: should return false and report
                // missing files.
                FileUtils.Delete(scrFile1);
                FileUtils.Delete(btFileSpan);

                // Now that we've saved the settings, we'll "revert" in order to re-load from the DB
                importSettings.RevertToSaved();

                Assert.IsFalse(importSettings.ImportProjectIsAccessible(out filesNotFound));
                Assert.AreEqual(7, filesNotFound.Count);

                Assert.IsTrue(filesNotFound.Contains(scrFile1));
                Assert.IsTrue(filesNotFound.Contains(scrFile2));
                Assert.IsTrue(filesNotFound.Contains(scrFile3));
                Assert.IsTrue(filesNotFound.Contains(btFileDef));
                Assert.IsTrue(filesNotFound.Contains(btFileSpan));
                Assert.IsTrue(filesNotFound.Contains(annotFileCons));
                Assert.IsTrue(filesNotFound.Contains(annotFileTrans));
            }
            finally
            {
                FileUtils.Manager.Reset();
            }
        }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds a list files for import settings.
		/// </summary>
		/// <param name="settings">The settings.</param>
		/// <param name="domain">The import domain.</param>
		/// <param name="strFileName">Name of the file.</param>
		/// <param name="numFiles">The number of files to add to the import list. Sequential
		/// numbers will be added to each file.</param>
		/// ------------------------------------------------------------------------------------
		private void AddImportFiles(IScrImportSet settings, ImportDomain domain, string strFileName,
			int numFiles)
		{
			for (int iFile = 0; iFile < numFiles; iFile++)
				settings.AddFile(@"c:\" + strFileName + (iFile + 1), domain, null, null);
		}
Beispiel #8
0
        /// ------------------------------------------------------------------------------------
        /// Populate m_settings as if user had used the Import Wizard to choose a SF project
        /// and set up mappings appropriate for TOB data files.
        /// </summary>
        /// <param name="settings">Import settings</param>
        /// ------------------------------------------------------------------------------------
        public static void MakeSFImportTestSettings(IScrImportSet settings)
        {
            settings.ImportTypeEnum = TypeOfImport.Other;

            // add TOB files to the project
            settings.AddFile(DriveUtil.BootDrive + @"sf_scr~files2003.~TOB~\32JON.sfm", ImportDomain.Main, null, null);
            settings.AddFile(DriveUtil.BootDrive + @"sf_scr~files2003.~TOB~\123JN.sfm", ImportDomain.Main, null, null);
            // add TEV Philemon file to the project
            settings.AddFile(DriveUtil.BootDrive + @"~IWTEST~\TEV\58Phm.tev", ImportDomain.Main, null, null);

            // Set up the mappings
            DummyTeImporter.SetUpMappings(settings);
        }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Test to see if the ImportProjectIsAccessible method works for projects other than
		/// Paratext 6.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void ImportProjectIsAccessible_helper(IScrImportSet importSettings)
		{
			var fileOs = new MockFileOS();
			try
			{
				FileUtils.Manager.SetFileAdapter(fileOs);
				string scrFile1 = fileOs.MakeSfFile("GEN", @"\p", @"\c 1", @"\v 1", @"\v 2");
				string scrFile2 = fileOs.MakeSfFile("EXO", @"\p", @"\c 1", @"\v 1", @"\v 2");
				string scrFile3 = fileOs.MakeSfFile("LEV", @"\p", @"\c 1", @"\v 1", @"\v 2");
				string btFileDef = fileOs.MakeSfFile("GEN", @"\p", @"\c 3", @"\v 1");
				string btFileSpan = fileOs.MakeSfFile("GEN", @"\p", @"\c 3", @"\v 1");
				string annotFileCons = fileOs.MakeSfFile("GEN", @"\p", @"\c 3", @"\v 1");
				string annotFileTrans = fileOs.MakeSfFile("GEN", @"\p", @"\c 3", @"\v 1");

				importSettings.AddFile(scrFile1, ImportDomain.Main, null, null);
				importSettings.AddFile(scrFile2, ImportDomain.Main, null, null);
				importSettings.AddFile(scrFile3, ImportDomain.Main, null, null);
				importSettings.AddFile(btFileDef, ImportDomain.BackTrans, null, null);
				importSettings.AddFile(btFileSpan, ImportDomain.BackTrans, "es", null);
				var annDefnRepo = Cache.ServiceLocator.GetInstance<ICmAnnotationDefnRepository>();
				importSettings.AddFile(annotFileCons, ImportDomain.Annotations, null,
					annDefnRepo.ConsultantAnnotationDefn);
				importSettings.AddFile(annotFileTrans, ImportDomain.Annotations, null,
					annDefnRepo.TranslatorAnnotationDefn);

				StringCollection filesNotFound;
				Assert.IsTrue(importSettings.ImportProjectIsAccessible(out filesNotFound));
				Assert.AreEqual(0, filesNotFound.Count);
				importSettings.SaveSettings();

				// Blow away some project files: should still return true, but should
				// report missing files.
				FileUtils.Delete(scrFile2);
				FileUtils.Delete(scrFile3);
				FileUtils.Delete(btFileDef);
				FileUtils.Delete(annotFileCons);
				FileUtils.Delete(annotFileTrans);

				// Now that we've saved the settings, we'll "revert" in order to re-load from the DB
				importSettings.RevertToSaved();

				Assert.IsTrue(importSettings.ImportProjectIsAccessible(out filesNotFound));
				Assert.AreEqual(5, filesNotFound.Count);

				Assert.IsTrue(filesNotFound.Contains(scrFile2));
				Assert.IsTrue(filesNotFound.Contains(scrFile3));
				Assert.IsTrue(filesNotFound.Contains(btFileDef));
				Assert.IsTrue(filesNotFound.Contains(annotFileCons));
				Assert.IsTrue(filesNotFound.Contains(annotFileTrans));

				importSettings.SaveSettings();

				// Blow away the rest of the project files: should return false and report
				// missing files.
				FileUtils.Delete(scrFile1);
				FileUtils.Delete(btFileSpan);

				// Now that we've saved the settings, we'll "revert" in order to re-load from the DB
				importSettings.RevertToSaved();

				Assert.IsFalse(importSettings.ImportProjectIsAccessible(out filesNotFound));
				Assert.AreEqual(7, filesNotFound.Count);

				Assert.IsTrue(filesNotFound.Contains(scrFile1));
				Assert.IsTrue(filesNotFound.Contains(scrFile2));
				Assert.IsTrue(filesNotFound.Contains(scrFile3));
				Assert.IsTrue(filesNotFound.Contains(btFileDef));
				Assert.IsTrue(filesNotFound.Contains(btFileSpan));
				Assert.IsTrue(filesNotFound.Contains(annotFileCons));
				Assert.IsTrue(filesNotFound.Contains(annotFileTrans));
			}
			finally
			{
				FileUtils.Manager.Reset();
			}
		}
        public void AddingFilesToDifferentLists()
        {
            TempSFFileMaker maker       = new TempSFFileMaker();
            string          scrFileName = maker.CreateFile("GEN", new string[] { @"\c 1", @"\v 1" });

            m_settings.AddFile(scrFileName, ImportDomain.Main, null, null);

            string enBtFileName = maker.CreateFile("GEN", new string[] { @"\c 1", @"\v 1" });
            string esBtFileName = maker.CreateFile("MAT",
                                                   new string[] { @"\c 1", @"\v 1", @"\id MRK", @"\c 1", @"\v 1" });

            m_settings.AddFile(enBtFileName, ImportDomain.BackTrans, "en", null);
            m_settings.AddFile(esBtFileName, ImportDomain.BackTrans, "es", null);

            string esTransNoteFileName = maker.CreateFile("GEN",
                                                          new string[] { @"\c 1", @"\v 1 No digan asi." });
            string enTransNoteFileName = maker.CreateFile("GEN",
                                                          new string[] { @"\c 1", @"\v 1 Try to find a better word." });
            string enConsNoteFileName1 = maker.CreateFile("GEN",
                                                          new string[] { @"\c 1", @"\v 1 Check the meaning of floobywump." });
            string enConsNoteFileName2 = maker.CreateFile("MAT",
                                                          new string[] { @"\c 1", @"\v 1", @"\id MRK", @"\c 1", @"\v 1" });
            ICmAnnotationDefn translatorNoteDef =
                Cache.ServiceLocator.GetInstance <ICmAnnotationDefnRepository>().TranslatorAnnotationDefn;
            ICmAnnotationDefn consultantNoteDef =
                Cache.ServiceLocator.GetInstance <ICmAnnotationDefnRepository>().ConsultantAnnotationDefn;

            m_settings.AddFile(esTransNoteFileName, ImportDomain.Annotations, "es",
                               translatorNoteDef);
            m_settings.AddFile(enTransNoteFileName, ImportDomain.Annotations, "en",
                               translatorNoteDef);

            m_settings.AddFile(enConsNoteFileName1, ImportDomain.Annotations, "en",
                               consultantNoteDef);
            m_settings.AddFile(enConsNoteFileName2, ImportDomain.Annotations, "en",
                               consultantNoteDef);

            m_builder.CallPopulateFileListsFromSettings();

            // Verify the Scripture file
            m_builder.SelectTab(0);
            Assert.AreEqual(1, m_builder.ScrListView.Items.Count);
            Assert.AreEqual(scrFileName, m_builder.ScrListView.Items[0].Text);

            // Verify the English BT file
            m_builder.SelectTab(1);
            m_builder.SelectBtWritingSystem("English");
            Assert.AreEqual(1, m_builder.BtListView.Items.Count);
            Assert.AreEqual(enBtFileName, m_builder.BtListView.Items[0].Text);
            Assert.AreEqual("GEN", m_builder.BtListView.Items[0].SubItems[1].Text);
//				Assert.AreEqual("English", m_builder.BtListView.Items[0].SubItems[2].Text);
            Assert.AreEqual("US-ASCII", m_builder.BtListView.Items[0].SubItems[2].Text);

            // Verify the Spanish BT file
            m_builder.SelectBtWritingSystem("Spanish");
            Assert.AreEqual(1, m_builder.BtListView.Items.Count);
            Assert.AreEqual(esBtFileName, m_builder.BtListView.Items[0].Text);
            Assert.AreEqual("MAT, MRK", m_builder.BtListView.Items[0].SubItems[1].Text);
//				Assert.AreEqual("Spanish", m_builder.BtListView.Items[0].SubItems[2].Text);
            Assert.AreEqual("US-ASCII", m_builder.BtListView.Items[0].SubItems[2].Text);

            // verify the Spanish Translator Notes file
            m_builder.SelectTab(2);
            m_builder.SelectNoteType("Translator");
            m_builder.SelectNotesWritingSystem("Spanish");
            Assert.AreEqual(1, m_builder.NotesListView.Items.Count);
            Assert.AreEqual(esTransNoteFileName, m_builder.NotesListView.Items[0].Text);
            Assert.AreEqual("GEN", m_builder.NotesListView.Items[0].SubItems[1].Text);
//				Assert.AreEqual("Spanish", m_builder.NotesListView.Items[0].SubItems[2].Text);
            Assert.AreEqual("US-ASCII", m_builder.NotesListView.Items[0].SubItems[2].Text);

            // verify the English Translator Notes file
            m_builder.SelectNotesWritingSystem("English");
            Assert.AreEqual(1, m_builder.NotesListView.Items.Count);
            Assert.AreEqual(enTransNoteFileName, m_builder.NotesListView.Items[0].Text);
            Assert.AreEqual("GEN", m_builder.NotesListView.Items[0].SubItems[1].Text);
//				Assert.AreEqual("Spanish", m_builder.NotesListView.Items[0].SubItems[2].Text);
            Assert.AreEqual("US-ASCII", m_builder.NotesListView.Items[0].SubItems[2].Text);

            // verify the English Consultant Notes files
            m_builder.SelectNoteType("Consultant");
            Assert.AreEqual(2, m_builder.NotesListView.Items.Count);
            Assert.AreEqual(enConsNoteFileName1, m_builder.NotesListView.Items[0].Text);
            Assert.AreEqual("GEN", m_builder.NotesListView.Items[0].SubItems[1].Text);
            //				Assert.AreEqual("Spanish", m_builder.NotesListView.Items[0].SubItems[2].Text);
            Assert.AreEqual("US-ASCII", m_builder.NotesListView.Items[0].SubItems[2].Text);

            Assert.AreEqual(enConsNoteFileName2, m_builder.NotesListView.Items[1].Text);
            Assert.AreEqual("MAT, MRK", m_builder.NotesListView.Items[1].SubItems[1].Text);
            //				Assert.AreEqual("Spanish", m_builder.NotesListView.Items[1].SubItems[2].Text);
            Assert.AreEqual("US-ASCII", m_builder.NotesListView.Items[1].SubItems[2].Text);
        }