public TestEnvironment() { _temporaryFolder = new TemporaryFolder("LiftLexEntryRepositoryTests"); string filePath = _temporaryFolder.GetTemporaryFile(); _repository = new LiftLexEntryRepository(filePath); _headwordWritingSystem = new WritingSystemDefinition("th") {DefaultCollation = new IcuRulesCollationDefinition("standard")}; }
public void SettingsFolderWithNewerConfig_SortsBeforeOneWithOlderConfig() { using (var tempFolder = new TemporaryFolder()) { var firstDirPath = Path.Combine(tempFolder.Path, "first"); var secondDirPath = Path.Combine(tempFolder.Path, "second"); var firstConfigFile = Path.Combine(firstDirPath, TestCrossPlatformSettingsProvider.UserConfigFileName); var secondConfigFile = Path.Combine(secondDirPath, TestCrossPlatformSettingsProvider.UserConfigFileName); Directory.CreateDirectory(firstDirPath); Directory.CreateDirectory(secondDirPath); File.WriteAllText(firstConfigFile, @"nonsense"); Thread.Sleep(1000); // May help ensure write times are sufficiently different on TeamCity. File.WriteAllText(secondConfigFile, @"nonsense"); // second is newer var result = TestCrossPlatformSettingsProvider.VersionDirectoryComparison(firstDirPath, secondDirPath); Assert.That(result, Is.GreaterThan(0)); Thread.Sleep(1000); // May help ensure write times are sufficiently different on TeamCity. File.WriteAllText(firstConfigFile, @"nonsense"); // now first is newer result = TestCrossPlatformSettingsProvider.VersionDirectoryComparison(firstDirPath, secondDirPath); Assert.That(result, Is.LessThan(0)); // A final check to make sure it is really working the way we want var list = new List<string>(); list.Add(secondDirPath); list.Add(firstDirPath); list.Sort(TestCrossPlatformSettingsProvider.VersionDirectoryComparison); Assert.That(list[0], Is.EqualTo(firstDirPath)); } }
public HgTestSetup() { _progress = new ConsoleProgress(); Root = new TemporaryFolder("ChorusHgWrappingTest"); HgRepository.CreateRepositoryInExistingDir(Root.Path,_progress); Repository = new HgRepository(Root.Path, new NullProgress()); }
public TestEnvironment(string rfctag, string rfctag2) { _folder = new TemporaryFolder("WritingSystemsInoptionListFileHelper"); var pathtoOptionsListFile1 = Path.Combine(_folder.Path, "test1.xml"); _optionListFile = new IO.TempFile(String.Format(_optionListFileContent, rfctag, rfctag2)); _optionListFile.MoveTo(pathtoOptionsListFile1); }
public void SettingsFolderWithNoConfig_SortsAfterOneWithConfig() { // We do two iterations like this to vary whether the (originally) first or last directory lacks // the config file. (We can't achieve this reliably by deleting the file because it sometimes // takes the system some time to notice that it is gone.) for (var which = 0; which < 1; which++) { using (var tempFolder = new TemporaryFolder()) { var firstDirPath = Path.Combine(tempFolder.Path, "first"); var secondDirPath = Path.Combine(tempFolder.Path, "second"); var firstConfigFile = Path.Combine(firstDirPath, TestCrossPlatformSettingsProvider.UserConfigFileName); var secondConfigFile = Path.Combine(firstDirPath, TestCrossPlatformSettingsProvider.UserConfigFileName); Directory.CreateDirectory(firstDirPath); Directory.CreateDirectory(secondDirPath); if (which == 0) File.WriteAllText(firstConfigFile, @"nonsense"); else File.WriteAllText(secondConfigFile, @"nonsense"); var list = new List<string>(); list.Add(secondDirPath); list.Add(firstDirPath); list.Sort(TestCrossPlatformSettingsProvider.VersionDirectoryComparison); if (which == 0) Assert.That(list[0], Is.EqualTo(firstDirPath), "first directory has config so should have come first"); else Assert.That(list[0], Is.EqualTo(secondDirPath), "second directory has config so should have come first"); } } }
public void Setup() { var library = new Moq.Mock<CollectionSettings>(); library.SetupGet(x => x.IsSourceCollection).Returns(false); library.SetupGet(x => x.Language2Iso639Code).Returns("en"); library.SetupGet(x => x.Language1Iso639Code).Returns("xyz"); library.SetupGet(x => x.XMatterPackName).Returns("Factory"); ErrorReport.IsOkToInteractWithUser = false; _fileLocator = new FileLocator(new string[] { //FileLocator.GetDirectoryDistributedWithApplication( "factoryCollections"), BloomFileLocator.GetFactoryBookTemplateDirectory("Basic Book"), BloomFileLocator.GetFactoryBookTemplateDirectory("Wall Calendar"), FileLocator.GetDirectoryDistributedWithApplication( BloomFileLocator.BrowserRoot), BloomFileLocator.GetBrowserDirectory("bookLayout"), BloomFileLocator.GetBrowserDirectory("bookEdit","css"), BloomFileLocator.GetInstalledXMatterDirectory() }); var projectFolder = new TemporaryFolder("BookStarterTests_ProjectCollection"); var collectionSettings = new CollectionSettings(Path.Combine(projectFolder.Path, "test.bloomCollection")); _starter = new BookStarter(_fileLocator, dir => new BookStorage(dir, _fileLocator, new BookRenamedEvent(), collectionSettings), library.Object); _shellCollectionFolder = new TemporaryFolder("BookStarterTests_ShellCollection"); _libraryFolder = new TemporaryFolder("BookStarterTests_LibraryCollection"); }
public void Constructor_PathDirectoryName_CreatesTemporarySubDirectoryAtPathWithGivenName() { TemporaryFolder temporaryFolder = new TemporaryFolder("Constructor_PathDirectoryName_CreatesTemporarySubDirectoryAtPathWithGivenName"); Assert.IsTrue(Directory.Exists(temporaryFolder.FolderPath)); temporaryFolder.Dispose(); Assert.IsFalse(Directory.Exists(temporaryFolder.Path)); }
public void Constructor_Path_CreatesTemporarySubDirectoryAtPath() { using (TemporaryFolder temporaryFolder = new TemporaryFolder("foo")) { Assert.IsTrue(Directory.Exists(temporaryFolder.FolderPath)); } }
public OfflineSldr() { _sldrCacheFolder = new TemporaryFolder("SldrCacheTest"); Sldr.SldrCachePath = _sldrCacheFolder.Path; Sldr.OfflineMode = true; Sldr.ResetLanguageTags(); }
public void Constructor_CreatesTemporarySubDirectory() { var temporaryFolder = new TemporaryFolder(); Assert.IsTrue(Directory.Exists(temporaryFolder.FolderPath)); temporaryFolder.Dispose(); Assert.IsFalse(Directory.Exists(temporaryFolder.Path)); }
public void Constructor_CreatesFolders() { using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests")) { var repo = new GlobalWritingSystemRepository(e.Path); Assert.That(Directory.Exists(repo.PathToWritingSystems), Is.True); } }
public void Launch_CloseAfterAFewSeconds_DoesntCrash() { using (var folder = new TemporaryFolder("ChorusApplicationTests")) { Application.Idle += new EventHandler(Application_Idle); new Program.Runner().Run(folder.Path, new Arguments(new object[]{})); } }
public void GetTemporaryFile_FileExistsInTemporarySubdirectory() { TemporaryFolder temporaryFolder = new TemporaryFolder(); string pathToFile = temporaryFolder.GetTemporaryFile(); Assert.IsTrue(File.Exists(pathToFile)); temporaryFolder.Dispose(); Assert.IsFalse(Directory.Exists(temporaryFolder.Path)); }
public TempLiftFile(string fileName, TemporaryFolder parentFolder, string xmlOfEntries, string claimedLiftVersion) : base(true) // True means "I'll set the the pathname, thank you very much." Otherwise, the temp one 'false' creates will stay forever, and fill the hard drive up. { _path = parentFolder.Combine(fileName); string liftContents = string.Format("<?xml version='1.0' encoding='utf-8'?><lift version='{0}'>{1}</lift>", claimedLiftVersion, xmlOfEntries); File.WriteAllText(_path, liftContents); }
public TestEnvironment(string liftFileContent) { _folder = new TemporaryFolder("WritingSystemsInLiftFileHelper"); var pathtoLiftFile1 = Path.Combine(_folder.Path, "test1.lift"); _liftFile1 = new SIL.IO.TempFile(liftFileContent); _liftFile1.MoveTo(pathtoLiftFile1); Helper = new WritingSystemsInLiftFileHelper(WritingSystems, _liftFile1.Path); }
public TestEnvironment() { FolderContainingLdml = new TemporaryFolder("LdmlInFolderMigratorTests"); NamespaceManager = new XmlNamespaceManager(new NameTable()); NamespaceManager.AddNamespace("sil", "urn://www.sil.org/ldml/0.1"); NamespaceManager.AddNamespace("palaso", "urn://palaso.org/ldmlExtensions/v1"); NamespaceManager.AddNamespace("palaso2", "urn://palaso.org/ldmlExtensions/v2"); }
public void GetTemporaryFile_Name_FileWithNameExistsInTemporarySubdirectory() { TemporaryFolder temporaryFolder = new TemporaryFolder(); string pathToFile = temporaryFolder.GetTemporaryFile("blah"); Assert.IsTrue(File.Exists(pathToFile)); Assert.AreEqual(pathToFile, Path.Combine(temporaryFolder.Path, "blah")); temporaryFolder.Dispose(); Assert.IsFalse(Directory.Exists(temporaryFolder.Path)); }
public void LaunchDialog_CustomUrlSourceWontBeFound() { using (var source = new TemporaryFolder("CloneDialogTest")) { Directory.CreateDirectory(source.Combine("repo1")); HgRepository.CreateRepositoryInExistingDir(source.Combine("repo1"), new NullProgress()); LaunchCustomUrl(@"somewhereElse"); } }
public void Constructor_WithExistingFolders_NoThrow() { using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests")) { new GlobalWritingSystemRepository(e.Path); var repo2 = new GlobalWritingSystemRepository(e.Path); Assert.That(Directory.Exists(repo2.PathToWritingSystems), Is.True); } }
public void GetTemporaryFile_CalledTwice_BothFilesFoundInSameTemporarySubdirectory() { TemporaryFolder temporaryFolder = new TemporaryFolder(); temporaryFolder.GetTemporaryFile(); temporaryFolder.GetTemporaryFile(); Assert.AreEqual(2, Directory.GetFiles(temporaryFolder.Path).Length); temporaryFolder.Dispose(); Assert.IsFalse(Directory.Exists(temporaryFolder.Path)); }
[Test]//regression public void RepoProjectName_SourceHasDotInName_IsNotLost() { using (var f = new TemporaryFolder("SourceHasDotInName_IsNotLost.x.y")) { Synchronizer m = new Synchronizer(f.Path, new ProjectFolderConfiguration("blah"), new ConsoleProgress()); Assert.AreEqual("SourceHasDotInName_IsNotLost.x.y", m.RepoProjectName); } }
public void HasNoExtantRepositories() { using (var hasProject = new TemporaryFolder("hasRepo")) { var newFile = Path.Combine(hasProject.Path, "test.txt"); File.WriteAllText(newFile, "some stuff"); Assert.AreEqual(0, GetSharedProjectModel.ExtantRepoIdentifiers(hasProject.Path, null).Count); } }
public void Clone_Test() { // RobustNetworkOperation.ClearCredentialSettings(); using (var f = new TemporaryFolder("clonetest")) { HgRepository.Clone(new HttpRepositoryPath("cloneableTestProjectUrl", _cloneableTestProjectUrl, false), f.Path, _progress); Assert.IsTrue(Directory.Exists(f.Combine(f.Path, ".hg"))); } }
public void BadMercurialIni_Throws() { using (new MercurialIniHider()) using (var testRoot = new TemporaryFolder("ChorusHgSettingsTest")) { Assert.Throws<ApplicationException>(() => HgRepository.CreateRepositoryInExistingDir(testRoot.Path, _progress) ); } }
public void PathConstructor_HasCorrectPath() { using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests")) { var repo = new GlobalWritingSystemRepository(e.Path); string expectedPath = string.Format(".*GlobalWritingSystemRepositoryTests.{0}", LdmlDataMapper.CurrentLdmlVersion); Assert.That(repo.PathToWritingSystems, Is.StringMatching(expectedPath)); } }
public void Set_NewWritingSystem_SetsId() { using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests")) { var repo = new GlobalWritingSystemRepository(e.Path); var ws = new WritingSystemDefinition("en-US"); Assert.That(ws.Id, Is.Null); repo.Set(ws); Assert.That(ws.Id, Is.EqualTo("en-US")); } }
public void Pull_Test() { //RobustNetworkOperation.ClearCredentialSettings(); using (var f = new TemporaryFolder("pulltest")) { var repo = HgRepository.CreateOrUseExisting(f.Path, _progress); var address = new HttpRepositoryPath("default", _cloneableTestProjectUrl, false); repo.Pull(address, _cloneableTestProjectUrl); Assert.IsTrue(Directory.Exists(f.Combine(f.Path, ".hg"))); } }
public void URL_AfterConstruction_GoodDefault() { using (var testFolder = new TemporaryFolder("clonetest")) { var model = new InternetCloneSettingsModel(testFolder.Path); model.AccountName = "account"; model.Password = "******"; model.ProjectId = "id"; Assert.AreEqual("http://*****:*****@resumable.languagedepot.org/id", model.URL.ToLower()); } }
public void InitFromUri_GivenCompleteUri_AllPropertiesCorrect() { using (var testFolder = new TemporaryFolder("clonetest")) { var model = new InternetCloneSettingsModel(testFolder.Path); model.InitFromUri("http://*****:*****@hg-languagedepot.org/tpi?localFolder=tokPisin"); Assert.AreEqual("tokPisin", model.LocalFolderName); Assert.IsTrue(model.ReadyToDownload); Assert.AreEqual("http://*****:*****@hg-languagedepot.org/tpi",model.URL); } }
public void Save_NewWritingSystem_CreatesLdmlFile() { using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests")) { var repo = new GlobalWritingSystemRepository(e.Path); var ws = new WritingSystemDefinition("en-US"); repo.Set(ws); repo.Save(); Assert.That(File.Exists(repo.GetFilePathFromLanguageTag("en-US")), Is.True); } }
/// <summary> /// Create a tempfile within the given parent folder /// </summary> public TempFileFromFolder(TemporaryFolder parentFolder) : base(true) // True means "I'll set the the pathname, thank you very much." Otherwise, the temp one 'false' creates will stay forever, and fill the hard drive up. { Path = parentFolder != null?parentFolder.GetPathForNewTempFile(true) : System.IO.Path.GetTempFileName(); }
public TempFileFromFolder(TemporaryFolder parentFolder, string name, string contents) : base(true) // True means "I'll set the the pathname, thank you very much." Otherwise, the temp one 'false' creates will stay forever, and fill the hard drive up. { Path = parentFolder.Combine(name); File.WriteAllText(Path, contents); }