本文整理汇总了C#中SIL.TestUtilities.TemporaryFolder类的典型用法代码示例。如果您正苦于以下问题:C# TemporaryFolder类的具体用法?C# TemporaryFolder怎么用?C# TemporaryFolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TemporaryFolder类属于SIL.TestUtilities命名空间,在下文中一共展示了TemporaryFolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestEnvironment
public TestEnvironment()
{
_temporaryFolder = new TemporaryFolder("LiftLexEntryRepositoryTests");
string filePath = _temporaryFolder.GetTemporaryFile();
_repository = new LiftLexEntryRepository(filePath);
_headwordWritingSystem = new WritingSystemDefinition("th") {DefaultCollation = new IcuRulesCollationDefinition("standard")};
}
示例2: Constructor_CreatesTemporarySubDirectory
public void Constructor_CreatesTemporarySubDirectory()
{
var temporaryFolder = new TemporaryFolder();
Assert.IsTrue(Directory.Exists(temporaryFolder.FolderPath));
temporaryFolder.Dispose();
Assert.IsFalse(Directory.Exists(temporaryFolder.Path));
}
示例3: OfflineSldr
public OfflineSldr()
{
_sldrCacheFolder = new TemporaryFolder("SldrCacheTest");
Sldr.SldrCachePath = _sldrCacheFolder.Path;
Sldr.OfflineMode = true;
Sldr.ResetLanguageTags();
}
示例4: SettingsFolderWithNewerConfig_SortsBeforeOneWithOlderConfig
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));
}
}
示例5: Setup
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");
}
示例6: TestEnvironment
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);
}
示例7: SettingsFolderWithNoConfig_SortsAfterOneWithConfig
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");
}
}
}
示例8: Constructor_PathDirectoryName_CreatesTemporarySubDirectoryAtPathWithGivenName
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));
}
示例9: Constructor_Path_CreatesTemporarySubDirectoryAtPath
public void Constructor_Path_CreatesTemporarySubDirectoryAtPath()
{
using (TemporaryFolder temporaryFolder = new TemporaryFolder("foo"))
{
Assert.IsTrue(Directory.Exists(temporaryFolder.FolderPath));
}
}
示例10: HgTestSetup
public HgTestSetup()
{
_progress = new ConsoleProgress();
Root = new TemporaryFolder("ChorusHgWrappingTest");
HgRepository.CreateRepositoryInExistingDir(Root.Path,_progress);
Repository = new HgRepository(Root.Path, new NullProgress());
}
示例11: TempLiftFile
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);
}
示例12: Launch_CloseAfterAFewSeconds_DoesntCrash
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[]{}));
}
}
示例13: GetTemporaryFile_FileExistsInTemporarySubdirectory
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));
}
示例14: TestEnvironment
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);
}
示例15: Constructor_CreatesFolders
public void Constructor_CreatesFolders()
{
using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
{
var repo = new GlobalWritingSystemRepository(e.Path);
Assert.That(Directory.Exists(repo.PathToWritingSystems), Is.True);
}
}