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 CanDeleteNonExistingDirectories() { VolumePath path = VolumePath.FromString("/abc"); TestVolume.CreateDirectory(path); TestVolume.Delete(path); TestVolume.Delete(path); }
public void CanDeleteNonExistingFiles() { VolumePath path = VolumePath.FromString("/abc"); TestVolume.CreateFile(path); // Delete the file twice Assert.IsTrue(TestVolume.Delete(path)); Assert.IsFalse(TestVolume.Delete(path)); }
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 CanFailWhenTryingToDeleteRootDirectory() { VolumePath path = VolumePath.FromString("/"); TestVolume.Delete(path); }