Beispiel #1
0
        public void FindsAllUniqueMatchesOfIncludesNotMatchedByExcludes()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var parser = new GlobParser();

            var matches = new MultiGlobMatchEnumerator()
                          .Exclude(parser.Parse("home/*/**"))
                          .Include(parser.Parse("**/h*"))
                          .EnumerateMatches(hierarchy);

            Assert.That(matches.Select(m => m.Item.Name).ToArray(),
                        Is.EquivalentTo(new []
            {
                "hda",
                "hda1",
                "hdb",
                "hdb1",
                "hdb2",
                "home"
            }));
        }
Beispiel #2
0
        public void MatcherWithOnlyRecursiveExclusionRulesMatchingWithinASubtree_DoesNotMatchWithinThatSubtree()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var parser = new GlobParser();

            var matches = new MultiGlobMatchEnumerator()
                          .Exclude(parser.Parse("d*/**"))
                          .Include(parser.Parse("d*"))
                          .EnumerateMatches(hierarchy).ToArray();

            Assert.That(matches.Select(m => m.Item.Name).ToArray(),
                        Is.EquivalentTo(new []
            {
                "dev",
            }));
        }
Beispiel #3
0
        public void MatcherWithOnlyExclusionRulesMatchingInitially_MatchesNothing()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var parser = new GlobParser();

            var matches = new MultiGlobMatchEnumerator()
                          .Exclude(parser.Parse("dev/**"))
                          .Exclude(parser.Parse("**/hd[am]?"))
                          .Include(parser.Parse("nothing/**"))
                          .EnumerateMatches(hierarchy).ToArray();

            Assert.That(matches.Select(m => m.Item.Name).ToArray(), Is.Empty);
        }
Beispiel #4
0
        public void EarlierRulesTakePrecedence_ExcludeBeforeInclude()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var parser = new GlobParser();

            var matches = new MultiGlobMatchEnumerator()
                          .Exclude(parser.Parse("dev/**"))
                          .Include(parser.Parse("**/hd[am]?"))
                          .EnumerateMatches(hierarchy).ToArray();

            Assert.That(matches.Select(m => m.Item.Name).ToArray(),
                        Is.EquivalentTo(new []
            {
                "hdmi",
            }));
        }
Beispiel #5
0
        public void ContainerExclusionDoesNotApplyRecursively()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var parser   = new GlobParser();
            var includes = new []
            {
                parser.Parse("**/h*")
            };
            var excludes = new []
            {
                parser.Parse("home")
            };

            var matches = new MultiGlobMatchEnumerator()
                          .Exclude(excludes)
                          .Include(includes)
                          .EnumerateMatches(hierarchy);

            Assert.That(matches.Select(m => m.Item.Name).ToArray(),
                        Is.EquivalentTo(new []
            {
                "hda",
                "hda1",
                "hdb",
                "hdb1",
                "hdb2",
                "hdmi"
            }));
        }
Beispiel #6
0
        public void YieldsDetailsForEveryMatchingIncludeGlob()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var parser   = new GlobParser();
            var includes = new []
            {
                parser.Parse("**/hd[am]?"),
                parser.Parse("home/**")
            };

            var matches = new MultiGlobMatchEnumerator()
                          .Include(includes)
                          .EnumerateMatches(hierarchy).ToArray();

            Assume.That(matches.Select(m => m.Item.Name).ToArray(),
                        Is.EquivalentTo(new []
            {
                "hda1",
                "me",
                "hdmi",
                "you"
            }));

            var hdmiMatch = matches.Single(m => m.Item.Name == "hdmi");

            Assert.That(hdmiMatch.Details.Select(s => s.Glob).ToArray(), Is.EquivalentTo(includes));
        }