public void AppendPathTest() { Assert.IsTrue(Directories.All(p => p.AppendPath(root) == p)); Assert.IsTrue(Directories.All(p => p.AppendPath("") == p)); var subpath = FileSystemPath.Parse("/dir/file"); var subpathstr = "dir/file"; foreach (var p in Directories) { Assert.IsTrue(p.AppendPath(subpath).ParentPath.ParentPath == p); } foreach (var p in Directories) { Assert.IsTrue(p.AppendPath(subpathstr).ParentPath.ParentPath == p); } foreach (var pa in Directories) { foreach (var pb in _paths.Where(pb => !pb.IsRoot)) { Assert.IsTrue(pa.AppendPath(pb).IsChildOf(pa)); } } EAssert.Throws <InvalidOperationException>(() => fileA.AppendPath(subpath)); EAssert.Throws <InvalidOperationException>(() => fileA.AppendPath(subpathstr)); EAssert.Throws <ArgumentException>(() => directoryA.AppendPath("/rootedpath/")); }
public void ParseTest() { Assert.IsTrue(_paths.All(p => p == FileSystemPath.Parse(p.ToString()))); EAssert.Throws <ArgumentNullException>(() => FileSystemPath.Parse(null)); EAssert.Throws <ParseException>(() => FileSystemPath.Parse("thisisnotapath")); EAssert.Throws <ParseException>(() => FileSystemPath.Parse("/thisisainvalid//path")); }
public void ChangeExtensionTest() { foreach (var p in _paths.Where(p => p.IsFile)) { Assert.IsTrue(p.ChangeExtension(".exe").GetExtension() == ".exe"); } EAssert.Throws <ArgumentException>(() => directoryA.ChangeExtension(".exe")); }
public void GetExtensionTest() { Assert.AreEqual(fileA.GetExtension(), ""); Assert.AreEqual(fileB.GetExtension(), ".txt"); fileC = FileSystemPath.Parse("/directory.txt/filec"); Assert.AreEqual(fileC.GetExtension(), ""); EAssert.Throws <ArgumentException>(() => directoryA.GetExtension()); }
public void RemoveChildTest() { Assert.AreEqual(fileB.RemoveChild(FileSystemPath.Parse("/fileb.txt")), directoryA); Assert.AreEqual(directoryB.RemoveChild(FileSystemPath.Parse("/directoryb/")), directoryA); Assert.AreEqual(directoryB.RemoveChild(directoryB), root); Assert.AreEqual(fileB.RemoveChild(fileB), root); EAssert.Throws <ArgumentException>(() => directoryA.RemoveChild(FileSystemPath.Parse("/nonexistantchild"))); EAssert.Throws <ArgumentException>(() => directoryA.RemoveChild(FileSystemPath.Parse("/directorya"))); }
public void ParentPathTest() { Assert.IsTrue( Directories .Where(d => d.GetDirectorySegments().Length == 1) .All(d => d.ParentPath == root) ); Assert.IsFalse(!Files.All(f => f.RemoveChild(root.AppendFile(f.EntityName)) == f.ParentPath)); EAssert.Throws <InvalidOperationException>(() => Assert.AreEqual(root.ParentPath, root.ParentPath)); }
public void RemoveParentTest() { Assert.AreEqual(directoryB.RemoveParent(directoryB), root); Assert.AreEqual(fileB.RemoveParent(directoryA), FileSystemPath.Parse("/fileb.txt")); Assert.AreEqual(root.RemoveParent(root), root); Assert.AreEqual(directoryB.RemoveParent(root), directoryB); EAssert.Throws <ArgumentException>(() => fileB.RemoveParent(FileSystemPath.Parse("/nonexistantparent/"))); EAssert.Throws <ArgumentException>(() => fileB.RemoveParent(FileSystemPath.Parse("/nonexistantparent"))); EAssert.Throws <ArgumentException>(() => fileB.RemoveParent(FileSystemPath.Parse("/fileb.txt"))); EAssert.Throws <ArgumentException>(() => fileB.RemoveParent(FileSystemPath.Parse("/directorya"))); }
public void AppendDirectoryTest() { foreach (var d in Directories) { Assert.IsTrue(d.AppendDirectory("dir").IsDirectory); } foreach (var d in Directories) { Assert.IsTrue(d.AppendDirectory("dir").EntityName == "dir"); } foreach (var d in Directories) { Assert.IsTrue(d.AppendDirectory("dir").ParentPath == d); } EAssert.Throws <InvalidOperationException>(() => fileA.AppendDirectory("dir")); EAssert.Throws <ArgumentException>(() => root.AppendDirectory("dir/dir")); }
public void AppendFileTest() { foreach (var d in Directories) { Assert.IsTrue(d.AppendFile("file").IsFile); } foreach (var d in Directories) { Assert.IsTrue(d.AppendFile("file").EntityName == "file"); } foreach (var d in Directories) { Assert.IsTrue(d.AppendFile("file").ParentPath == d); } EAssert.Throws <InvalidOperationException>(() => fileA.AppendFile("file")); EAssert.Throws <ArgumentException>(() => directoryA.AppendFile("dir/file")); }