public void CanDeleteFiles() { string parent1 = "/parent1"; string file1 = parent1 + "/sub1", file2 = parent1 + "/sub2"; TestVolume.CreateFile(VolumePath.FromString(file1)); TestVolume.CreateFile(VolumePath.FromString(file2)); Assert.IsTrue(TestVolume.Delete(VolumePath.FromString(file1))); VolumeDirectory dir = TestVolume.Open(VolumePath.FromString(parent1)) as VolumeDirectory; Assert.AreEqual(1, dir.List().Count); Assert.AreEqual(file2, dir.List()["sub2"].Path.ToString()); Assert.IsInstanceOf <VolumeFile>(dir.List()["sub2"]); TestVolume.CreateFile(VolumePath.FromString(file2 + ".ks")); Assert.IsTrue(TestVolume.Delete(VolumePath.FromString(file2 + ".ks"))); Assert.AreEqual(1, dir.List().Count); Assert.AreEqual(file2, dir.List()["sub2"].Path.ToString()); Assert.IsInstanceOf <VolumeFile>(dir.List()["sub2"]); TestVolume.CreateFile(VolumePath.FromString(file2 + ".ks")); Assert.IsTrue(TestVolume.Delete(VolumePath.FromString(file2))); Assert.AreEqual(1, dir.List().Count); Assert.AreEqual(file2 + ".ks", dir.List()["sub2.ks"].Path.ToString()); Assert.IsInstanceOf <VolumeFile>(dir.List()["sub2.ks"]); Assert.IsTrue(TestVolume.Delete(VolumePath.FromString(file2))); Assert.AreEqual(0, dir.List().Count); }
public void CanCreateFiles() { string parent1 = "/parent1", parent2 = "/parent2"; string file1 = parent1 + "/sub1/file", file2 = parent1 + "/sub2", file3 = parent2 + "/sub3"; TestVolume.CreateFile(VolumePath.FromString(file1)); TestVolume.CreateFile(VolumePath.FromString(file2)); TestVolume.CreateFile(VolumePath.FromString(file3)); Assert.AreEqual(2, TestVolume.Root.List().Count); Assert.AreEqual(parent1, TestVolume.Root.List()["parent1"].Path.ToString()); Assert.AreEqual(parent2, TestVolume.Root.List()["parent2"].Path.ToString()); VolumeDirectory dir = TestVolume.Open(VolumePath.FromString(parent1)) as VolumeDirectory; Assert.AreEqual(2, dir.List().Count); Assert.AreEqual("/parent1/sub1", dir.List()["sub1"].Path.ToString()); Assert.IsInstanceOf <VolumeDirectory>(dir.List()["sub1"]); Assert.AreEqual(file2, dir.List()["sub2"].Path.ToString()); Assert.IsInstanceOf <VolumeFile>(dir.List()["sub2"]); dir = TestVolume.Open(VolumePath.FromString("/parent1/sub1")) as VolumeDirectory; Assert.AreEqual(1, dir.List().Count); Assert.AreEqual("/parent1/sub1/file", dir.List()["file"].Path.ToString()); Assert.IsInstanceOf <VolumeFile>(dir.List()["file"]); dir = TestVolume.Open(VolumePath.FromString(parent2)) as VolumeDirectory; Assert.AreEqual(1, dir.List().Count); Assert.AreEqual(file3, dir.List()["sub3"].Path.ToString()); Assert.IsInstanceOf <VolumeFile>(dir.List()["sub3"]); }
public void CanDeleteDirectories() { string parent1 = "/parent1", parent2 = "/parent2"; string dir1 = parent1 + "/sub1", dir2 = parent1 + "/sub2", dir3 = parent2 + "/sub3"; TestVolume.CreateDirectory(VolumePath.FromString(dir1)); TestVolume.CreateDirectory(VolumePath.FromString(dir2)); TestVolume.CreateDirectory(VolumePath.FromString(dir3)); VolumeDirectory parent = TestVolume.Open(VolumePath.FromString(parent1)) as VolumeDirectory; TestVolume.Delete(VolumePath.FromString(dir1)); Assert.AreEqual(1, parent.List().Count); Assert.AreEqual(dir2, parent.List()["sub2"].Path.ToString()); TestVolume.Delete(VolumePath.FromString(parent2)); Assert.AreEqual(1, TestVolume.Root.List().Count); Assert.AreEqual(parent1, TestVolume.Root.List()["parent1"].Path.ToString()); }
public void CanHandleOpeningNonExistingFiles() { Assert.IsNull(TestVolume.Open(VolumePath.FromString("/idonotexist"))); }