public void EmptyCollectionWhenNoFilesPresent()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("alpha.txt")
                .Execute();

            scenario.AssertExact();
        }
        public void FolderNamesAreTraversed()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("beta/alpha.txt")
                .Files("beta/alpha.txt")
                .Execute();

            scenario.AssertExact("beta/alpha.txt");
        }
        public void MismatchedFileIsIgnored()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("alpha.txt")
                .Files("omega.txt")
                .Execute();

            scenario.AssertExact();
        }
        public void SlashPolarityIsIgnored(string includePattern, string filePath)
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include(includePattern)
                .Files("one/two.txt", filePath, "three/four.txt")
                .Execute();

            scenario.AssertExact("beta/alpha.txt");
        }
        public void ExcludeFolderByName()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("*.*")
                .Include("../sibling/**/*.*")
                .Exclude("../sibling/exc/")
                .Exclude("../sibling/inc/2.txt")
                .Files("main/1.txt", "main/2.txt", "sibling/1.txt", "sibling/inc/1.txt", "sibling/inc/2.txt", "sibling/exc/1.txt", "sibling/exc/2.txt")
                .SubDirectory("main")
                .Execute();

            scenario.AssertExact("1.txt", "2.txt", "../sibling/1.txt", "../sibling/inc/1.txt");
        }
        public void LeadingDotDotWithRecursiveCanComeThroughPattern()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("*.cs")
                .Include("../2/**/*.cs")
                .Files("1/x.cs", "1/x.txt", "2/x.cs", "2/x.txt", "2/3/x.cs", "2/3/4/z.cs", "2/3/x.txt")
                .SubDirectory("1")
                .Execute();

            scenario.AssertExact("x.cs", "../2/x.cs", "../2/3/x.cs", "../2/3/4/z.cs");
        }
        public void ExcludeCanHaveSurroundingRecursiveWildcards()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("**")
                .Exclude("**/x/**")
                .Files("x/1", "1/x/2", "1/x", "x", "1", "1/2")
                .Execute();

            scenario.AssertExact("1/x", "x", "1", "1/2");
        }
        public void RecursiveAloneIncludesEverything()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("**")
                .Files("1/2/2/3/x", "1/2/3/y")
                .Execute();

            scenario.AssertExact("1/2/2/3/x", "1/2/3/y");
        }
        public void ExcludeMayEndInDirectoryName()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("*.cs", "*/*.cs", "*/*/*.cs")
                .Exclude("bin", "one/two")
                .Files("one/x.cs", "two/x.cs", "one/two/x.cs", "x.cs", "bin/x.cs", "bin/two/x.cs")
                .Execute();

            scenario.AssertExact("one/x.cs", "two/x.cs", "x.cs");
        }
        public void InnerRecursiveWildcardMuseStartWithAndEndWith()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("one/**/*.cs")
                .Files("one/x.cs", "two/x.cs", "one/two/x.cs", "x.cs")
                .Files("one/x.txt", "two/x.txt", "one/two/x.txt", "x.txt")
                .Execute();

            scenario.AssertExact("one/x.cs", "one/two/x.cs");
        }
        public void LeadingRecursiveWildcardMatchesAllLeadingPaths()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("**/*.cs")
                .Files("one/x.cs", "two/x.cs", "one/two/x.cs", "x.cs")
                .Files("one/x.txt", "two/x.txt", "one/two/x.txt", "x.txt")
                .Execute();

            scenario.AssertExact("one/x.cs", "two/x.cs", "one/two/x.cs", "x.cs");
        }
        public void TrailingRecursiveWildcardMatchesAllFiles()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("one/**")
                .Files("one/x.txt", "two/x.txt", "one/x/y.txt")
                .Execute();

            scenario.AssertExact("one/x.txt", "one/x/y.txt");
        }
        public void IncompletePatternsDoNotExclude()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("*/*.txt")
                .Exclude("one/hello.txt")
                .Files("one/x.txt", "two/x.txt")
                .Execute();

            scenario.AssertExact("one/x.txt", "two/x.txt");
        }
        public void StarDotStarIsSameAsStar()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("*.*")
                .Files("alpha.txt", "alpha.", ".txt", ".", "alpha", "txt")
                .Execute();

            scenario.AssertExact("alpha.txt", "alpha.", ".txt", ".", "alpha", "txt");
        }
        public void SequentialFoldersMayBeRequired()
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include("a/b/**/1/2/**/2/3/**")
                .Files("1/2/2/3/x", "1/2/3/y", "a/1/2/4/2/3/b", "a/2/3/1/2/b")
                .Files("a/b/1/2/2/3/x", "a/b/1/2/3/y", "a/b/a/1/2/4/2/3/b", "a/b/a/2/3/1/2/b")
                .Execute();

            scenario.AssertExact("a/b/1/2/2/3/x", "a/b/a/1/2/4/2/3/b");
        }
        public void PatternMatchingWorks(string includePattern, string[] matchesExpected)
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include(includePattern)
                .Files("alpha.txt", "beta.txt", "gamma.dat")
                .Execute();

            scenario.AssertExact(matchesExpected);
        }
        public void PatternBeginAndEndCantOverlap(string includePattern, string[] matchesExpected)
        {
            var matcher = new Matcher();
            var scenario = new FileSystemGlobbingTestContext(@"c:\files\", matcher)
                .Include(includePattern)
                .Files("12345678")
                .Execute();

            scenario.AssertExact(matchesExpected);
        }