public void other_actions_should_not_be_wrapped() { var visitor = new BehaviorVisitor(new NulloConfigurationObserver(), ""); visitor.Filters += chain => chain.ContainsCall(call => call.Method.Name != "SomeAction"); visitor.Actions += chain => chain.Top.ShouldBeOfType <ActionCall>(); _graph.VisitBehaviors(visitor); }
public void other_actions_should_not_be_wrapped() { var visitor = new BehaviorVisitor(""); visitor.Filters += chain => chain.Calls.Any(call => call.Method.Name != "SomeAction"); visitor.Actions += chain => chain.Top.Next.ShouldBeOfType <ActionCall>(); _graph.VisitBehaviors(visitor); }
public void someaction_call_should_be_enriched() { var visitor = new BehaviorVisitor(new NulloConfigurationObserver(), ""); visitor.Filters += chain => chain.Calls.Any(call => call.Method.Name == "SomeAction"); visitor.Actions += chain => { var wrapper = chain.Top.Next.ShouldBeOfType <Wrapper>(); wrapper.BehaviorType.ShouldEqual(typeof(FakeUnitOfWorkBehavior)); wrapper.Previous.ShouldBeOfType <ActionCall>(); }; _graph.VisitBehaviors(visitor); }
public void Activate(IEnumerable <IPackageInfo> packages, IPackageLog log) { var postActionsFinder = new BehaviorVisitor(_graph.Observer, "Looking for valid POST actions."); postActionsFinder.Filters.Add(x => x.Route != null); postActionsFinder.Filters.Add(x => x.Route.AllowedHttpMethods.Contains("POST")); postActionsFinder.Filters.Add(x => x.FirstCall() != null); postActionsFinder.Filters.Add(x => x.FirstCall().HasOutput); postActionsFinder.Filters.Add(x => x.FirstCall().HasInput); postActionsFinder.Actions += x => { var postAction = x.FirstCall(); var handlerActions = _graph.ActionsForHandler(postAction.HandlerType); var getAction = handlerActions .Where(h => h.ParentChain().Route != null) .Where(h => h.ParentChain().Route.AllowedHttpMethods.Contains("GET")) .Where(h => h.HasInput).Where(h => h.HasOutput) .FirstOrDefault(h => x.InputType().IsAssignableFrom(h.OutputType())); if (getAction == null) { return; } log.Trace("Linking validation descriptor for {0} against {1}.", postAction, getAction); _provider.Register(postAction, getAction.InputType()); }; _graph.VisitBehaviors(postActionsFinder); }
public void should_add_new_behavior_node_to_graph() { _graph.Behaviors.ShouldHaveCount(2); var visitor = new BehaviorVisitor(new NulloConfigurationObserver(), ""); visitor.Filters += chain => !chain.ContainsCall(call => call.InputType() == typeof(InputModel)); visitor.Actions += chain => chain.ShouldHaveCount(0); _graph.VisitBehaviors(visitor); }
public void should_add_new_behavior_node_to_graph() { _graph.Behaviors.Count().ShouldEqual(2); var visitor = new BehaviorVisitor(""); visitor.Filters += chain => !chain.Calls.Any(call => call.InputType() == typeof(InputModel)); visitor.Filters += chain => !chain.Any(x => x is OutputCachingNode); visitor.Actions += chain => chain.Top.ShouldBeNull(); _graph.VisitBehaviors(visitor); }
public void all_behaviors_chains_should_start_with_the_declared_behavior() { BehaviorGraph graph = registry.BuildGraph(); graph.Behaviors.Count().ShouldEqual(3); var visitor = new BehaviorVisitor(new NulloConfigurationObserver(), ""); visitor.Actions += chain => { var wrapper = chain.Top.ShouldBeOfType <Wrapper>(); wrapper.BehaviorType.ShouldEqual(typeof(FakeUnitOfWorkBehavior)); wrapper.Next.ShouldBeOfType <ActionCall>(); }; graph.VisitBehaviors(visitor); }
public void Configure(BehaviorGraph graph) { var visitor = new BehaviorVisitor(graph.Observer, _reasonToVisit); _configureAction(visitor); graph.VisitBehaviors(visitor); }
void IConfigurationAction.Configure(BehaviorGraph graph) { graph.VisitBehaviors(this); }