Пример #1
0
        private static void AssertMatch(MatchKind kind, object[,] expectedResults, bool optimize)
        {
            Debug.WriteLine(string.Format("===================================================================="));
            Debug.WriteLine(string.Format("Verifying expected result for {0} entries with optimization={1}.",
                                          expectedResults.GetLength(0), optimize));
            Debug.WriteLine(string.Format("===================================================================="));
            for (var i = 0; i < expectedResults.GetLength(0); i++)
            {
                var pattern = (string)expectedResults[i, 0];
                var path    = (string)expectedResults[i, 1];
                var result  = (bool)expectedResults[i, 2];
                Debug.WriteLine(string.Format("Matching \"{0}\" pattern \"{1}\" against path \"{2}\" should return {3}.", kind,
                                              pattern, path, result));

                pattern = pattern.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                path    = path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);

                IPathMatcher matcher;
                if (optimize)
                {
                    matcher = new AggregatePathMatcher(Enumerable.Repeat(PatternParser.ParsePattern(pattern), 1));
                }
                else
                {
                    matcher = PatternParser.ParsePattern(pattern);
                }

                if (kind == MatchKind.Directory)
                {
                    Assert.AreEqual(result, matcher.MatchDirectoryName(path, SystemPathComparer.Instance));
                }
                else
                {
                    Assert.AreEqual(result, matcher.MatchFileName(path, SystemPathComparer.Instance));
                }
            }
        }
Пример #2
0
        private List <PathMatcher> CreateMatcherLines()
        {
            var patterns = _configurationSectionProvider.GetSection(_configurationFileName, FilterDirectories);

            return(patterns.Select(x => PatternParser.ParsePattern(x)).ToList());
        }