public void TestRename(string directory, string newFileName, string additionalFolders) { var scheduler = new SimpleTestScheduler(); var source = new TempFileSource(); long sourceSize = source.FileInfo.Length; string destinationPath = newFileName; string rootFolderPath = source.Path; if (directory != null) { destinationPath = Path.Combine( additionalFolders == null ? directory : Path.Combine(directory, additionalFolders), destinationPath); rootFolderPath = Path.Combine(rootFolderPath, directory); } string fullDestinationPath = Path.Combine(source.Path, destinationPath); Assert.IsFalse(File.Exists(destinationPath)); scheduler.Builder.Append(new SourceRenamer(f => destinationPath)); scheduler.Start(); scheduler.ExecuteBlocking(source); Assert.IsTrue(File.Exists(fullDestinationPath)); Assert.AreEqual(sourceSize, new FileInfo(fullDestinationPath).Length); File.Delete(fullDestinationPath); if (directory != null) { Directory.Delete(rootFolderPath, true); } }
private static SimpleTestScheduler InitVars(out IFileSource source, out string newFolderPath) { var scheduler = new SimpleTestScheduler(); source = new TempFileSource(); newFolderPath = Path.Combine(Path.GetTempPath(), ".clone"); return(scheduler); }
private static SimpleTestScheduler PrepareMove(out TempFileSource source, out long sourceSize, out string destinationPath) { var scheduler = new SimpleTestScheduler(); source = new TempFileSource(); sourceSize = source.FileInfo.Length; destinationPath = Path.Combine(Path.GetTempPath(), ".subfolder"); return(scheduler); }
public void TestDeleteSource() { var scheduler = new SimpleTestScheduler(); var source = new TempFileSource(); scheduler.Builder.Append(new SourceDeleter()); Assert.AreEqual(true, File.Exists(source.FileInfo.FullName)); scheduler.Execute(source); Assert.AreEqual(false, File.Exists(source.FileInfo.FullName)); }