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)); }
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)); }
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); } }); }
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); }