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 FileExistsWithNullPath() { // Setup var fileSystem = new PathTree <string>(); // Execute var result = fileSystem.FileExists(a_path: 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); }
//[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 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 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 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 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 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 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 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 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 FileExistsWithNullPath() { // Setup var fileSystem = new PathTree<string>(); // Execute var result = fileSystem.FileExists(a_path: 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 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 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")); }