예제 #1
0
 public void ChangeExtensionTest()
 {
     _paths
     .Where(p => p.IsFile)
     .All(p => p.ChangeExtension(".exe").GetExtension() == ".exe");
     EAssert.Throws <ArgumentException>(() => directoryA.ChangeExtension(".exe"));
 }
예제 #2
0
 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"));
 }
예제 #3
0
        public void AppendPathTest()
        {
            Assert.True(Directories.All(p => p.AppendPath(_root) == p));
            Assert.True(Directories.All(p => p.AppendPath("") == p));

            var subpath    = FileSystemPath.Parse("/dir/file");
            var subpathstr = "dir/file";

            foreach (var p in Directories)
            {
                Assert.True(p.AppendPath(subpath).ParentPath.ParentPath == p);
            }
            foreach (var p in Directories)
            {
                Assert.True(p.AppendPath(subpathstr).ParentPath.ParentPath == p);
            }
            foreach (var pa in Directories)
            {
                foreach (var pb in _paths.Where(pb => !pb.IsRoot))
                {
                    Assert.True(pa.AppendPath(pb).IsChildOf(pa));
                }
            }
            // ReSharper disable ReturnValueOfPureMethodIsNotUsed
            EAssert.Throws <InvalidOperationException>(() => _fileA.AppendPath(subpath));
            EAssert.Throws <InvalidOperationException>(() => _fileA.AppendPath(subpathstr));
            EAssert.Throws <ArgumentException>(() => DirectoryA.AppendPath("/rootedpath/"));
            // ReSharper restore ReturnValueOfPureMethodIsNotUsed
        }
예제 #4
0
        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/"));
        }
예제 #5
0
 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());
 }
예제 #6
0
 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"));
 }
예제 #7
0
 public void AppendFileTest()
 {
     Directories.All(d => d.AppendFile("file").IsFile);
     Directories.All(d => d.AppendFile("file").EntityName == "file");
     Directories.All(d => d.AppendFile("file").ParentPath == d);
     EAssert.Throws <InvalidOperationException>(() => fileA.AppendFile("file"));
     EAssert.Throws <ArgumentException>(() => directoryA.AppendFile("dir/file"));
 }
예제 #8
0
 public void AppendDirectoryTest()
 {
     Directories.All(d => d.AppendDirectory("dir").IsDirectory);
     Directories.All(d => d.AppendDirectory("dir").EntityName == "dir");
     Directories.All(d => d.AppendDirectory("dir").ParentPath == d);
     EAssert.Throws <InvalidOperationException>(() => fileA.AppendDirectory("dir"));
     EAssert.Throws <ArgumentException>(() => root.AppendDirectory("dir/dir"));
 }
예제 #9
0
 public void ChangeExtensionTest()
 {
     foreach (var p in _paths.Where(p => p.IsFile))
     {
         Assert.True(p.ChangeExtension(".exe").GetExtension() == ".exe");
     }
     // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
     EAssert.Throws <ArgumentException>(() => DirectoryA.ChangeExtension(".exe"));
 }
예제 #10
0
 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")));
 }
예제 #11
0
 public void GetExtensionTest()
 {
     Assert.Equal("", _fileA.GetExtension());
     Assert.Equal(".txt", _fileB.GetExtension());
     _fileC = FileSystemPath.Parse("/directory.txt/filec");
     Assert.Equal("", _fileC.GetExtension());
     // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
     EAssert.Throws <ArgumentException>(() => DirectoryA.GetExtension());
 }
예제 #12
0
        public void ParentPathTest()
        {
            Assert.True(
                Directories
                .Where(d => d.GetDirectorySegments().Length == 1)
                .All(d => d.ParentPath == _root)
                );

            Assert.False(Files != null && Files.Any(f => f.RemoveChild(_root.AppendFile(f.EntityName)) != f.ParentPath));
            EAssert.Throws <InvalidOperationException>(() => Assert.Equal(_root.ParentPath, _root.ParentPath));
        }
예제 #13
0
 public void RemoveChildTest()
 {
     Assert.Equal(DirectoryA, _fileB.RemoveChild(FileSystemPath.Parse("/fileb.txt")));
     Assert.Equal(DirectoryA, _directoryB.RemoveChild(FileSystemPath.Parse("/directoryb/")));
     Assert.Equal(_root, _directoryB.RemoveChild(_directoryB));
     Assert.Equal(_root, _fileB.RemoveChild(_fileB));
     // ReSharper disable ReturnValueOfPureMethodIsNotUsed
     EAssert.Throws <ArgumentException>(() => DirectoryA.RemoveChild(FileSystemPath.Parse("/nonexistantchild")));
     EAssert.Throws <ArgumentException>(() => DirectoryA.RemoveChild(FileSystemPath.Parse("/directorya")));
     // ReSharper restore ReturnValueOfPureMethodIsNotUsed
 }
예제 #14
0
 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")));
 }
예제 #15
0
        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));
        }
예제 #16
0
 public void RemoveParentTest()
 {
     Assert.Equal(_root, _directoryB.RemoveParent(_directoryB));
     Assert.Equal(FileSystemPath.Parse("/fileb.txt"), _fileB.RemoveParent(DirectoryA));
     Assert.Equal(_root, _root.RemoveParent(_root));
     Assert.Equal(_directoryB, _directoryB.RemoveParent(_root));
     // ReSharper disable ReturnValueOfPureMethodIsNotUsed
     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")));
     // ReSharper restore ReturnValueOfPureMethodIsNotUsed
 }
예제 #17
0
        public void AppendPathTest()
        {
            Directories.All(p => p.AppendPath(root) == p);
            Directories.All(p => p.AppendPath("") == p);

            var subpath    = FileSystemPath.Parse("/dir/file");
            var subpathstr = "dir/file";

            Directories.All(p => p.AppendPath(subpath).ParentPath.ParentPath == p);
            Directories.All(p => p.AppendPath(subpathstr).ParentPath.ParentPath == p);
            Directories.All(pa => _paths.All(pb => pa.AppendPath(pb).IsChildOf(pa)));
            EAssert.Throws <InvalidOperationException>(() => fileA.AppendPath(subpath));
            EAssert.Throws <InvalidOperationException>(() => fileA.AppendPath(subpathstr));
            EAssert.Throws <ArgumentException>(() => directoryA.AppendPath("/rootedpath/"));
        }
예제 #18
0
 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"));
 }
예제 #19
0
 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"));
 }
예제 #20
0
 public void AppendFileTest()
 {
     foreach (var d in Directories)
     {
         Assert.True(d.AppendFile("file").IsFile);
     }
     foreach (var d in Directories)
     {
         Assert.True(d.AppendFile("file").EntityName == "file");
     }
     foreach (var d in Directories)
     {
         Assert.True(d.AppendFile("file").ParentPath == d);
     }
     // ReSharper disable ReturnValueOfPureMethodIsNotUsed
     EAssert.Throws <InvalidOperationException>(() => _fileA.AppendFile("file"));
     EAssert.Throws <ArgumentException>(() => DirectoryA.AppendFile("dir/file"));
     // ReSharper restore ReturnValueOfPureMethodIsNotUsed
 }