public void ConstructPathDirectoryWithNullPath() { // Setup var fileSystem = new PathTree<string>(); // Execute new PathDirectory<string>(a_pathTree: fileSystem, a_path: null); }
public void CreateDirectoryWithNull() { // Setup var fileSystem = new PathTree<string>(); // Execute fileSystem.CreateDirectory(a_path: null); }
public void ChangeExtensionWithNull() { // Setup var pathTree = new PathTree<string>(); var file = new PathFile<string>(pathTree, @"x:\directory\File.txt"); // Execute var result = file.ChangeExtension(a_extension: 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 CreateDirectoryMoreThanOnce() { // Setup var fileSystem = new PathTree<string>(); var path = @"X:\This is bad a directory path"; // Execute fileSystem.CreateDirectory(path); fileSystem.CreateDirectory(path); }
public void CreateFileOnEmptyRoot() { // Setup var fileSystem = new PathTree<string>(); // Execute fileSystem.CreateFile(@"File.dat", "Value"); // Assert Assert.IsTrue(fileSystem.FileExists(@"File.dat")); }
public void CallExistsWithNotExistingFile() { // Setup var pathTree = new PathTree<string>(); var file = new PathFile<string>(pathTree, "\\file\\does\\not\\exist.dat"); // Execute var result = file.Exists; // Assert Assert.IsFalse(result); }
public void ConstructPathDirectory() { // Setup var fileSystem = new PathTree<string>(); // Execute var directory = new PathDirectory<string>(fileSystem, "\\"); // Assert Assert.AreEqual("\\", directory.Path); Assert.AreSame(fileSystem, directory.FileSystem); }
public void ChangeExtensionOnNotRootedFile() { // Setup var pathTree = new PathTree<string>(); var file = new PathFile<string>(pathTree, @"File.txt"); // Execute var result = file.ChangeExtension("jpg"); Assert.AreEqual("File.jpg", result.Name); Assert.AreEqual("File.jpg", result.Path); }
public void CreateDirectory() { // Setup var fileSystem = new PathTree<string>(); var path = @"X:\This is a directory path\"; // Execute fileSystem.CreateDirectory(path); // Assert Assert.IsTrue(fileSystem.DirectoryExists(path)); }
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 GetDirectoriesInRoot() { // Setup var fileSystem = new PathTree <string>(); fileSystem.CreateDirectory("directory1"); fileSystem.CreateDirectory(@"directory2\child"); fileSystem.CreateFile(@"directory3\file.rgb", "Value"); fileSystem.CreateDirectory(@"x:\directory4"); fileSystem.CreateDirectory(@"\directory5"); // Execute var directoryPaths = fileSystem.GetDirectories(""); // Assert Assert.AreEqual(3, directoryPaths.Length); }
/// <summary> /// Gets a settled vertex. /// </summary> public static void GetSettledVertex(this PathTree tree, uint pointer, out uint vertex, out WeightAndDir <float> weightAndDir, out uint hops) { uint data0, data1, data2; tree.Get(pointer, out data0, out data1, out data2); vertex = data0; weightAndDir = new WeightAndDir <float>() { Weight = data1 / WeightFactor, Direction = new Dir() { _val = (byte)(data2 & 3) } }; hops = data2 / 4; }
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 MergePassedPaths() { string currentDirectoryBackup = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(TestDataPath); try { var pathTree = new PathTree(); Assert.True(pathTree.TryAdd("Hoge/Hoge.txt", out string errorMessage1)); Assert.True(pathTree.TryAdd(Path.Combine(TestDataPath, "Hoge"), out string errorMessage2)); Assert.Equal(pathTree.FindNode("Hoge/Hoge.txt"), pathTree.FindNode(Path.Combine(TestDataPath, "Hoge/Hoge.txt"))); } finally { Directory.SetCurrentDirectory(currentDirectoryBackup); } }
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 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 GetsEndpoint() { var tree = new PathTree { Item = new OpenApiPathItem { Operations = { [OperationType.Post] = Sample.Operation(statusCode: HttpStatusCode.NoContent, summary: "An action.") } } }; TryGetEndpoint(tree).Should().BeEquivalentTo(new ActionEndpoint { Description = "An action." }, options => options.IncludingAllRuntimeProperties()); }
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 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 GetsEndpoint() { var tree = new PathTree { Item = new OpenApiPathItem { Operations = { [OperationType.Post] = Sample.Operation(statusCode: HttpStatusCode.Accepted, mimeType: "application/octet-stream", request: new OpenApiSchema(), description: "Upload a file.") } } }; TryGetEndpoint(tree).Should().BeEquivalentTo(new UploadEndpoint { Description = "Upload a file." }, options => options.IncludingAllRuntimeProperties()); }
public string[] GetCardsString() { List <string> cards = new List <string>(); foreach (CD dat in cardSet) { if (dat.ID < 0) { PathTree tree = new PathTree(dat.Parent_FP, dat.Code); cards.Add(string.Format("{0}: {1}", tree, dat.Name)); } else if (dat.ID > 0) { cards.Add(dat.ToString()); } } return(cards.ToArray()); }
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 GetsEndpoint() { var tree = new PathTree { Item = new OpenApiPathItem { Operations = { [OperationType.Get] = Sample.Operation(mimeType: "application/octet-stream", response: new OpenApiSchema(), summary: "A blob."), [OperationType.Put] = Sample.Operation(mimeType: "application/octet-stream", request: new OpenApiSchema()) } } }; TryGetEndpoint(tree).Should().BeEquivalentTo(new BlobEndpoint { Description = "A blob." }, options => options.IncludingAllRuntimeProperties()); }
public void GetsEndpoint() { var tree = new PathTree { Item = new OpenApiPathItem { Operations = { [OperationType.Post] = Sample.Operation(response: Sample.ContactSchema, description: "A producer.") } } }; TryGetEndpoint(tree).Should().BeEquivalentTo(new ProducerEndpoint { Schema = Sample.ContactSchema, Description = "A producer." }, options => options.IncludingAllRuntimeProperties()); }
public override string ToString() { string fp = ""; if (_value is string && PathTree.IsPathTree((string)_value)) { fp = (string)_value; } else if (_value is PathTree) { fp = ((PathTree)_value).ToString(); } string ret = null; if (_value == null) { ret = string.Format("({0} is null)" , Column ); } else if (string.IsNullOrEmpty(_value.ToString())) { return(""); } else { ret = string.Format("({0} = '{1}')" , Column , fp ); } if (_IsFull && !string.IsNullOrEmpty(fp)) { ret += string.Format(" OR ({0} like '{1}.%')" , Column , fp ); ret = string.Format("({0})", ret); } return(ret); }
public void GetsEndpoint() { var tree = new PathTree { Item = new OpenApiPathItem { Operations = { [OperationType.Post] = Sample.Operation(statusCode: HttpStatusCode.NoContent, request: Sample.ContactSchema, description: "A consumer.") } } }; TryGetEndpoint(tree).Should().BeEquivalentTo(new ConsumerEndpoint { Schema = Sample.ContactSchema, Description = "A consumer." }, options => options.IncludingAllRuntimeProperties()); }
public override void Update(GameTime gameTime) { if (paths == null) { paths = PathTree.makeEmptyRoot(); foreach (string key in ResearchTable.category.Keys) { paths.addChildren(PathTree.makePathTree("", key)); } hasChanged = true; } if (hasChanged) { buildPathList(); } Recalculate(); base.Update(gameTime); }
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")); }
private void buildPathList() { internalGrid.Clear(); internalGrid.Left.Set(2, 0); internalGrid.Top.Set(2, 0); internalGrid.Width.Set(0, 1.0f); internalGrid.Height.Set(0, 1.0f); float startX = 2; float startY = 2; UIPathTreeText all = new UIPathTreeText(this, allTree); all.Left.Set(startX, 0); /*all.Top.Set(startY, 0); * startY = startY + 12f;*/ if (selected == null) { selected = allTree; } if (all.tree.SimpleEquals(selected)) { all.TextColor = Color.LimeGreen; } internalGrid.Add(all); List <String> keys = new List <string>(); keys.AddRange(paths.tree.Keys); keys.Sort(); foreach (String key in keys) { buildPathListFromPath(paths.tree[key], ref startY, ref startX); startX -= 4; } Recalculate(); internalGrid.RecalculateChildren(); hasChanged = false; }
public List <LineStrip> GetRouts() { GL.PushMatrix(); Slice lastPolygon = null; foreach (var p in polygons) { var routLast = p.GetLines(Slice.LineType.Outside).First(s => true); routLast.Vertices.Add(routLast.Vertices[0]); routLast.Vertices.Reverse(); Slice obliterate = new Slice(p); obliterate.Offset(-toolRadius * cleanRoutFactor); var routFirst = PathTree.ObliterateSlice(obliterate, toolRadius * 2.0f, true); if (lastPolygon == null) { lastPolygon = p; } bool first = true; foreach (var rout in routFirst) { first = true; foreach (var point in rout.Vertices) { AddRoutPoint(lastPolygon, point, first); first = false; } } first = true; foreach (var point in routLast.Vertices) { AddRoutPoint(p, point, first); first = false; } lastPolygon = p; } GL.PopMatrix(); return(routs); }
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 object[] GetData() { Dictionary <int, ArrayList> dict = new Dictionary <int, ArrayList>(); foreach (CD dat in cardSet) { int root; if (dat.ID < 0) { PathTree tree = new PathTree(dat.Parent_FP, dat.Code); root = tree.Root; if (!dict.ContainsKey(root)) { dict[root] = new ArrayList(); } dict[root].Add(tree); } else if (dat.ID > 0) { root = dat.FP.Root; if (!dict.ContainsKey(root)) { dict[root] = new ArrayList(); } dict[root].Add(dat.ID); } } object[] retList = new object[dict.Count]; int i = 0; foreach (ArrayList al in dict.Values) { if (al.Count > 1) { retList[i++] = al.ToArray(); } else { retList[i++] = al[0]; } } return(retList); }
public void KeepCharactorEncodingOnContentEdit() { RefreshWorkData(); foreach (var path in new[] { Ja_UTF8_CRLF_TxtPath, Ja_UTF8WithBom_CRLF_TxtPath, Ja_SJIS_CRLF_TxtPath, Ja_EUCJP_LF_TxtPath }) { var srcInfo = new TextFileInfo(path); var pathTree = new PathTree(); pathTree.TryAdd(path, out string errorMessage); var commands = new List <Command>(); if (Command.TryParse("s/ほげ/ホゲ/g", out var command)) { commands.Add(command); } var runner = new CommandRunner(commands); runner.Run(pathTree, CommandRunnerActionKind.Replace); var editedInfo = new TextFileInfo(path); Assert.Equal(srcInfo.Encoding, editedInfo.Encoding); Assert.Equal(srcInfo.NewLine, editedInfo.NewLine); } }
public void KeepLastEmptyLineOnContentEdit() { RefreshWorkData(); foreach (var path in new[] { Ja_UTF8_CRLF_TxtPath, Ja_UTF8_CRLF_EndsWithEmptyLine_TxtPath }) { var fileInfo = new TextFileInfo(path); int srcLineCount = fileInfo.ReadAllLines().Count; var pathTree = new PathTree(); pathTree.TryAdd(path, out string errorMessage); var commands = new List <Command>(); if (Command.TryParse("s/ほげ/ホゲ/g", out var command)) { commands.Add(command); } var runner = new CommandRunner(commands); runner.Run(pathTree, CommandRunnerActionKind.Replace); int lineCount = fileInfo.ReadAllLines().Count; Assert.Equal(srcLineCount, lineCount); } }
public void GetsEndpoint() { var tree = new PathTree { Item = new OpenApiPathItem { Operations = { [OperationType.Post] = Sample.Operation(request: Sample.ContactSchema, response: Sample.NoteSchema, summary: "A function.") } } }; TryGetEndpoint(tree).Should().BeEquivalentTo(new FunctionEndpoint { RequestSchema = Sample.ContactSchema, ResponseSchema = Sample.NoteSchema, Description = "A function." }, options => options.IncludingAllRuntimeProperties()); }
public void GetsEndpoint() { var tree = new PathTree { Item = new OpenApiPathItem { Operations = { [OperationType.Get] = Sample.Operation(response: Sample.ContactSchema, summary: "A specific contact."), [OperationType.Put] = Sample.Operation(statusCode: HttpStatusCode.NoContent, request: Sample.ContactSchema), [OperationType.Delete] = Sample.Operation(statusCode: HttpStatusCode.NoContent) } } }; TryGetEndpoint(tree).Should().BeEquivalentTo(new ElementEndpoint { Description = "A specific contact.", Schema = Sample.ContactSchema }, options => options.IncludingAllRuntimeProperties()); }
private void ReloadList() { if (treeRoot != null && (currentParentFP == null || !currentParentFP.IsChildOf(treeRoot))) { currentParentFP = treeRoot; } treeSet.FilterApply(delegate(TD dat) { return(dat.FP.Parent == currentParentFP); } ); cardSet.LoadFilter.Reset(); cardSet.LoadFilter.AddWhere(new FilterTree(currentParentFP, false)); cardSet.Load(); grid.DataSource = null; AddTreeSet(treeSet, cardSet); grid.DataSource = cardSet; treeSet.FilterReset(); Refresh(); }
public void WorkWithSedRegex() { RefreshWorkData(); string path = Ja_UTF8_CRLF_TxtPath; var pathTree = new PathTree(); pathTree.TryAdd(path, out string errorMessage); var commands = new List <Command>(); if (Command.TryParse(@"s/ほ\(げ\)/ホ\1/g", out var command)) { commands.Add(command); } var runner = new CommandRunner(commands); runner.Run(pathTree, CommandRunnerActionKind.Replace); var fileInfo = new TextFileInfo(path); var lines = fileInfo.ReadAllLines(); Assert.Contains(lines, l => l.Contains("ホげ")); }
public void ReplaceDirectoryNameAndDescendant() { RefreshWorkData(); string path = Path.Combine(WorkDataPath, "Hoge"); var pathTree = new PathTree(); pathTree.TryAdd(path, out string errorMessage); var commands = new List <Command>(); if (Command.TryParse("s/Hoge/Piyo/g", out var command)) { commands.Add(command); } var runner = new CommandRunner(commands); runner.Run(pathTree, CommandRunnerActionKind.Replace); Assert.False(Directory.Exists(Path.Combine(WorkDataPath, "Hoge"))); Assert.True(Directory.Exists(Path.Combine(WorkDataPath, "Piyo"))); Assert.False(File.Exists(Path.Combine(WorkDataPath, "Piyo/Hoge.txt"))); Assert.Equal("Piyo", File.ReadAllText(Path.Combine(WorkDataPath, "Piyo/Piyo.txt"))); }
protected override void Edit(BaseDat dat) { try { if (dat == null) { return; } if (((IDat)dat).ID == 0) { string path = ""; path = ((ICardDat)dat).Parent_FP.Parent == null ? "" : ((ICardDat)dat).Parent_FP.Parent.ToString(); if (path != "") { pt = new PathTree(path); } else { pt = null; } ReloadList(); } if (((IDat)dat).ID < 0 && IsChooserMode) { string path = ""; path = ((ICardDat)dat).Parent_FP == null ? "" : ((ICardDat)dat).Parent_FP.ToString() + "."; path += ((ICardDat)dat).Code; pt = new PathTree(path); ReloadList(); } else { base.Edit(dat); } } catch (Exception Ex) { MessageBox.Show(Common.ExMessage(Ex), "ќшибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//[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 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 GetIsEmptyOnNotExistingDirectory() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, "\\directory\\does\\not\\exist"); // Execute var result = directory.IsEmpty; // Assert Assert.IsFalse(result); }
public void GetName() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, "\\this\\is\\a\\directory"); // Execute var result = directory.Name; // Assert Assert.AreEqual("directory", result); }
public void GetChildDirectoryByNameWithNull() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory"); // Execute var result = directory.Directory(a_name: null); }
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 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 CopyInWithNotExistingDirectory() { // Setup var fileSystem = new PathTree<string>(); var directory = fileSystem.CreateDirectory(@"\directory"); var file = new PathFile<string>(fileSystem, @"\noexisty\file1.dat"); // Execute directory.CopyIn(file); }
public void GetChildFilesWithNullSearchPattern() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory"); // Execute directory.Files(a_pattern: null); }
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 GetParent() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, "\\this\\is\\a\\directory"); // Execute var result = directory.Parent; // Assert Assert.IsNotNull(result); Assert.AreEqual("a", result.Name); }
public void GetExistsWithNonexistingFile() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, "\\directory\\does\\not\\exist"); // Execute var result = directory.Exists; // Assert Assert.IsFalse(result); }
public void GetFileByNameWithNull() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory"); // Execute directory.File(a_name: null); }
public void GetExistsOnExistingFile() { // Setup var path = "\\directory\\does\\exist"; var fileSystem = new PathTree<string>(); fileSystem.CreateDirectory(path); var directory = new PathDirectory<string>(fileSystem, path); // Execute var result = directory.Exists; // Assert Assert.IsTrue(result); }
public ReferenceNode(HeapSnapshot map, int type, PathTree pathTree) { this.map = map; this.type = type; TypeName = map.GetTypeName (type); this.pathTree = pathTree; FillRootPaths (); }
public void GetDirectoryPathForNotExistingChild() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory"); // Execute var result = directory.DirectoryPath("Directory4"); // Assert Assert.AreEqual(@"x:\mydirectory\Directory4", result); }
public void GetIsEmptyOnNonemptyDirectory() { // Setup var fileSystem = new PathTree<string>(); var directory = fileSystem.CreateDirectory("\\directory\\does\\not\\exist"); // Execute var result = directory.Parent.IsEmpty; // Assert Assert.IsFalse(result); }
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); }