public void Should_be_possible_to_change_regex_in_the_path_to_a_name() { var pathWithFirstRegex = new PathLevelWithRegex(1, ".*", @"c:\.*"); var newPath = pathWithFirstRegex.SubstitutionValueInPattern("Temp"); Assert.AreEqual(@"c:\Temp", newPath, "the path is not expected"); }
public PathLevelWithRegex GetPathWithFirstRegex() { PathLevelWithRegex pathLevelWithRegex = null; string fixedPart = ""; for (int i = 0; i <= this.pathLevels.Count() - 1; i++) { string pathLevel = this.pathLevels[i]; if (!RegexHelper.IsPathLevelARegexPattern(pathLevel.Replace(".", ""))) { fixedPart += String.Format("{0}{1}", pathLevel, this.levelSeparator); } else { fixedPart += pathLevel; if (this.levelSeparator.Equals("/")) { fixedPart = "/" + fixedPart; } return(new PathLevelWithRegex(i, pathLevel, fixedPart)); } } return(pathLevelWithRegex); }
private void AssertPathWithPattern(PathLevelWithRegex itemToAssert, string expectedPathWithPattern, int expectedLevel) { Assert.AreEqual(expectedPathWithPattern, itemToAssert.PathWithPattern, "the path is not expected"); Assert.AreEqual(expectedLevel, itemToAssert.Level, "the path level is not expected"); }
private IEnumerable <string> SubstitutionValueInPattern(List <string> values, PathLevelWithRegex basePath, FilePathRegexInformation regexInformation) { List <string> paths = new List <string>(); foreach (string path in values) { string concatenatedString = regexInformation.ConcatPathWithNextLeveRegex(path, basePath.Level); if (!string.IsNullOrEmpty(concatenatedString)) { paths.Add(concatenatedString); } } return(paths); }