コード例 #1
0
        public void GlobCompilesToExpectedRegex(Case testCase)
        {
            var compiler = new GlobToRegexCompiler();
            var regex    = compiler.CompileRegex(testCase.Glob, testCase.Casing);

            Assert.That(regex.ToString(), Is.EqualTo(testCase.ExpectedRegex));
        }
コード例 #2
0
        public void InvalidGlobGeneratesException(ErrorCase testCase)
        {
            var compiler = new GlobToRegexCompiler();

            var exception = Assert.Throws <GlobFormatException>(() => compiler.CompileRegex(testCase.Glob, FileSystemCasing.CaseSensitive));

            Assert.That(exception.Message, Is.EqualTo(testCase.ErrorMessage));
            Assert.That(exception.ErrorPosition, Is.EqualTo(testCase.ErrorPosition));
        }
コード例 #3
0
        public void GlobRejectsExpectedPaths(Case testCase)
        {
            var compiler = new GlobToRegexCompiler();
            var regex    = compiler.CompileRegex(testCase.Glob, testCase.Casing);

            Assert.Multiple(() => {
                foreach (var path in testCase.ShouldNotMatch)
                {
                    Assert.That(regex.IsMatch(path), Is.False);
                }
            });
        }
コード例 #4
0
        public void DoesNotMapExcludedPath()
        {
            var builder = new StorageHierarchiesBuilder(new StubFileSystemApi());
            var root    = builder.CreateNode(@"C:\Root", FileSystemCasing.CasePreservingInsensitive);

            builder.AddNamedRoot("Root", root);
            var regex = new GlobToRegexCompiler().CompileRegex("**/.caber/**", FileSystemCasing.CaseSensitive);

            builder.AddFilter(root, new RelativePathMatcher(regex, FilterRule.Exclude));
            var storage = builder.BuildHierarchies();

            var qualifiedPath = new QualifiedPath(root, RelativePath.CreateFromSegments(".caber", "tempfile"));

            Assert.That(storage.MapToAbstractPath(qualifiedPath), Is.Null);
        }