public MakeSfFile ( |
||
encoding | File encoding | |
fIncludeBOM | bool | Indicates whether file contents should include the byte /// order mark |
sBookId | string | The book id (if set, this will cause \id line to be written /// as the first line of the fiel) |
return | string |
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(); } }
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); }
/// ------------------------------------------------------------------------------------ /// <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(); } }