public void CanCopyRootDirectoryToExistingDirectory() { TargetVolume.CreateDirectory(VolumePath.FromString("/newdirectory")); Assert.IsTrue(volumeManager.Copy(GlobalPath.FromString("0:/"), GlobalPath.FromString("1:/newdirectory"))); CompareDirectories(GlobalPath.FromString("0:/"), GlobalPath.FromString("1:/newdirectory")); }
public void CanMoveDirectoryToRootDirectory() { GlobalPath targetPath = GlobalPath.FromString("1:"); Assert.IsTrue(volumeManager.Move(dir1Path, targetPath)); Assert.IsFalse(SourceVolume.Exists(dir1Path)); }
public void CanFailToMoveRootDirectory() { GlobalPath sourcePath = GlobalPath.FromString("0:"); GlobalPath targetPath = GlobalPath.FromString("1:/newname"); volumeManager.Move(sourcePath, targetPath); }
public void CanCopyDirectoryToExistingDirectoryTwice() { TargetVolume.CreateDirectory(VolumePath.FromString("/newdirectory")); Assert.IsTrue(volumeManager.Copy(dir1Path, GlobalPath.FromString("1:/newdirectory"))); Assert.IsTrue(volumeManager.Copy(dir1Path, GlobalPath.FromString("1:/newdirectory"))); CompareDirectories(dir1Path, GlobalPath.FromString("1:/newdirectory/" + dir1)); }
public void CanReturnParent() { GlobalPath path = GlobalPath.FromString("othervolume:/level1/level2"); Assert.AreEqual("othervolume", path.VolumeId); Assert.AreEqual(2, path.Depth); Assert.AreEqual(2, path.Length); }
public void CanHandleVolumeIds() { GlobalPath path = GlobalPath.FromString("1:level1/level2"); Assert.AreEqual(1, path.VolumeId); Assert.AreEqual(2, path.Depth); Assert.AreEqual(2, path.Length); }
public void CanHandleVolumeNames() { GlobalPath path = GlobalPath.FromString("othervolume:/level1/level2"); Assert.AreEqual("othervolume", path.VolumeId); Assert.AreEqual(2, path.Depth); Assert.AreEqual(2, path.Length); }
public void CanCopyDirectoryToNewDirectory() { GlobalPath targetPath = GlobalPath.FromString("1:/newname"); Assert.IsTrue(volumeManager.Copy(dir1Path, targetPath)); CompareDirectories(dir1Path, targetPath); }
public void CanHandleJustVolumeName() { GlobalPath path = GlobalPath.FromString("othervolume:"); Assert.AreEqual("othervolume", path.VolumeId); Assert.IsEmpty(path.Name); Assert.AreEqual(0, path.Depth); Assert.AreEqual(0, path.Length); }
public void CanCopyFileByCookedName() { GlobalPath targetPath = GlobalPath.FromString("1:"); Assert.IsTrue(volumeManager.Copy(dir1Path.Combine("file3"), targetPath)); Assert.AreEqual(1, TargetVolume.Root.List().Count); Assert.IsTrue(TargetVolume.Root.List()[file3] is VolumeFile); }
public void CanCopyFileToNewFile() { Assert.IsTrue(volumeManager.Copy(subsubdir1File1Path, GlobalPath.FromString("1:/dir1/file1"))); Assert.AreEqual(1, TargetVolume.Root.List().Count); VolumeDirectory parent = (TargetVolume.Open(dir1Path) as VolumeDirectory); Assert.AreEqual(1, parent.List().Count); Assert.AreEqual("subsubdir1File1\n", (parent.List()[file1] as VolumeFile).ReadAll().String); }
public void CanCopyRootDirectoryToRootDirectoryTwice() { GlobalPath source = GlobalPath.FromString("0:/"); GlobalPath destination = GlobalPath.FromString("1:/"); Assert.IsTrue(volumeManager.Copy(source, destination)); Assert.IsTrue(volumeManager.Copy(source, destination)); CompareDirectories(source, destination); }
public void CanCopyFileToRootDirectory() { GlobalPath targetPath = GlobalPath.FromString("1:"); Assert.IsTrue(volumeManager.Copy(subsubdir1File1Path, targetPath)); Assert.AreEqual(1, TargetVolume.Root.List().Count); VolumeFile file = (TargetVolume.Open(file1) as VolumeFile); Assert.AreEqual("subsubdir1File1\n", file.ReadAll().String); }
public void CanMoveFileByCookedName() { var sourcePath = dir1Path.Combine("file3"); GlobalPath targetPath = GlobalPath.FromString("1:"); Assert.IsTrue(volumeManager.Move(sourcePath, targetPath)); Assert.IsFalse(SourceVolume.Exists(sourcePath)); Assert.AreEqual(1, TargetVolume.Root.List().Count); Assert.IsTrue(TargetVolume.Root.List()[file3] is VolumeFile); }
public void CanMoveEvenIfThereIsNoSpaceOnSameVolume() { if (SourceVolume.Capacity == Volume.INFINITE_CAPACITY) { Assert.Pass(); return; } (SourceVolume.Open(subsubdir1File1Path) as VolumeFile) .WriteLn(new string('a', (int)SourceVolume.Capacity / 2 + 1)); Assert.IsTrue(volumeManager.Move(subdir1Path, GlobalPath.FromString("0:/newname"))); }
public void CanFailToMoveWhenTheresNoSpaceOnTargetVolume() { if (TargetVolume.Capacity == Volume.INFINITE_CAPACITY) { Assert.Pass(); return; } (SourceVolume.Open(subsubdir1File1Path) as VolumeFile) .WriteLn(new string('a', (int)TargetVolume.Capacity / 2 + 1)); Assert.IsTrue(volumeManager.Copy(subdir1Path, GlobalPath.FromString("1:/copy1"))); Assert.IsFalse(volumeManager.Move(subdir1Path, GlobalPath.FromString("1:/copy2"))); }
public void CanMoveFileToDirectory() { GlobalPath targetPath = GlobalPath.FromString("1:/dir1"); TargetVolume.CreateDirectory(targetPath); Assert.IsTrue(volumeManager.Move(subsubdir1File1Path, targetPath)); Assert.IsFalse(SourceVolume.Exists(subsubdir1File1Path)); Assert.AreEqual(1, TargetVolume.Root.List().Count); VolumeDirectory parent = (TargetVolume.Open(dir1Path) as VolumeDirectory); Assert.AreEqual(1, parent.List().Count); Assert.AreEqual("subsubdir1File1\n", (parent.List()[file1] as VolumeFile).ReadAll().String); }
public void CanFailToCopyDirectoryIfThereIsNoSpaceToCopy() { if (TargetVolume.Capacity == Volume.INFINITE_CAPACITY) { Assert.Pass(); return; } (SourceVolume.Open(subsubdir1File1Path) as VolumeFile) .WriteLn(new string('a', (int)TargetVolume.Capacity / 4 + 1)); SourceVolume.CreateFile(subdir1Path.Combine("other")) .WriteLn(new string('a', (int)TargetVolume.Capacity / 4 + 1)); Assert.IsTrue(volumeManager.Copy(subdir1Path, GlobalPath.FromString("1:/copy1"))); Assert.IsFalse(volumeManager.Copy(subdir1Path, GlobalPath.FromString("1:/copy2"))); }
public void CanChangeName() { GlobalPath path = GlobalPath.FromString("othervolume:123"); GlobalPath newPath = path.ChangeName("abc"); Assert.AreEqual("othervolume", newPath.VolumeId); Assert.AreEqual(1, newPath.Length); Assert.AreEqual("abc", newPath.Name); path = GlobalPath.FromString("othervolume:/dir/file.jpg"); newPath = path.ChangeName("new.txt"); Assert.AreEqual("othervolume", newPath.VolumeId); Assert.AreEqual(2, newPath.Length); Assert.AreEqual("new.txt", newPath.Name); }
public void CanIdentifyParents() { GlobalPath path = GlobalPath.FromString("othervolume:/level1/level2"); GlobalPath parent1 = GlobalPath.FromString("othervolume:"); GlobalPath parent2 = GlobalPath.FromString("othervolume:/level1"); GlobalPath notParent1 = GlobalPath.FromString("othervolume:/sthelse"); GlobalPath notParent2 = GlobalPath.FromString("othervolume:/level1/level2/level3"); GlobalPath notParent3 = GlobalPath.FromString("othervolume2:/level1/level2"); Assert.IsTrue(parent1.IsParent(path)); Assert.IsTrue(parent2.IsParent(path)); Assert.IsFalse(path.IsParent(path)); Assert.IsFalse(notParent1.IsParent(path)); Assert.IsFalse(notParent2.IsParent(path)); Assert.IsFalse(notParent3.IsParent(path)); }
public void CanCombine() { GlobalPath path = GlobalPath.FromString("othervolume:123"); GlobalPath newPath = path.Combine("456", "789"); Assert.AreEqual("othervolume", newPath.VolumeId); Assert.AreEqual(3, newPath.Length); Assert.AreEqual("789", newPath.Name); newPath = path.Combine("..", "abc"); Assert.AreEqual("othervolume", newPath.VolumeId); Assert.AreEqual(1, newPath.Length); Assert.AreEqual("abc", newPath.Name); newPath = path.Combine("sub/abc"); Assert.AreEqual("othervolume", newPath.VolumeId); Assert.AreEqual(3, newPath.Length); Assert.AreEqual("abc", newPath.Name); }
public void CanChangeExtension() { GlobalPath path = GlobalPath.FromString("othervolume:123"); GlobalPath newPath = path.ChangeExtension("txt"); Assert.AreEqual("othervolume", newPath.VolumeId); Assert.AreEqual(1, newPath.Length); Assert.AreEqual("123.txt", newPath.Name); path = GlobalPath.FromString("othervolume:/dir/file.jpg"); newPath = path.ChangeExtension("txt"); Assert.AreEqual("othervolume", newPath.VolumeId); Assert.AreEqual(2, newPath.Length); Assert.AreEqual("file.txt", newPath.Name); path = GlobalPath.FromString("othervolume:/dir/complex.file..name.."); newPath = path.ChangeExtension("txt"); Assert.AreEqual("othervolume", newPath.VolumeId); Assert.AreEqual(2, newPath.Length); Assert.AreEqual("complex.file..name..txt", newPath.Name); }
public void SetupVolumes() { dir1Path = GlobalPath.FromString("0:" + dir1); subdir1Path = dir1Path.Combine(subdir1); subdir2Path = dir1Path.Combine(subdir2); subsubdir1Path = subdir1Path.Combine(subsubdir1); file1Path = GlobalPath.FromString("0:" + file1); dir1File1Path = dir1Path.Combine(file1); dir1File2Path = dir1Path.Combine(file2); dir1File3Path = dir1Path.Combine(file3); subdir1File1Path = subdir1Path.Combine(file1); subsubdir1File1Path = subsubdir1Path.Combine(file1); SourceVolume.Clear(); TargetVolume.Clear(); SourceVolume.CreateDirectory(subdir2Path); SourceVolume.CreateDirectory(subsubdir1Path); SourceVolume.CreateFile(file1Path).WriteLn(file1); SourceVolume.CreateFile(dir1File3Path).WriteLn(file2); SourceVolume.CreateFile(subsubdir1File1Path).WriteLn("subsubdir1File1"); }
public void CanHandleChangingExtensionOfRootPaths() { GlobalPath path = GlobalPath.FromString("othervolume:"); path.ChangeExtension("txt"); }
public void CanMoveDirectoryToExistingDirectory() { TargetVolume.CreateDirectory(VolumePath.FromString("/newdirectory")); Assert.IsTrue(volumeManager.Move(dir1Path, GlobalPath.FromString("1:/newdirectory"))); Assert.IsFalse(SourceVolume.Exists(dir1Path)); }
public void CanFailWhenTryingToMoveDirectoryToAFile() { VolumePath filePath = TargetVolume.CreateFile("newfile").Path; volumeManager.Move(dir1Path, GlobalPath.FromString("1:/newfile")); }
public void CanFailToCombineOutside() { GlobalPath path = GlobalPath.FromString("othervolume:123"); path.Combine("..", ".."); }
public void CanHandleGlobalPathWithLessThanZeroDepth() { GlobalPath.FromString("othervolume:/test/../../"); }
public void CanCopyRootDirectoryToRootDirectory() { Assert.IsTrue(volumeManager.Copy(GlobalPath.FromString("0:/"), GlobalPath.FromString("1:/"))); CompareDirectories(GlobalPath.FromString("0:/"), GlobalPath.FromString("1:/")); }
public override void LoadDump(Dump dump) { Path = GlobalPath.FromString(dump[DumpPath] as string); }