예제 #1
0
        public void use_multiple_predicates()
        {
            var composite = new CompositePredicate <string>();

            composite += x => x.StartsWith("a");
            composite += x => x.EndsWith("x");

            composite.MatchesAll("a").ShouldBeFalse();
            composite.MatchesAll("x").ShouldBeFalse();
            composite.MatchesAll("abx").ShouldBeTrue();
        }
예제 #2
0
        public void registered_predicates_are_used()
        {
            var composite = new CompositePredicate <string>();

            composite.MatchesAll("a").ShouldBeTrue();
            composite.MatchesAll("b").ShouldBeTrue();

            composite += x => x == "a";

            composite.MatchesAll("a").ShouldBeTrue();
            composite.MatchesAll("b").ShouldBeFalse();
        }
예제 #3
0
 public void VisitRoute(IRouteDefinition route, BehaviorChain chain)
 {
     if (_behaviorFilters.MatchesAll(chain) && _routeFilters.MatchesAll(route))
     {
         _actions.Do(route, chain);
     }
 }
예제 #4
0
 public void no_predicates_means_that_it_always_true()
 {
     var composite = new CompositePredicate<string>();
     composite.MatchesAll("a").ShouldBeTrue();
     composite.MatchesAll("b").ShouldBeTrue();
     composite.MatchesAll("c").ShouldBeTrue();
     composite.MatchesAll("d").ShouldBeTrue();
     composite.MatchesAll("e").ShouldBeTrue();
     composite.MatchesAll("f").ShouldBeTrue();
     composite.MatchesAll("g").ShouldBeTrue();
 }
예제 #5
0
        public void no_predicates_means_that_it_always_true()
        {
            var composite = new CompositePredicate <string>();

            composite.MatchesAll("a").ShouldBeTrue();
            composite.MatchesAll("b").ShouldBeTrue();
            composite.MatchesAll("c").ShouldBeTrue();
            composite.MatchesAll("d").ShouldBeTrue();
            composite.MatchesAll("e").ShouldBeTrue();
            composite.MatchesAll("f").ShouldBeTrue();
            composite.MatchesAll("g").ShouldBeTrue();
        }
예제 #6
0
        public void VisitBehavior(BehaviorChain chain)
        {
            if (!_filters.MatchesAll(chain))
            {
                return;
            }

            var matchesDescriptions = _filters.GetDescriptionOfMatches(chain).Join(", ");

            if (matchesDescriptions == string.Empty)
            {
                matchesDescriptions = "(no filters defined)";
            }

            chain.Calls.Each(call => call.Trace("Visiting: {0}. Matched on filters [{1}]", _reasonToVisit, matchesDescriptions));

            _actions.Do(chain);
        }
예제 #7
0
        public void registered_predicates_are_used()
        {
            var composite = new CompositePredicate<string>();
            composite.MatchesAll("a").ShouldBeTrue();
            composite.MatchesAll("b").ShouldBeTrue();

            composite += x => x == "a";

            composite.MatchesAll("a").ShouldBeTrue();
            composite.MatchesAll("b").ShouldBeFalse();
        }
예제 #8
0
        public void use_multiple_predicates()
        {
            var composite = new CompositePredicate<string>();
            composite += x => x.StartsWith("a");
            composite += x => x.EndsWith("x");

            composite.MatchesAll("a").ShouldBeFalse();
            composite.MatchesAll("x").ShouldBeFalse();
            composite.MatchesAll("abx").ShouldBeTrue();
        }