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); }
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")); }
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); }
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); }
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()); }
public void CreateFileWithNullStats() { // Setup var fileSystem = new PathTree <string>(); // Execute fileSystem.CreateFile(a_path: @"X:\Directory\File.dat", a_value: null); }
public void CreateFileWithNull() { // Setup var fileSystem = new PathTree <string>(); // Execute fileSystem.CreateFile(a_path: null, a_value: "Value"); }
public void CopyToWithNullDest() { // Setup var pathTree = new PathTree <string>(); var file = pathTree.CreateFile(@"x:\directory\File.bmp", "Value"); // Execute file.CopyTo(a_dest: null); }
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); }
public void GetFileStatsWithNullpath() { // Setup var fileSystem = new PathTree <string>(); fileSystem.CreateFile(@"X:\Directory\File.dat", "Value"); // Execute fileSystem.GetLeafValue(a_path: null); }
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); }
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); }
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); }
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); }
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); }
public void CreateFileOnEmptyRoot() { // Setup var fileSystem = new PathTree <string>(); // Execute fileSystem.CreateFile(@"File.dat", "Value"); // Assert Assert.IsTrue(fileSystem.FileExists(@"File.dat")); }
public void CreateFileOnEmptyRoot() { // Setup var fileSystem = new PathTree<string>(); // Execute fileSystem.CreateFile(@"File.dat", "Value"); // Assert Assert.IsTrue(fileSystem.FileExists(@"File.dat")); }
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")); }
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); }
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); }
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")); }
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); }
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")); }
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); }
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); }
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); }
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); }
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); }
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()); }
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); }
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); }
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")); }
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); }
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")); }
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()); }
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); }
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); }
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); }
public void GetFileStatsWithNullpath() { // Setup var fileSystem = new PathTree<string>(); fileSystem.CreateFile(@"X:\Directory\File.dat", "Value"); // Execute fileSystem.GetLeafValue(a_path: null); }
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); }
//[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")); }
public void CopyToWithNullDest() { // Setup var pathTree = new PathTree<string>(); var file = pathTree.CreateFile(@"x:\directory\File.bmp", "Value"); // Execute file.CopyTo(a_dest: null); }
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); }
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); }
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); }
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); }
//[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")); }
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); }
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")); }
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")); }
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()); }
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); }
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); }
public void CreateFileWithNullStats() { // Setup var fileSystem = new PathTree<string>(); // Execute fileSystem.CreateFile(a_path: @"X:\Directory\File.dat", a_value: null); }
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")); }
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); }
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")); }
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); }
public void CreateFileWithNull() { // Setup var fileSystem = new PathTree<string>(); // Execute fileSystem.CreateFile(a_path: null, a_value: "Value"); }
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); }