public void Create_LdmlWritingSystemsFound_CopiesWritingSystems() { string ldmlText = @"<?xml version=""1.0"" encoding=""utf-8""?> <ldml> <identity> <version number="""" /> <generation date=""0001-01-01T00:00:00"" /> <language type=""test"" /> </identity> <collations /> <special xmlns:palaso=""urn://palaso.org/ldmlExtensions/v1""> <palaso:abbreviation value=""test"" /> <palaso:defaultFontFamily value=""Arial"" /> <palaso:defaultFontSize value=""12"" /> </special> </ldml>"; using (var testDir = new TemporaryFolder("NormalSituation_CreatesProject")) { var lift = new TempLiftFile(testDir, "", "0.12"); using (var ldmlFile = new TempFile(ldmlText)) { ldmlFile.MoveTo(Path.Combine(testDir.Path, "test.ldml")); var targetDir = testDir.Combine("target"); Assert.IsTrue(ProjectFromRawFLExLiftFilesCreator.Create(targetDir, lift.Path)); AssertFileExistsInTargetDir(Path.Combine(targetDir, "WritingSystems"), "test.ldml"); } } }
private void Run(string contents, string[] traitsWithMultiplicity) { contents = contents.Replace("GUID1", "guid='" + Guid.NewGuid() + "'"); contents = contents.Replace("GUID2", "guid='" + Guid.NewGuid() + "'"); contents = contents.Replace("GUID3", "guid='" + Guid.NewGuid() + "'"); contents = contents.Replace("GUID4", "guid='" + Guid.NewGuid() + "'"); using (var input = new TempLiftFile(contents, "0.13")) { using (var repo = new LiftLexEntryRepository(input.Path)) { var ws = HomographMerger.GuessPrimarLexicalFormWritingSystem(repo, _progress); HomographMerger.Merge(repo, ws, traitsWithMultiplicity, _progress); } _resultDom.Load(input.Path); //removing these tombstones simplifies our assertions, later foreach (XmlNode deletedEntry in _resultDom.SelectNodes("//entry[@dateDeleted]")) { deletedEntry.ParentNode.RemoveChild(deletedEntry); } var bakPathname = input.Path + ".bak"; if (File.Exists(bakPathname)) { File.Delete(bakPathname); } } }
public void Setup() { _repoFile = new TempLiftFile(""); _repo = new LexEntryRepository(_repoFile.Path); AddPicturesConfig config = new AddPicturesConfig(string.Format("<task taskName='AddMissingInfo' visible='true'><indexFileName>{0}</indexFileName></task>", "ArtOfReadingIndexV3_en.txt")); _task = new AddPicturesTask(config, _repo, new TaskMemoryRepository(), new FileLocator(new string[] { WeSay.Project.BasilProject.ApplicationCommonDirectory })); _task.Activate(); }
public void Activate_IndexNotFound_GivesUserMessage() { using (var repoFile = new TempLiftFile("")) { using (var repo = new LexEntryRepository(repoFile.Path)) { AddPicturesConfig config = MakeConfig("Bogus.txt"); var task = new AddPicturesTask(config, repo, new TaskMemoryRepository(), new FileLocator(new string[0])); Assert.Throws <ConfigurationException>(() => task.Activate()); } } }
public void Create_SourceLiftLocked_GivesMessageReturnsFalse() { using (var lift = new TempLiftFile("")) { using (var stream = File.OpenWrite(lift.Path)) { var targetDir = Path.Combine(Path.GetTempPath(), "ProjectFromFLExCreatorTests"); using (var x = new ErrorReport.NonFatalErrorReportExpected()) { Assert.IsFalse(ProjectFromRawFLExLiftFilesCreator.Create(targetDir, lift.Path)); } } } }
public void Create_LiftAndRangesFound_CopiesRanges() { using (var testDir = new TemporaryFolder("NormalSituation_CreatesProject")) { using (var lift = new TempLiftFile(testDir, "", "0.12")) { File.WriteAllText(lift.Path + "-ranges", "hello"); var targetDir = testDir.Combine("target"); Assert.IsTrue(ProjectFromRawFLExLiftFilesCreator.Create(targetDir, lift.Path)); var projectName = Path.GetFileNameWithoutExtension(targetDir); AssertFileExistsInTargetDir(targetDir, projectName + ".lift-ranges"); } } }
public GroupOfConflictingLiftFiles() { Folder = new TemporaryFolder("ChorusTest"); string ancestor = @"<entry id='one' guid='F169EB3D-16F2-4eb0-91AA-FDB91636F8F6'> <lexical-unit> <form lang='a'> <text>original</text> </form> </lexical-unit> </entry>" ; string bob = ancestor.Replace("original", "bob says"); string sally = ancestor.Replace("original", "sally says"); AncestorFile = new TempLiftFile("ancestor.lift", Folder, ancestor, "0.12"); BobFile = new TempLiftFile("bob.lift", Folder, bob, "0.12"); SallyFile = new TempLiftFile("sally.lift", Folder, sally, "0.12"); }
public void Create_JustLiftFound_CreatesProjectAndCopiesLIFT() { using (var testDir = new TemporaryFolder("NormalSituation_CreatesProject")) { using (var lift = new TempLiftFile(testDir, "<entry id='foo'></entry>", "0.12")) { var targetDir = testDir.Combine("target"); Assert.IsTrue(ProjectFromRawFLExLiftFilesCreator.Create(targetDir, lift.Path)); var projectName = Path.GetFileNameWithoutExtension(targetDir); Assert.IsTrue(Directory.Exists(targetDir)); var liftName = projectName + ".lift"; AssertFileExistsInTargetDir(targetDir, liftName); var liftPath = Path.Combine(targetDir, liftName); AssertThatXmlIn.File(liftPath).HasAtLeastOneMatchForXpath("//entry[@id='foo']"); } } }
private void Run(string contents, Action test) { using (var input = new TempLiftFile(contents, "0.13")) { using (var repo = new LiftLexEntryRepository(input.Path)) { EntrySplitter.Run(repo, _progress); } _resultDom.Load(input.Path); var bakPathname = input.Path + ".bak"; if (File.Exists(bakPathname)) { File.Delete(bakPathname); } } test(); }
public void BackupToExternal_FileToBackUpIsLocked_Throws() { using (var folderForBackup = new TemporaryFolder("Backup Test")) { string backUpFileName = Path.Combine(folderForBackup.Path, "Backup Test.zip"); //Create and lock a lift file var fileToBackUp = new TempLiftFile("TempLiftFile.lift", folderForBackup, "", "0.13"); //This is our lock var liftFileStreamForLocking = new FileStream( fileToBackUp.Path, FileMode.Open, FileAccess.Read, FileShare.None ); Assert.Throws <System.IO.IOException>( () => BackupMaker.BackupToExternal( Path.GetDirectoryName(fileToBackUp.Path), backUpFileName, new[] { fileToBackUp.Path } ) ); liftFileStreamForLocking.Close(); } }
private GatherWordListTask CreateAndActivateLiftTask(IEnumerable <string> definitionWritingSystems, string entriesXml) { var file = new TempLiftFile("wordlist.lift", _tempFolder, entriesXml, Palaso.Lift.Validation.Validator.LiftVersion); var vt = new ViewTemplate(); vt.Add(new Field( Field.FieldNames.EntryLexicalForm.ToString(), "LexEntry", new[] { WritingSystemsIdsForTests.VernacularIdForTest } )); vt.Add(new Field( LexSense.WellKnownProperties.Definition.ToString(), "LexSense", definitionWritingSystems )); vt.Add( new Field( LexSense.WellKnownProperties.Gloss.ToString(), "LexSense", new string[] { WritingSystemsIdsForTests.AnalysisIdForTest, "fr" } ) ); var t = new GatherWordListTask( GatherWordListConfig.CreateForTests(file.Path, "xx", _catalog), _lexEntryRepository, vt, new TaskMemoryRepository() ); t.Activate(); return(t); }
public void CreateLiftFile(string content, string version) { _liftFile = new TempLiftFile(_folder, content, version); }