public static FubuMVC.Swank.Specification.Specification GetSpec(Action <Swank> configure = null) { var graph = Behavior.BuildGraph().AddActionsInThisNamespace(); var moduleConvention = new ModuleConvention(new MarkerConvention <ModuleDescription>()); var resourceConvention = new ResourceConvention( new MarkerConvention <ResourceDescription>(), new BehaviorSource(graph, Swank.CreateConfig(x => x.AppliesToThisAssembly().Where(ActionFilter)))); var configuration = Swank.CreateConfig(x => { x.AppliesToThisAssembly().Where(ActionFilter).WithEnumValueTypeOf(EnumValue.AsString); if (configure != null) { configure(x); } }); var specBuilder = new FubuMVC.Swank.Specification.SpecificationService(configuration, new BehaviorSource(graph, configuration), new TypeDescriptorCache(), moduleConvention, resourceConvention, new EndpointConvention(), new MemberConvention(), new OptionConvention(), new StatusCodeConvention(), new HeaderConvention(), new TypeConvention(), new MergeService()); return(specBuilder.Generate()); }
protected FubuMVC.Swank.Specification.Specification BuildSpec <TNamespace>(BehaviorGraph graph, Action <Swank> configure = null, string specFile = null) { var configuration = Swank.CreateConfig(x => { if (configure != null) { configure(x); } x.AppliesToThisAssembly() .Where(y => y.FirstCall().HandlerType.InNamespace <TNamespace>()); if (specFile != null) { x.MergeThisSpecification(specFile); } }); var behaviorSource = new BehaviorSource(graph, configuration); var resourceConvention = new ResourceConvention(new MarkerConvention <ResourceDescription>(), behaviorSource); var moduleConvention = new ModuleConvention(new MarkerConvention <ModuleDescription>()); return(new FubuMVC.Swank.Specification.SpecificationService(configuration, behaviorSource, new TypeDescriptorCache(), moduleConvention, resourceConvention, new EndpointConvention(), new MemberConvention(), new OptionConvention(), new StatusCodeConvention(), new HeaderConvention(), new TypeConvention(), new MergeService()).Generate()); }
public void Setup() { _graph = Behavior.BuildGraph().AddActionsInThisNamespace(); _resourceConvention = new ResourceConvention( new MarkerConvention <ResourceDescription>(), new BehaviorSource(_graph, Swank.CreateConfig(x => x.AppliesToThisAssembly() .Where(y => y.FirstCall().HandlerType.InNamespace <Tests>())))); }
public void should_only_enumerate_actions_in_the_specified_assemblies() { _graph.AddAction <GetHandler>("GET"); var configuration = Swank.CreateConfig(x => x.AppliesTo <Tests>()); var chains = new BehaviorSource(_graph, configuration).GetChains(); chains.Count.ShouldEqual(4); chains.All(x => x.FirstCall().HandlerType.Assembly == Assembly.GetExecutingAssembly()).ShouldBeTrue(); }
public void should_filter_actions_based_on_filter_in_the_configuration() { var configuration = Swank.CreateConfig(x => x .AppliesToThisAssembly() .Where(y => y.Route.Pattern.StartsWith("/handlers/widget"))); var chains = new BehaviorSource(_graph, configuration).GetChains(); chains.Count.ShouldEqual(2); chains.All(x => x.Route.Pattern.StartsWith("/handlers/widget")).ShouldBeTrue(); }