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 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); }
private void CompareDirectories(GlobalPath dir1Path, GlobalPath dir2Path) { Volume dir1Volume = volumeManager.GetVolumeFromPath(dir1Path); Volume dir2Volume = volumeManager.GetVolumeFromPath(dir2Path); VolumeDirectory dir1 = dir1Volume.Open(dir1Path) as VolumeDirectory; VolumeDirectory dir2 = dir2Volume.Open(dir2Path) as VolumeDirectory; Assert.NotNull(dir1); Assert.NotNull(dir2); int dir1Count = dir1.List().Count; int dir2Count = dir2.List().Count; if (dir1Count != dir2Count) { Assert.Fail("Item count not equal: " + dir1Count + " != " + dir2Count); } foreach (KeyValuePair <string, VolumeItem> pair in dir1.List()) { VolumeItem dir2Item = dir2Volume.Open(dir2Path.Combine(pair.Key)); if (pair.Value is VolumeDirectory && dir2Item is VolumeDirectory) { CompareDirectories(dir1Path.Combine(pair.Key), dir2Path.Combine(pair.Key)); } else if (pair.Value is VolumeFile && dir2Item is VolumeFile) { VolumeFile file1 = pair.Value as VolumeFile; VolumeFile file2 = dir2Item as VolumeFile; Assert.AreEqual(file1.ReadAll(), file2.ReadAll()); } else { Assert.Fail("Items are not of the same type: " + dir1Path.Combine(pair.Key) + ", " + dir2Path.Combine(pair.Key)); } } }
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 CanFailToCombineOutside() { GlobalPath path = GlobalPath.FromString("othervolume:123"); path.Combine("..", ".."); }