Example #1
0
        public void CopyFromWithExistingDest()
        {
            // Setup
            var pathTree = new PathTree <string>();
            var source   = pathTree.CreateFile(@"x:\directory\File.bmp", "Value");
            var file     = pathTree.CreateFile(@"x:\directory\File2.bmp", "Value2");

            // Execute
            file.CopyFrom(source);

            // Assert
            Assert.IsTrue(file.Exists);
            Assert.AreEqual("Value", file.Value);
        }
Example #2
0
        public void DeleteNotExistingFile()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            fileSystem.CreateFile(@"x:\directory2\file1.rgb", "Value");
            fileSystem.CreateFile(@"x:\directory2\file2.rgb", "Value");

            // Execute
            fileSystem.DeleteFile(@"x:\directory2\file3.rgb");

            // Assert
            Assert.IsTrue(fileSystem.FileExists(@"x:\directory2\file1.rgb"));
            Assert.IsTrue(fileSystem.FileExists(@"x:\directory2\file2.rgb"));
        }
Example #3
0
        public void GetFilesInDirectory()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            fileSystem.CreateFile(@"x:\mydirectory\file1.dat", "Value");
            fileSystem.CreateFile(@"x:\mydirectory\file2.dat", "Value");
            fileSystem.CreateFile(@"x:\mydirectory\file3.dat", "Value");
            fileSystem.CreateFile(@"x:\mydirectory\otherdirectory\file4.dat", "Value");

            // Execute
            var filePaths = fileSystem.GetFiles(@"X:\MYDIRECTORY");

            // Assert
            Assert.AreEqual(3, filePaths.Length);
        }
Example #4
0
        public void GetFilesWithASearchPattern()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            fileSystem.CreateFile(@"x:\mydirectory\file1.dat", "Value1");
            fileSystem.CreateFile(@"x:\mydirectory\file2.css", "Value2");
            fileSystem.CreateFile(@"x:\mydirectory\file3.dat", "Value3");
            fileSystem.CreateFile(@"x:\mydirectory\otherdirectory\file4.dat", "Value4");

            // Execute
            var filePaths = fileSystem.GetFiles(@"X:\MYDIRECTORY", "*.dat");

            // Assert
            Assert.AreEqual(2, filePaths.Length);
        }
Example #5
0
        public void GetChildFilesBySearchPattern()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            fileSystem.CreateFile(@"x:\mydirectory\file1.dat", "Value");
            fileSystem.CreateFile(@"x:\mydirectory\file2.dat", "Value");
            fileSystem.CreateFile(@"x:\mydirectory\file3.css", "Value");
            fileSystem.CreateFile(@"x:\mydirectory\otherdirectory\file4.dat", "Value");
            var directory = new PathDirectory <string>(fileSystem, @"x:\mydirectory");

            // Execute
            var filePaths = directory.Files("*.css");

            // Assert
            Assert.AreEqual(1, filePaths.Count());
        }
Example #6
0
        public void CreateFileWithNullStats()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            // Execute
            fileSystem.CreateFile(a_path: @"X:\Directory\File.dat", a_value: null);
        }
Example #7
0
        public void CreateFileWithNull()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            // Execute
            fileSystem.CreateFile(a_path: null, a_value: "Value");
        }
Example #8
0
        public void CopyToWithNullDest()
        {
            // Setup
            var pathTree = new PathTree <string>();
            var file     = pathTree.CreateFile(@"x:\directory\File.bmp", "Value");

            // Execute
            file.CopyTo(a_dest: null);
        }
Example #9
0
        public void CustomTest_I()
        {
            var fileSystem = new PathTree <string>();

            fileSystem.CreateDirectory(@"\Root\Directory");
            fileSystem.CreateDirectory(@"\Root\Directory\Sub1");
            fileSystem.CreateDirectory(@"\Root\Directory\Sub2");
            fileSystem.CreateDirectory(@"\Root\Directory\Sub3");
            fileSystem.CreateFile(@"\Root\Directory\File1.hsf", "Value");
            fileSystem.CreateFile(@"\Root\Directory\File2.hsf", "Value");
            fileSystem.CreateFile(@"\Root\Directory\File3.hsf", "Value");

            var directory = new PathDirectory <string>(fileSystem, @"\");

            var result = directory.Directory(@"Root\Directory\Sub1").Exists;

            Assert.IsTrue(result);
        }
Example #10
0
        public void GetFileStatsWithNullpath()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            fileSystem.CreateFile(@"X:\Directory\File.dat", "Value");

            // Execute
            fileSystem.GetLeafValue(a_path: null);
        }
Example #11
0
        public void CopyInOnNotExistingDirectory()
        {
            // Setup
            var fileSystem = new PathTree <string>();
            var directory  = new PathDirectory <string>(@"\directory");
            var file       = fileSystem.CreateFile(@"\file1.dat", "Value");

            // Execute
            directory.CopyIn(file);
        }
Example #12
0
        public void CopyInOnNotExistingDirectory()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            var directory = new PathDirectory<string>(@"\directory");
            var file = fileSystem.CreateFile(@"\file1.dat", "Value");

            // Execute
            directory.CopyIn(file);
        }
Example #13
0
        public void GetFilePathByName()
        {
            // Setup
            var created      = DateTime.UtcNow;
            var lastModified = DateTime.UtcNow;
            var fileSystem   = new PathTree <string>();

            fileSystem.CreateFile(@"x:\mydirectory\file1.dat", "Value1");
            fileSystem.CreateFile(@"x:\mydirectory\file2.dat", "Value2");
            fileSystem.CreateFile(@"x:\mydirectory\file3.dat", "Value3");
            fileSystem.CreateFile(@"x:\mydirectory\otherdirectory\file4.dat", "Value4");
            var directory = new PathDirectory <string>(fileSystem, @"x:\mydirectory");

            // Execute
            var result = directory.FilePath("File1.dat");

            // Assert
            Assert.AreEqual(@"x:\mydirectory\File1.dat", result);
        }
Example #14
0
        public void CopyToWithNullCopier()
        {
            // Setup
            var mockCopier = new Mock <IFileCopier <PathFile <string>, TestFile> >();
            var pathTree   = new PathTree <string>();
            var file       = pathTree.CreateFile(@"x:\directory\File.dat", "Value");
            var dest       = new TestFile(@"C:\temp\test.dat");

            // Execute
            file.CopyTo(a_dest: dest, a_fileCopier: null);
        }
Example #15
0
        public void CopyInWithNullFile()
        {
            // Setup
            var fileSystem = new PathTree <string>();
            var directory  = fileSystem.CreateDirectory(@"\directory");

            fileSystem.CreateFile(@"\file1.dat", "Value");

            // Execute
            directory.CopyIn(a_file: null);
        }
Example #16
0
        public void CreateFileOnEmptyRoot()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            // Execute
            fileSystem.CreateFile(@"File.dat", "Value");

            // Assert
            Assert.IsTrue(fileSystem.FileExists(@"File.dat"));
        }
Example #17
0
        public void CreateFileOnEmptyRoot()
        {
            // Setup
            var fileSystem = new PathTree<string>();

            // Execute
            fileSystem.CreateFile(@"File.dat", "Value");

            // Assert
            Assert.IsTrue(fileSystem.FileExists(@"File.dat"));
        }
Example #18
0
        public void EmptyDirectory()
        {
            // Setup
            var fileSystem = new PathTree <string>();
            var directory  = fileSystem.CreateDirectory(@"\directory");

            fileSystem.CreateDirectory(@"\directory\child1");
            fileSystem.CreateDirectory(@"\directory\child2");
            fileSystem.CreateDirectory(@"\directory\child3");
            fileSystem.CreateFile(@"\directory\file1.dat", "Value1");
            fileSystem.CreateFile(@"\directory\file2.dat", "Value2");
            fileSystem.CreateFile(@"\directory\file3.dat", "Value3");
            fileSystem.CreateFile(@"\directory\child2\fileA.dat", "ValueA");
            fileSystem.CreateFile(@"\directory\child2\fileB.dat", "ValueB");
            fileSystem.CreateFile(@"\directory\child2\fileC.dat", "ValueC");

            // Execute
            directory.Empty();

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists(@"\directory"));
            Assert.IsFalse(fileSystem.DirectoryExists(@"\directory\child1"));
            Assert.IsFalse(fileSystem.DirectoryExists(@"\directory\child2"));
            Assert.IsFalse(fileSystem.DirectoryExists(@"\directory\child3"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\file1.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\file2.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\file3.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\child2\fileA.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\child2\fileB.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\child2\fileC.dat"));
        }
Example #19
0
        public void FileExists()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            fileSystem.CreateFile(@"X:\Directory\File.dat", "Value");

            // Execute
            var result = fileSystem.FileExists(@"x:\directory\file.DAT");

            // Assert
            Assert.IsTrue(result);
        }
Example #20
0
        public void CallExistsWithExistingFile()
        {
            // Setup
            var path = "\\file\\does\\exist.dat";
            var pathTree = new PathTree<string>();
            pathTree.CreateFile(path, "Value");
            var file = new PathFile<string>(pathTree, path);

            // Execute
            var result = file.Exists;

            // Assert
            Assert.IsTrue(result);
        }
Example #21
0
        public void CreateFile()
        {
            // Setup
            var created = DateTime.UtcNow;
            var lastModified = DateTime.UtcNow;
            var fileSystem = new PathTree<string>();

            // Execute
            fileSystem.CreateFile(@"X:\Directory\File.dat", "Value");

            // Assert
            Assert.IsTrue(fileSystem.FileExists(@"X:\Directory\File.dat"));
            Assert.AreEqual("Value", fileSystem.GetLeafValue(@"X:\Directory\File.dat"));
        }
Example #22
0
        public void CopyTo()
        {
            // Setup
            var pathTree = new PathTree <string>();
            var file     = pathTree.CreateFile(@"x:\directory\File.bmp", "Value");
            var dest     = new PathFile <string>(pathTree, @"x:\directory\file2.bmp");

            // Execute
            file.CopyTo(dest);

            // Assert
            Assert.IsTrue(dest.Exists);
            Assert.AreEqual("Value", dest.Value);
        }
Example #23
0
        public void CreateFile()
        {
            // Setup
            var created      = DateTime.UtcNow;
            var lastModified = DateTime.UtcNow;
            var fileSystem   = new PathTree <string>();

            // Execute
            fileSystem.CreateFile(@"X:\Directory\File.dat", "Value");

            // Assert
            Assert.IsTrue(fileSystem.FileExists(@"X:\Directory\File.dat"));
            Assert.AreEqual("Value", fileSystem.GetLeafValue(@"X:\Directory\File.dat"));
        }
Example #24
0
        public void CopyToWithCopier()
        {
            // Setup
            var mockCopier = new Mock <IFileCopier <PathFile <string>, TestFile> >();
            var pathTree   = new PathTree <string>();
            var file       = pathTree.CreateFile(@"x:\directory\File.dat", "Value");
            var dest       = new TestFile(@"C:\temp\test.dat");

            // Execute
            file.CopyTo(dest, mockCopier.Object);

            // Assert
            mockCopier.Verify(i => i.Copy(file, dest), Times.Once);
        }
Example #25
0
        public void CallExistsWithExistingFile()
        {
            // Setup
            var path     = "\\file\\does\\exist.dat";
            var pathTree = new PathTree <string>();

            pathTree.CreateFile(path, "Value");
            var file = new PathFile <string>(pathTree, path);

            // Execute
            var result = file.Exists;

            // Assert
            Assert.IsTrue(result);
        }
Example #26
0
        public void GetDirectoriesWithSearchPattern()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            fileSystem.CreateDirectory(@"x:\mydirectory\directory1");
            fileSystem.CreateDirectory(@"x:\mydirectory\directory2\child");
            fileSystem.CreateFile(@"x:\mydirectory\directory3\file.rgb", "Value");

            // Execute
            var directoryPaths = fileSystem.GetDirectories(@"X:\MYDIRECTORY", "*1");

            // Assert
            Assert.AreEqual(1, directoryPaths.Length);
        }
Example #27
0
        public void GetDirectoryInRoot()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            fileSystem.CreateDirectory(@"x:\directory1");
            fileSystem.CreateDirectory(@"x:\directory2\child");
            fileSystem.CreateFile(@"x:\directory3\file.rgb", "Value");

            // Execute
            var directoryPaths = fileSystem.GetDirectories(@"X:\");

            // Assert
            Assert.AreEqual(3, directoryPaths.Length);
        }
Example #28
0
        public void GetLeafValue()
        {
            // Setup
            var created      = DateTime.UtcNow;
            var lastModified = DateTime.UtcNow;
            var fileSystem   = new PathTree <string>();

            fileSystem.CreateFile(@"X:\Directory\File.dat", "Value");

            // Execute
            var result = fileSystem.GetLeafValue(@"X:\Directory\File.dat");

            // Assert
            Assert.AreEqual("Value", result);
        }
Example #29
0
        public void GetChildDirectories()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            fileSystem.CreateDirectory(@"x:\mydirectory\directory1");
            fileSystem.CreateDirectory(@"x:\mydirectory\directory2\child");
            fileSystem.CreateFile(@"x:\mydirectory\directory3\file.rgb", "Value");
            var directory = new PathDirectory <string>(fileSystem, @"x:\mydirectory");

            // Execute
            var result = directory.Directories();

            // Assert
            Assert.AreEqual(3, result.Count());
        }
Example #30
0
        public void GetNotExistingChildDirectoryByName()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            fileSystem.CreateDirectory(@"x:\mydirectory\directory1");
            fileSystem.CreateDirectory(@"x:\mydirectory\directory2\child");
            fileSystem.CreateFile(@"x:\mydirectory\directory3\file.rgb", "Value");
            var directory = new PathDirectory <string>(fileSystem, @"x:\mydirectory");

            // Execute
            var result = directory.Directory("Directory4");

            // Assert
            Assert.AreEqual("Directory4", result.Name);
            Assert.IsFalse(result.Exists);
        }
Example #31
0
        public void CopyIn()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            var directory = fileSystem.CreateDirectory(@"\directory");
            var file = fileSystem.CreateFile(@"\file1.dat", "Value");

            // Execute
            var result = directory.CopyIn(file);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Exists);
            Assert.AreEqual(@"\directory\file1.dat", result.Path);
            Assert.IsTrue(fileSystem.FileExists(@"\directory\file1.dat"));
            Assert.IsInstanceOfType(result, typeof (PathFile<string>));
            Assert.AreSame(fileSystem, (result as PathFile<string>)?.FileSystem);
        }
Example #32
0
        public void DeleteDirectory()
        {
            // Setup
            var fileSystem = new PathTree <string>();

            fileSystem.CreateDirectory(@"x:\directory1");
            fileSystem.CreateDirectory(@"X:\DIRECTORY2\CHILD");
            fileSystem.CreateFile(@"x:\directory2\file.rgb", "Value");

            // Execute
            fileSystem.DeleteDirectory(@"x:\directory2");

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists(@"x:\directory1"));
            Assert.IsFalse(fileSystem.DirectoryExists((@"x:\directory2")));
            Assert.IsFalse(fileSystem.DirectoryExists(@"x:\directory2\child"));
            Assert.IsFalse(fileSystem.FileExists(@"x:\directory2\file.rgb"));
        }
Example #33
0
        public void CopyIn()
        {
            // Setup
            var fileSystem = new PathTree <string>();
            var directory  = fileSystem.CreateDirectory(@"\directory");
            var file       = fileSystem.CreateFile(@"\file1.dat", "Value");

            // Execute
            var result = directory.CopyIn(file);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Exists);
            Assert.AreEqual(@"\directory\file1.dat", result.Path);
            Assert.IsTrue(fileSystem.FileExists(@"\directory\file1.dat"));
            Assert.IsInstanceOfType(result, typeof(PathFile <string>));
            Assert.AreSame(fileSystem, (result as PathFile <string>)?.FileSystem);
        }
Example #34
0
        public void DeleteNotExistingDirectory()
        {
            // Setup
            var root       = Path.GetPathRoot(Environment.SystemDirectory);
            var fileSystem = new PathTree <string>();

            fileSystem.CreateDirectory($@"{root}directory1");
            fileSystem.CreateDirectory($@"{root}directory2\child");
            fileSystem.CreateFile($@"{root}directory2\file.rgb", "Value");

            // Execute
            fileSystem.DeleteDirectory(@"\directory3");

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists($@"{root}directory1"));
            Assert.IsTrue(fileSystem.DirectoryExists(($@"{root}directory2")));
            Assert.IsTrue(fileSystem.DirectoryExists($@"{root}directory2\child"));
            Assert.IsTrue(fileSystem.FileExists($@"{root}directory2\file.rgb"));
        }
Example #35
0
        public void GetChildFilesBySearchPattern()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            fileSystem.CreateFile(@"x:\mydirectory\file1.dat", "Value");
            fileSystem.CreateFile(@"x:\mydirectory\file2.dat", "Value");
            fileSystem.CreateFile(@"x:\mydirectory\file3.css", "Value");
            fileSystem.CreateFile(@"x:\mydirectory\otherdirectory\file4.dat", "Value");
            var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory");

            // Execute
            var filePaths = directory.Files("*.css");

            // Assert
            Assert.AreEqual(1, filePaths.Count());
        }
Example #36
0
        public void GetFilesInDirectory()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            fileSystem.CreateFile(@"x:\mydirectory\file1.dat", "Value");
            fileSystem.CreateFile(@"x:\mydirectory\file2.dat", "Value");
            fileSystem.CreateFile(@"x:\mydirectory\file3.dat", "Value");
            fileSystem.CreateFile(@"x:\mydirectory\otherdirectory\file4.dat", "Value");

            // Execute
            var filePaths = fileSystem.GetFiles(@"X:\MYDIRECTORY");

            // Assert
            Assert.AreEqual(3, filePaths.Length);
        }
Example #37
0
        public void GetFilePathByName()
        {
            // Setup
            var created = DateTime.UtcNow;
            var lastModified = DateTime.UtcNow;
            var fileSystem = new PathTree<string>();
            fileSystem.CreateFile(@"x:\mydirectory\file1.dat", "Value1");
            fileSystem.CreateFile(@"x:\mydirectory\file2.dat", "Value2");
            fileSystem.CreateFile(@"x:\mydirectory\file3.dat", "Value3");
            fileSystem.CreateFile(@"x:\mydirectory\otherdirectory\file4.dat", "Value4");
            var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory");

            // Execute
            var result = directory.FilePath("File1.dat");

            // Assert
            Assert.AreEqual(@"x:\mydirectory\File1.dat", result);
        }
Example #38
0
        public void GetFilesWithASearchPattern()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            fileSystem.CreateFile(@"x:\mydirectory\file1.dat", "Value1");
            fileSystem.CreateFile(@"x:\mydirectory\file2.css", "Value2");
            fileSystem.CreateFile(@"x:\mydirectory\file3.dat", "Value3");
            fileSystem.CreateFile(@"x:\mydirectory\otherdirectory\file4.dat", "Value4");

            // Execute
            var filePaths = fileSystem.GetFiles(@"X:\MYDIRECTORY", "*.dat");

            // Assert
            Assert.AreEqual(2, filePaths.Length);
        }
Example #39
0
        public void GetFileStatsWithNullpath()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            fileSystem.CreateFile(@"X:\Directory\File.dat", "Value");

            // Execute
            fileSystem.GetLeafValue(a_path: null);
        }
Example #40
0
        public void GetDirectoriesWithSearchPattern()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            fileSystem.CreateDirectory(@"x:\mydirectory\directory1");
            fileSystem.CreateDirectory(@"x:\mydirectory\directory2\child");
            fileSystem.CreateFile(@"x:\mydirectory\directory3\file.rgb", "Value");

            // Execute
            var directoryPaths = fileSystem.GetDirectories(@"X:\MYDIRECTORY", "*1");

            // Assert
            Assert.AreEqual(1, directoryPaths.Length);
        }
Example #41
0
        //[TestMethod]
        public void Temp()
        {
            var fileSystem = new TestFileSystem();
            var pathTree = new PathTree<IFile>();
            pathTree.CreateDirectory(@"urban stuff");
            pathTree.CreateFile(@"urban stuff\urban1.hsf", fileSystem.StageFile(@"x:\root\urban stuff\urban1.hsf"));
            pathTree.CreateFile(@"urban stuff\urban1.jpg", fileSystem.StageFile(@"x:\root\urban stuff\urban1.jpg"));
            pathTree.CreateFile(@"urban stuff\urban2.hsf", fileSystem.StageFile(@"x:\root\urban stuff\urban2.hsf"));
            pathTree.CreateFile(@"urban stuff\urban2.jpg", fileSystem.StageFile(@"x:\root\urban stuff\urban2.jpg"));
            pathTree.CreateFile(@"urban stuff\urban3.hsf", fileSystem.StageFile(@"x:\root\urban stuff\urban3.hsf"));
            pathTree.CreateFile(@"urban stuff\urban3.jpg", fileSystem.StageFile(@"x:\root\urban stuff\urban3.jpg"));
            pathTree.CreateDirectory(@"curved case stuff");
            pathTree.CreateFile(@"curved case stuff\curved1.hsf", fileSystem.StageFile(@"x:\root\curved case stuff\curved1.hsf"));
            pathTree.CreateFile(@"curved case stuff\curved1.jpg", fileSystem.StageFile(@"x:\root\curved case stuff\curved1.jpg"));
            pathTree.CreateFile(@"curved case stuff\curved2.hsf", fileSystem.StageFile(@"x:\root\curved case stuff\curved2.hsf"));
            pathTree.CreateFile(@"curved case stuff\curved2.jpg", fileSystem.StageFile(@"x:\root\curved case stuff\curved2.jpg"));
            pathTree.CreateFile(@"curved case stuff\curved3.hsf", fileSystem.StageFile(@"x:\root\curved case stuff\curved3.hsf"));
            pathTree.CreateFile(@"curved case stuff\curved3.jpg", fileSystem.StageFile(@"x:\root\curved case stuff\curved3.jpg"));

            IFile file = new PathFile<IFile>(pathTree, @"urban stuff\urban1.hsf");
            IFile destination = new PathFile<IFile>(pathTree, @"curved case stuff\carved urban1.esa");

            if (file.Exists)
                file.CopyTo(destination);

            file = file.ChangeExtension(".jpg");
            destination = destination.ChangeExtension(".jpg");

            if (file.Exists)
                file.CopyTo(destination);

            Assert.IsFalse(pathTree.FileExists(@"urban stuff\urban1.hsf"));
            Assert.IsTrue(pathTree.FileExists(@"curved case stuff\carved urban1.esa"));
        }
Example #42
0
        public void CopyToWithNullDest()
        {
            // Setup
            var pathTree = new PathTree<string>();
            var file = pathTree.CreateFile(@"x:\directory\File.bmp", "Value");

            // Execute
            file.CopyTo(a_dest: null);
        }
Example #43
0
        public void GetDirectoryInRoot()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            fileSystem.CreateDirectory(@"x:\directory1");
            fileSystem.CreateDirectory(@"x:\directory2\child");
            fileSystem.CreateFile(@"x:\directory3\file.rgb", "Value");

            // Execute
            var directoryPaths = fileSystem.GetDirectories(@"X:\");

            // Assert
            Assert.AreEqual(3, directoryPaths.Length);
        }
Example #44
0
        public void FileExists()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            fileSystem.CreateFile(@"X:\Directory\File.dat", "Value");

            // Execute
            var result = fileSystem.FileExists(@"x:\directory\file.DAT");

            // Assert
            Assert.IsTrue(result);
        }
Example #45
0
        public void GetNotExistingChildDirectoryByName()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            fileSystem.CreateDirectory(@"x:\mydirectory\directory1");
            fileSystem.CreateDirectory(@"x:\mydirectory\directory2\child");
            fileSystem.CreateFile(@"x:\mydirectory\directory3\file.rgb", "Value");
            var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory");

            // Execute
            var result = directory.Directory("Directory4");

            // Assert
            Assert.AreEqual("Directory4", result.Name);
            Assert.IsFalse(result.Exists);
        }
Example #46
0
        public void CopyInWithNullFile()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            var directory = fileSystem.CreateDirectory(@"\directory");
            fileSystem.CreateFile(@"\file1.dat", "Value");

            // Execute
            directory.CopyIn(a_file: null);
        }
Example #47
0
        //[TestMethod]
        public void Temp()
        {
            var fileSystem = new TestFileSystem();
            var pathTree   = new PathTree <IFile>();

            pathTree.CreateDirectory(@"urban stuff");
            pathTree.CreateFile(@"urban stuff\urban1.hsf", fileSystem.StageFile(@"x:\root\urban stuff\urban1.hsf"));
            pathTree.CreateFile(@"urban stuff\urban1.jpg", fileSystem.StageFile(@"x:\root\urban stuff\urban1.jpg"));
            pathTree.CreateFile(@"urban stuff\urban2.hsf", fileSystem.StageFile(@"x:\root\urban stuff\urban2.hsf"));
            pathTree.CreateFile(@"urban stuff\urban2.jpg", fileSystem.StageFile(@"x:\root\urban stuff\urban2.jpg"));
            pathTree.CreateFile(@"urban stuff\urban3.hsf", fileSystem.StageFile(@"x:\root\urban stuff\urban3.hsf"));
            pathTree.CreateFile(@"urban stuff\urban3.jpg", fileSystem.StageFile(@"x:\root\urban stuff\urban3.jpg"));
            pathTree.CreateDirectory(@"curved case stuff");
            pathTree.CreateFile(@"curved case stuff\curved1.hsf", fileSystem.StageFile(@"x:\root\curved case stuff\curved1.hsf"));
            pathTree.CreateFile(@"curved case stuff\curved1.jpg", fileSystem.StageFile(@"x:\root\curved case stuff\curved1.jpg"));
            pathTree.CreateFile(@"curved case stuff\curved2.hsf", fileSystem.StageFile(@"x:\root\curved case stuff\curved2.hsf"));
            pathTree.CreateFile(@"curved case stuff\curved2.jpg", fileSystem.StageFile(@"x:\root\curved case stuff\curved2.jpg"));
            pathTree.CreateFile(@"curved case stuff\curved3.hsf", fileSystem.StageFile(@"x:\root\curved case stuff\curved3.hsf"));
            pathTree.CreateFile(@"curved case stuff\curved3.jpg", fileSystem.StageFile(@"x:\root\curved case stuff\curved3.jpg"));

            IFile file        = new PathFile <IFile>(pathTree, @"urban stuff\urban1.hsf");
            IFile destination = new PathFile <IFile>(pathTree, @"curved case stuff\carved urban1.esa");

            if (file.Exists)
            {
                file.CopyTo(destination);
            }

            file        = file.ChangeExtension(".jpg");
            destination = destination.ChangeExtension(".jpg");

            if (file.Exists)
            {
                file.CopyTo(destination);
            }

            Assert.IsFalse(pathTree.FileExists(@"urban stuff\urban1.hsf"));
            Assert.IsTrue(pathTree.FileExists(@"curved case stuff\carved urban1.esa"));
        }
Example #48
0
        public void CopyToWithNullCopier()
        {
            // Setup
            var mockCopier = new Mock<IFileCopier<PathFile<string>, TestFile>>();
            var pathTree = new PathTree<string>();
            var file = pathTree.CreateFile(@"x:\directory\File.dat", "Value");
            var dest = new TestFile(@"C:\temp\test.dat");

            // Execute
            file.CopyTo(a_dest: dest, a_fileCopier: null);
        }
Example #49
0
        public void DeleteDirectory()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            fileSystem.CreateDirectory(@"x:\directory1");
            fileSystem.CreateDirectory(@"X:\DIRECTORY2\CHILD");
            fileSystem.CreateFile(@"x:\directory2\file.rgb", "Value");

            // Execute
            fileSystem.DeleteDirectory(@"x:\directory2");

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists(@"x:\directory1"));
            Assert.IsFalse(fileSystem.DirectoryExists((@"x:\directory2")));
            Assert.IsFalse(fileSystem.DirectoryExists(@"x:\directory2\child"));
            Assert.IsFalse(fileSystem.FileExists(@"x:\directory2\file.rgb"));
        }
Example #50
0
        public void EmptyDirectory()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            var directory = fileSystem.CreateDirectory(@"\directory");
            fileSystem.CreateDirectory(@"\directory\child1");
            fileSystem.CreateDirectory(@"\directory\child2");
            fileSystem.CreateDirectory(@"\directory\child3");
            fileSystem.CreateFile(@"\directory\file1.dat", "Value1");
            fileSystem.CreateFile(@"\directory\file2.dat", "Value2");
            fileSystem.CreateFile(@"\directory\file3.dat", "Value3");
            fileSystem.CreateFile(@"\directory\child2\fileA.dat", "ValueA");
            fileSystem.CreateFile(@"\directory\child2\fileB.dat", "ValueB");
            fileSystem.CreateFile(@"\directory\child2\fileC.dat", "ValueC");

            // Execute
            directory.Empty();

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists(@"\directory"));
            Assert.IsFalse(fileSystem.DirectoryExists(@"\directory\child1"));
            Assert.IsFalse(fileSystem.DirectoryExists(@"\directory\child2"));
            Assert.IsFalse(fileSystem.DirectoryExists(@"\directory\child3"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\file1.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\file2.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\file3.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\child2\fileA.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\child2\fileB.dat"));
            Assert.IsFalse(fileSystem.FileExists(@"\directory\child2\fileC.dat"));
        }
Example #51
0
        public void GetChildDirectories()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            fileSystem.CreateDirectory(@"x:\mydirectory\directory1");
            fileSystem.CreateDirectory(@"x:\mydirectory\directory2\child");
            fileSystem.CreateFile(@"x:\mydirectory\directory3\file.rgb", "Value");
            var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory");

            // Execute
            var result = directory.Directories();

            // Assert
            Assert.AreEqual(3, result.Count());
        }
Example #52
0
        public void GetLeafValue()
        {
            // Setup
            var created = DateTime.UtcNow;
            var lastModified = DateTime.UtcNow;
            var fileSystem = new PathTree<string>();
            fileSystem.CreateFile(@"X:\Directory\File.dat", "Value");

            // Execute
            var result = fileSystem.GetLeafValue(@"X:\Directory\File.dat");

            // Assert
            Assert.AreEqual("Value", result);
        }
Example #53
0
        public void CopyToWithExistingDest()
        {
            // Setup
            var pathTree = new PathTree<string>();
            var file = pathTree.CreateFile(@"x:\directory\File.bmp", "Value");
            var dest = pathTree.CreateFile(@"x:\directory\File2.bmp", "Value2");

            // Execute
            file.CopyTo(dest);

            // Assert
            Assert.IsTrue(dest.Exists);
            Assert.AreEqual("Value", dest.Value);
        }
Example #54
0
        public void CreateFileWithNullStats()
        {
            // Setup
            var fileSystem = new PathTree<string>();

            // Execute
            fileSystem.CreateFile(a_path: @"X:\Directory\File.dat", a_value: null);
        }
Example #55
0
        public void DeleteNotExistingFile()
        {
            // Setup
            var fileSystem = new PathTree<string>();
            fileSystem.CreateFile(@"x:\directory2\file1.rgb", "Value");
            fileSystem.CreateFile(@"x:\directory2\file2.rgb", "Value");

            // Execute
            fileSystem.DeleteFile(@"x:\directory2\file3.rgb");

            // Assert
            Assert.IsTrue(fileSystem.FileExists(@"x:\directory2\file1.rgb"));
            Assert.IsTrue(fileSystem.FileExists(@"x:\directory2\file2.rgb"));
        }
Example #56
0
        public void CopyToWithCopier()
        {
            // Setup
            var mockCopier = new Mock<IFileCopier<PathFile<string>, TestFile>>();
            var pathTree = new PathTree<string>();
            var file = pathTree.CreateFile(@"x:\directory\File.dat", "Value");
            var dest = new TestFile(@"C:\temp\test.dat");

            // Execute
            file.CopyTo(dest, mockCopier.Object);

            // Assert
            mockCopier.Verify(i => i.Copy(file, dest), Times.Once);
        }
Example #57
0
        public void DeleteNotExistingDirectory()
        {
            // Setup
            var root = Path.GetPathRoot(Environment.SystemDirectory);
            var fileSystem = new PathTree<string>();
            fileSystem.CreateDirectory($@"{root}directory1");
            fileSystem.CreateDirectory($@"{root}directory2\child");
            fileSystem.CreateFile($@"{root}directory2\file.rgb", "Value");

            // Execute
            fileSystem.DeleteDirectory(@"\directory3");

            // Assert
            Assert.IsTrue(fileSystem.DirectoryExists($@"{root}directory1"));
            Assert.IsTrue(fileSystem.DirectoryExists(($@"{root}directory2")));
            Assert.IsTrue(fileSystem.DirectoryExists($@"{root}directory2\child"));
            Assert.IsTrue(fileSystem.FileExists($@"{root}directory2\file.rgb"));
        }
Example #58
0
        public void CopyFrom()
        {
            // Setup
            var pathTree = new PathTree<string>();
            var source = pathTree.CreateFile(@"x:\directory\File.bmp", "Value");
            var file = new PathFile<string>(pathTree, @"x:\directory\file2.bmp");

            // Execute
            file.CopyFrom(source);

            // Assert
            Assert.IsTrue(file.Exists);
            Assert.AreEqual("Value", file.Value);
        }
Example #59
0
        public void CreateFileWithNull()
        {
            // Setup
            var fileSystem = new PathTree<string>();

            // Execute
            fileSystem.CreateFile(a_path: null, a_value: "Value");
        }
Example #60
0
        public void CustomTest_I()
        {
            var fileSystem = new PathTree<string>();
            fileSystem.CreateDirectory(@"\Root\Directory");
            fileSystem.CreateDirectory(@"\Root\Directory\Sub1");
            fileSystem.CreateDirectory(@"\Root\Directory\Sub2");
            fileSystem.CreateDirectory(@"\Root\Directory\Sub3");
            fileSystem.CreateFile(@"\Root\Directory\File1.hsf", "Value");
            fileSystem.CreateFile(@"\Root\Directory\File2.hsf", "Value");
            fileSystem.CreateFile(@"\Root\Directory\File3.hsf", "Value");

            var directory = new PathDirectory<string>(fileSystem, @"\");

            var result = directory.Directory(@"Root\Directory\Sub1").Exists;

            Assert.IsTrue(result);
        }