public void TestGetPathsAtRootWithExtraSlashs() { var uri = @"C:\\"; var paths = ParsePath.GetPaths(uri); Assert.AreEqual("C:", paths[0]); }
public void TestGetPathsAtRoot() { var uri = @"C:"; var paths = ParsePath.GetPaths(uri); Assert.AreEqual("C:", paths[0]); }
public void TestGetDepthForDirectoryWithDoubleSlashes() { var uri = @"C:\\RootDir\\"; var depth = ParsePath.GetDepth(uri); Assert.AreEqual(1, depth); }
public void TestGetDepthForFileInSubDirectory() { var uri = @"C:\RootDir\SubDir\\FileName.ext"; var depth = ParsePath.GetDepth(uri); Assert.AreEqual(3, depth); }
public void TestGetDepthAtRoot() { var uri = @"C:"; var depth = ParsePath.GetDepth(uri); Assert.AreEqual(0, depth); }
public void TestGetDepthForSubDirectory() { var uri = @"C:\\RootDir\\SubDir"; var depth = ParsePath.GetDepth(uri); Assert.AreEqual(2, depth); }
public void TestGetDepthAtRootWithExtraSlashs() { var uri = @"C:\\"; var depth = ParsePath.GetDepth(uri); Assert.AreEqual(0, depth); }
public void TestGetDepthInvalid() { var uri = @""; var depth = ParsePath.GetDepth(uri); Assert.AreEqual(-1, depth); }
public void TestGetPathsEmpty() { var uri = @""; var paths = ParsePath.GetPaths(uri); Assert.AreEqual(0, paths.Length); }
public void TestHasSameRootNotSameRootAtRoot() { var uri1 = @"C:\"; var uri2 = @"D:\Directory2\Subdirectory"; var same = ParsePath.HasSameRoot(uri1, uri2); Assert.IsFalse(same); }
public void TestHasSameRootAtRootWithSubDirectories() { var uri1 = @"C:\Directory1\Subdirectory"; var uri2 = @"C:\Directory2\Subdirectory"; var same = ParsePath.HasSameRoot(uri1, uri2); Assert.IsTrue(same); }
public void TestHasSameRootAtRootWithDirectory1And2() { var uri1 = @"C:\Directory1"; var uri2 = @"C:\Directory2"; var same = ParsePath.HasSameRoot(uri1, uri2); Assert.IsTrue(same); }
public void TestHasSameRootAtRootWithSlash1And2() { var uri1 = @"C:\"; var uri2 = @"C:\"; var same = ParsePath.HasSameRoot(uri1, uri2); Assert.IsTrue(same); }
public void TestHasSameRootAtRoot() { var uri1 = @"C:"; var uri2 = @"C:"; var same = ParsePath.HasSameRoot(uri1, uri2); Assert.IsTrue(same); }
public void TestParseCommonPathRootWithDirectory1And2() { var uri1 = @"C:\Directory1"; var uri2 = @"C:\Directory2\\"; var path = ParsePath.GetCommonPath(uri1, uri2); Assert.AreEqual(@"C:", path); }
public void TestGetPathsForDirectoryWithDoubleSlashes() { var uri = @"C:\\RootDir\\"; var paths = ParsePath.GetPaths(uri); Assert.AreEqual("C:", paths[0]); Assert.AreEqual("RootDir", paths[1]); }
public void TestParseCommonPathRoot() { var uri1 = @"C:"; var uri2 = @"C:"; var path = ParsePath.GetCommonPath(uri1, uri2); Assert.AreEqual(@"C:", path); }
public CreateChecksumsExecute(CreateChecksumsRequest request) : base(request) { // set up truncation if (!String.IsNullOrWhiteSpace(Request.RelativeToUri)) { _truncateLength = ParsePath.FixUri(Request.RelativeToUri, true).Length; } }
public void TestParseCommonPathRootWithCommonRootDirectory() { var uri1 = @"C:\Directory\Sub1\Child1"; var uri2 = @"C:\Directory\Sub2\Child2\"; var path = ParsePath.GetCommonPath(uri1, uri2); Assert.AreEqual(@"C:\Directory", path); }
public void TestParseCommonPathRootWithCommonRootDirectoryDifferentLevels() { var uri1 = @"C:\Directory\Sub1\Child1\"; var uri2 = @"C:\Directory\Sub2\Child2\Grandchild2"; var path = ParsePath.GetCommonPath(uri1, uri2); Assert.AreEqual(@"C:\Directory", path); }
public void TestParseCommonPathRootInvalidWithDirectory() { var uri1 = @"C:\Same"; var uri2 = @"D:\Same"; var path = ParsePath.GetCommonPath(uri1, uri2); Assert.AreEqual(@"", path); }
public void TestGetPathsForDirectory() { var uri = @"C:\RootDir"; var paths = ParsePath.GetPaths(uri); Assert.AreEqual("C:", paths[0]); Assert.AreEqual("RootDir", paths[1]); }
private void Validate(CreateChecksumsExecute execute) { // check input uri var dir = execute.Request.DirectoryUri; if (String.IsNullOrWhiteSpace(dir)) { throw new Exception($"Input URI is not provided"); } if (!Directory.Exists(dir)) { throw new Exception($"Input URI '{dir}' is not accessible"); } // check output uri var root = execute.Request.RelativeToUri; if (!String.IsNullOrWhiteSpace(root)) { if (!Directory.Exists(execute.Request.RelativeToUri)) { throw new Exception($"Output URI '{root}' is not accessible"); } if (!ParsePath.IsSamePath(root, dir) && !ParsePath.IsAncestor(root, dir)) { throw new Exception($"Input URI '{root}' is not ancestor of output URI '{dir}'"); } } // prepare output files var now = DateTime.Now; var ext = execute.Request.HashType.ToString().ToLowerInvariant(); var path = String.IsNullOrWhiteSpace(root) ? dir : root; var name = $"_{now:yyyyMMdd}-{now:HHmmss}"; // check hash file var hash = Path.Combine(path, $"{name}.{ext}"); if (File.Exists(hash)) { throw new Exception($"Output hash file '{name}' already exists"); } execute.OutputFileUri = hash; // check excel file if (execute.Request.Report) { var excel = Path.Combine(path, $"{name}.xlsx"); if (File.Exists(excel)) { throw new Exception($"Output report file '{name}' already exists"); } execute.ReportFileUri = excel; } }
public void TestGetPathsForFileInSubDirectory() { var uri = @"C:\RootDir\SubDir\\FileName.ext"; var paths = ParsePath.GetPaths(uri); Assert.AreEqual("C:", paths[0]); Assert.AreEqual("RootDir", paths[1]); Assert.AreEqual("SubDir", paths[2]); Assert.AreEqual("FileName.ext", paths[3]); }
/// <summary> /// 解析物品Json /// </summary> public void ParseItemJson() { loadNumber = 1; /* * TextAsset textAsset = Resources.Load<TextAsset>("json"); * string itemsJson = textAsset.text; * //Debug.Log(textAsset.text); * JsonData jj = JsonMapper.ToObject(itemsJson); * * //以后加入多条轨迹,得多维数组 * for (int j = 0; j < jj["date"].Count; j++) * { * itemList = new List<Item>();//代表一条轨迹 * * for (int i = 0; i < jj["date"][j].Count; i++) * { * * x = float.Parse((jj["date"][j][i]["x"].ToString())); * y = float.Parse((jj["date"][j][i]["y"].ToString())); * Item item = new Item(x, y); * itemList.Add(item); * * } * guiJi.instant().guiJiDict.Add("gj" + (j + 1), itemList); * } */ ParsePath _path = new ParsePath(); List <Vector2[]> pathes = _path.JieXiPath(); Debug.Log("轨迹:" + pathes.Count); if (pathes == null) { return; } for (int k = 0; k < pathes.Count; ++k) { itemList = new List <Item>(); //代表一条轨迹 for (int k1 = 0; k1 < pathes[k].Length; ++k1) { Item item = new Item(pathes[k][k1].x, pathes[k][k1].y); itemList.Add(item); } guiJi.instant().guiJiDict.Add("gj" + (k + 1), itemList); } }
public static async Task Test_ParsePath() { //Prepare ParsePath cmd = new ParsePath(); var mockProfile = new Mock <IProfile>(); var mockModel = new Mock <IEntryModel>(); mockProfile.Setup(p => p.ParseAsync(dummyPath)).Returns(Task.FromResult <IEntryModel>(mockModel.Object)); ParameterDic pd = new ParameterDic() { { cmd.ProfileKey, mockProfile.Object }, { cmd.PathKey, dummyPath } }; //Action await cmd.ExecuteAsync(pd); //Assert Assert.IsTrue(pd.ContainsKey(cmd.DestinationKey)); Assert.AreEqual(mockModel.Object, pd[cmd.DestinationKey]); }
public VariableTree(ParsePath i_parsePath, char seperator) { parsePath = i_parsePath; pathSeperator = seperator; }