public async Task MoveFile_SamePath() { using var tmp = TempDir.Create(); var file = TorrentFileInfo.Create(Constants.BlockSize, ("file.txt", 123456, Path.Combine(tmp.Path, "orig.txt"))).Single(); File.OpenWrite(file.FullPath).Close(); using var writer = new TestPieceWriter(); using var manager = new DiskManager(new EngineSettings(), Factories.Default, writer); await manager.MoveFileAsync(file, file.FullPath); Assert.IsTrue(File.Exists(file.FullPath)); }
public async Task MoveFile_ConvertsToFullPath() { using var writer = new TestPieceWriter(); using var manager = new DiskManager(new EngineSettings(), Factories.Default, writer); var file = TorrentFileInfo.Create(Constants.BlockSize, 123456).Single(); Assert.IsFalse(File.Exists(file.FullPath)); await manager.MoveFileAsync(file, "NewPath"); Assert.AreEqual(Path.GetFullPath("NewPath"), file.FullPath); Assert.IsFalse(File.Exists(file.FullPath)); }
public async Task MoveFile_TargetDirectoryDoesNotExist() { using var tmp = TempDir.Create(); var file = TorrentFileInfo.Create(Constants.BlockSize, ("file.txt", 123456, Path.Combine(tmp.Path, "orig.txt"))).Single(); File.OpenWrite(file.FullPath).Close(); using var writer = new TestPieceWriter(); using var manager = new DiskManager(new EngineSettings(), Factories.Default, writer); var fullPath = Path.Combine(tmp.Path, "New", "Path", "file.txt"); await manager.MoveFileAsync(file, fullPath); Assert.AreEqual(fullPath, file.FullPath); }
public void MoveFileFail() { writer.move = true; Assert.ThrowsAsync <Exception> (() => diskManager.MoveFileAsync((TorrentFileInfo)data.Files[0], "root")); }