public void Match_EmptyPattern() { var pattern = new PathPattern(""); Assert.IsTrue(pattern.Match("")); Assert.IsFalse(pattern.Match("a")); }
public void Match_DifferentOrderOfRecursiveGeneralPatternWithNonRecursivePattern() { var pattern = new PathPattern("*/**"); Assert.IsFalse(pattern.Match("")); Assert.IsTrue(pattern.Match("a")); Assert.IsTrue(pattern.Match("abcd")); Assert.IsTrue(pattern.Match("ab/cd")); Assert.IsTrue(pattern.Match("ab/cd/efg")); }
public void Match_JustTheGeneralPattern() { var pattern = new PathPattern("**"); Assert.IsTrue(pattern.Match("")); Assert.IsTrue(pattern.Match("/")); Assert.IsTrue(pattern.Match("a")); Assert.IsTrue(pattern.Match("a/b")); Assert.IsTrue(pattern.Match("a/b/c")); Assert.IsTrue(pattern.Match("c/a/b")); Assert.IsTrue(pattern.Match("//")); Assert.IsTrue(pattern.Match("/\\")); Assert.IsTrue(pattern.Match("/\\/")); Assert.IsFalse(pattern.Match("c//a/b")); }
protected bool MatchDeleted(string path) { // Check path if (PathPattern.Match(path)) { // Also check file/folder DOES NOT exists since we might be watching for a folder/file with same path. if (!PathExist(path)) { // Notify CREATED if we had doubts previously if (_mightBeQuicklyDeletedAfterCreate) { RegisterMatchingPath(path); NotifyCreated(path); _mightBeQuicklyDeletedAfterCreate = false; } return(true); } // If file/folder DO exist, there is two possibility: // 1. The path might be used by a different entry type (folder/file). // 2. The entry might have been quickly CREATED after DELETE. // We will wait next events since second case will trigger CREATED after that. _mightBeQuicklyCreatedAfterDelete = true; } // Other case can be reset _mightBeQuicklyDeletedAfterCreate = false; return(false); }
public void Match_JustTheQuestionMarkPattern() { var pattern = new PathPattern("?"); Assert.IsFalse(pattern.Match("")); Assert.IsFalse(pattern.Match("/")); Assert.IsTrue(pattern.Match("a")); Assert.IsTrue(pattern.Match("b")); Assert.IsTrue(pattern.Match("a/")); Assert.IsFalse(pattern.Match("ab")); Assert.IsFalse(pattern.Match("a/b")); Assert.IsFalse(pattern.Match("a/b/c")); Assert.IsFalse(pattern.Match("c/a/b")); }
public void Match_GeneralPatternAtTheStart() { var pattern = new PathPattern("**/a"); Assert.IsTrue(pattern.Match("a")); Assert.IsTrue(pattern.Match("a/")); Assert.IsFalse(pattern.Match("a/b")); Assert.IsFalse(pattern.Match("a/b/c")); Assert.IsTrue(pattern.Match("b/a")); Assert.IsTrue(pattern.Match("c/b/a")); Assert.IsFalse(pattern.Match("b")); Assert.IsFalse(pattern.Match("")); }
public void Match_EndsWithPattern() { var pattern = new PathPattern("**/a?b*c"); Assert.IsFalse(pattern.Match("")); Assert.IsFalse(pattern.Match("a")); Assert.IsFalse(pattern.Match("ab")); Assert.IsFalse(pattern.Match("abc")); Assert.IsTrue(pattern.Match("axbc")); Assert.IsTrue(pattern.Match("yz/axbc")); Assert.IsTrue(pattern.Match("yz/uv/axbc")); Assert.IsFalse(pattern.Match("axbc/uv")); }
public void Match_PathWithGeneralPattern() { var pattern = new PathPattern("C:/a/**/c"); Assert.IsFalse(pattern.Match("C:/a")); Assert.IsTrue(pattern.Match("C:/a/c")); Assert.IsFalse(pattern.Match("C:/ac")); Assert.IsFalse(pattern.Match("C:/a/bc")); Assert.IsFalse(pattern.Match("C:/ab/c")); Assert.IsTrue(pattern.Match("C:/a/x/c")); Assert.IsTrue(pattern.Match("C:/a/x/y/c")); Assert.IsFalse(pattern.Match("C:/a/x/y")); }
public void Match_PathWithOneAsteriskPattern() { var pattern = new PathPattern("C:/a/b*/c"); Assert.IsFalse(pattern.Match("C:/a")); Assert.IsFalse(pattern.Match("C:/a/c")); Assert.IsFalse(pattern.Match("C:/a/x/c")); Assert.IsTrue(pattern.Match("C:/a/b/c")); Assert.IsTrue(pattern.Match("C:/a\\b/c\\")); Assert.IsTrue(pattern.Match("C:/a/bx/c")); Assert.IsTrue(pattern.Match("C:/a/bxy/c")); Assert.IsTrue(pattern.Match("C:/a/bxyz/c")); }
public void Match_PathWithOneQuestionMarkPattern() { var pattern = new PathPattern("C:/a/b?/c"); Assert.IsFalse(pattern.Match("C:/a")); Assert.IsFalse(pattern.Match("C:/a/c")); Assert.IsFalse(pattern.Match("C:/a/x/c")); Assert.IsFalse(pattern.Match("C:/a/b/c")); Assert.IsTrue(pattern.Match("C:/a/bx/c")); Assert.IsTrue(pattern.Match("C:\\a\\bx/c\\")); Assert.IsFalse(pattern.Match("C:/a/bxy/c")); Assert.IsFalse(pattern.Match("C:/a/bxyz/c")); }
public void Match_PathWithoutPattern() { var pattern = new PathPattern("C:/directory/a/b/c"); Assert.IsFalse(pattern.Match("C:/")); Assert.IsFalse(pattern.Match("C:/directory")); Assert.IsFalse(pattern.Match("C:/directory/a")); Assert.IsFalse(pattern.Match("C:/directory/a/b")); Assert.IsTrue(pattern.Match("C:/directory/a/b/c")); Assert.IsTrue(pattern.Match("C:/directory/a/b/c/")); Assert.IsTrue(pattern.Match("C:\\directory\\a\\b\\c")); Assert.IsTrue(pattern.Match("C:\\directory\\a\\b\\c\\")); }
public void Match_JustTheStarPattern() { var pattern = new PathPattern("*"); Assert.IsFalse(pattern.Match("")); Assert.IsFalse(pattern.Match("/")); Assert.IsTrue(pattern.Match("a")); Assert.IsTrue(pattern.Match("a/")); Assert.IsFalse(pattern.Match("a/b")); Assert.IsFalse(pattern.Match("a/b/c")); Assert.IsFalse(pattern.Match("c/a/b")); }
public void Match_CombinedPattern() { var pattern = new PathPattern("C:/a/**/b*/c"); Assert.IsFalse(pattern.Match("C:/a")); Assert.IsFalse(pattern.Match("C:/a/c")); Assert.IsTrue(pattern.Match("C:/a/b/c")); Assert.IsTrue(pattern.Match("C:/a/bx/c")); Assert.IsTrue(pattern.Match("C:/a/bxy/c")); Assert.IsTrue(pattern.Match("C:/a/x/b/c")); Assert.IsFalse(pattern.Match("C:/a/x/b")); }
public void Match_StartsWithPattern() { var pattern = new PathPattern("a?b*c/**"); Assert.IsFalse(pattern.Match("")); Assert.IsFalse(pattern.Match("a")); Assert.IsFalse(pattern.Match("ab")); Assert.IsFalse(pattern.Match("abc")); Assert.IsTrue(pattern.Match("axbc")); Assert.IsTrue(pattern.Match("axbc/yz")); Assert.IsFalse(pattern.Match("abc/yz/uv")); }
public void Match_StarPatternWontMatchEmptyString() { var pattern = new PathPattern("a/*/b"); Assert.IsFalse(pattern.Match("a")); Assert.IsFalse(pattern.Match("a/")); Assert.IsFalse(pattern.Match("a/b")); Assert.IsFalse(pattern.Match("a//b")); Assert.IsFalse(pattern.Match("a\\\\b")); Assert.IsTrue(pattern.Match("a/c/b")); }
public void Match_MultipleGeneralPatternsInSuccession() { var pattern = new PathPattern("a/**/**/b"); Assert.IsFalse(pattern.Match("a")); Assert.IsFalse(pattern.Match("b")); Assert.IsTrue(pattern.Match("a/b")); Assert.IsFalse(pattern.Match("a//b")); Assert.IsFalse(pattern.Match("a///b")); Assert.IsFalse(pattern.Match(@"a\\b")); }
public void Match_RecursiveGeneralPatternWithNonRecursivePattern() { var pattern = new PathPattern("**/*"); Assert.IsFalse(pattern.Match("")); Assert.IsTrue(pattern.Match("a")); Assert.IsTrue(pattern.Match("abcd")); Assert.IsTrue(pattern.Match("ab/cd")); Assert.IsTrue(pattern.Match("ab/cd/efg")); Assert.IsFalse(pattern.Match("a//b")); }
protected bool MatchExisting(string path) => PathPattern.Match(path) && PathExist(path);
public IEnumerable <MockFileSystemWatcher> GetAllMatchingWatchers(string uniquePath) { GetWatcher(uniquePath); return(_watchers.Where(x => PathPattern.Match(uniquePath, x.Key, caseSensitive: true)).Select(x => x.Value).ToArray()); }
public void Match_MultipleGeneralPatterns() { var pattern = new PathPattern("a/**/b/**/c"); Assert.IsFalse(pattern.Match("")); Assert.IsFalse(pattern.Match("a")); Assert.IsFalse(pattern.Match("b")); Assert.IsFalse(pattern.Match("c")); Assert.IsFalse(pattern.Match("a/b")); Assert.IsFalse(pattern.Match("a/c")); Assert.IsFalse(pattern.Match("b/c")); Assert.IsTrue(pattern.Match("a/b/c")); Assert.IsTrue(pattern.Match("a/x/b/c")); Assert.IsTrue(pattern.Match("a/b/x/c")); Assert.IsTrue(pattern.Match("a/x/b/y/c")); Assert.IsTrue(pattern.Match("a/x/z/b/y/w/c")); }