public void find_a_handler_action_set_for_a_type() { var handlerActions = theGraph.ActionsForHandler <AwesomeController>(); handlerActions.Each(x => x.HandlerType.ShouldEqual(typeof(AwesomeController))); handlerActions.Select(x => x.Method.Name) .ShouldHaveTheSameElementsAs("M1", "M2", "Different"); }
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); }