public void Configure(BehaviorGraph graph) { if (TopicGraph.AllTopics.Projects.Count() == 1) { var project = TopicGraph.AllTopics.Projects.Single(); var chain = graph.Behaviors.FirstOrDefault(x => x.Route != null && x.GetRoutePattern().EqualsIgnoreCase(project.Url)); if (chain != null) { chain.Route = new RouteDefinition(""); } } else { var chain = graph.BehaviorFor <HostHomeEndpoint>(x => x.Render()); if (chain.Output.Writers.Any(x => x is SpecialView <HostHome>)) { chain.Route = new RouteDefinition(""); } else { graph.BehaviorFor <AllTopicsEndpoint>(x => x.get_topics()) .Route = new RouteDefinition(""); } } }
public void JsonMessage_interface_has_no_effect_for_partial_actions() { var theChain = theGraph.BehaviorFor(typeof(Input2)); theChain.Input.UsesFormatter <JsonFormatter>().ShouldBeFalse(); theChain.Output.UsesFormatter <JsonFormatter>().ShouldBeFalse(); }
public void the_filter_does_not_count_toward_input_or_resource_type() { var chain = theGraph.BehaviorFor <SomeEndpoint>(x => x.get_something(null)); chain.InputType().ShouldEqual(typeof(RealInput)); chain.ResourceType().ShouldEqual(typeof(RealOutput)); }
public void automatically_output_methds_that_are_decorated_with_JsonEndpoint_to_json() { BehaviorNode behavior = graph.BehaviorFor <JsonOutputAttachmentTesterController>(x => x.Decorated()).Calls.First().Next; behavior.ShouldBeOfType <RenderJsonNode>().ModelType.ShouldEqual(typeof(ViewModel1)); }
public void should_place_an_EnsureEntityExistsBehavior_in_front_of_entity_endpoints() { var chain = theGraph.BehaviorFor <SitesController>(x => x.Edit(null)); chain.FirstCall().Previous.ShouldBeOfType <Wrapper>().BehaviorType.ShouldEqual( typeof(EnsureEntityExistsBehavior <Site>)); }
public void asymmetric_json_attribute_makes_the_input_take_html_or_json() { var theChain = theGraph.BehaviorFor <JsonController>(x => x.Asymmetric(null)); var theInput = theChain.Input; theInput.AllowHttpFormPosts.ShouldBeTrue(); theInput.UsesFormatter <JsonFormatter>().ShouldBeTrue(); }
public void SetUp() { _runtime = FubuApplication.For <ApplicationRegistry>().StructureMap().Bootstrap(); behaviors = _runtime.Factory.Get <BehaviorGraph>(); appChain = behaviors.BehaviorFor <ApplicationActions>(x => x.get_app_action()); pakChain = behaviors.BehaviorFor <PackageActions>(x => x.get_pak_action()); }
public void action_that_returns_HtmlDocument_should_output_to_html() { var outputNode = graph.BehaviorFor <TagController>(x => x.BuildDoc()).Outputs.First().ShouldBeOfType <OutputNode>(); outputNode .ResourceType.ShouldEqual(typeof(HtmlDocument)); outputNode.Writes(MimeType.Html).ShouldBeTrue(); }
each_route_with_the_input_type_matching_the_policy_should_have_the_route_inputs_specified_in_the_convention() { graph.BehaviorFor <SpecialController>(x => x.Go1(null)).Route.Input.As <RouteInput <InputModel> >().RouteParameters.Count. ShouldEqual(0); graph.BehaviorFor <SpecialController>(x => x.Go2(null)).Route.Input.As <RouteInput <SpecialMessage1> >().RouteParameters. Select(x => x.Name).ShouldHaveTheSameElementsAs("Id"); graph.BehaviorFor <SpecialController>(x => x.Go3(null)).Route.Input.As <RouteInput <SpecialMessage2> >().RouteParameters. Select(x => x.Name).ShouldHaveTheSameElementsAs("Id"); graph.BehaviorFor <SpecialController>(x => x.Go4(null)).Route.Input.As <RouteInput <SpecialMessage3> >().RouteParameters. Select(x => x.Name).ShouldHaveTheSameElementsAs("Id"); }
public void provenance_chain_from_a_bottle() { ITracedModel model = theGraph.BehaviorFor <AssemblyEndpoint>(x => x.get_hello()).As <ITracedModel>(); var chain = model.AllEvents().OfType <Created>().Single().Source.ProvenanceChain.Chain; chain.Each(x => Debug.WriteLine(x)); var assemblyPackage = PackageRegistry.Packages.Single(x => x.Name == typeof(AssemblyEndpoint).Assembly.GetName().Name); assemblyPackage.ShouldNotBeNull(); chain.ShouldContain(new BottleProvenance(assemblyPackage)); chain.OfType <FubuRegistryProvenance>().Last().Registry.ShouldBeOfType <AssemblyPackageRegistry>(); }
public void should_have_a_chain_for_each_matching_view() { theBehaviorGraph.BehaviorFor(typeof(InputModel)).ShouldNotBeNull(); theBehaviorGraph.BehaviorFor(typeof(TestInputModel)).ShouldNotBeNull(); theBehaviorGraph.BehaviorFor(typeof(Model1)).ShouldNotBeNull(); theBehaviorGraph.BehaviorFor(typeof(Model3)).ShouldNotBeNull(); }
public void find_creator_positive() { var chain = graph.BehaviorFor <ChainResolverController>(x => x.M6(null)); chain.UrlCategory.Creates.Add(typeof(Entity1)); chain.UrlCategory.Creates.Add(typeof(Entity2)); resolver.FindCreatorOf(typeof(Entity1)).FirstCall().Method.Name.ShouldEqual("M6"); resolver.FindCreatorOf(typeof(Entity2)).FirstCall().Method.Name.ShouldEqual("M6"); resolver.FindCreatorOf(typeof(Entity3)).ShouldBeNull(); }
public void SetUp() { theHttpRequest = new StandInCurrentHttpRequest(); UrlContext.Stub("http://server"); theUrlResolver = new ChainUrlResolver(theHttpRequest); theGraph = BehaviorGraph.BuildFrom(registry => { registry.Actions.IncludeType <ChainUrlResolverEndpoint>(); }); theSimpleChain = theGraph.BehaviorFor <ChainUrlResolverEndpoint>(x => x.get_index()); theChainWithRouteParams = theGraph.BehaviorFor(typeof(ChainUrlParams)); }
public void SetUp() { theHttpRequest = OwinHttpRequest.ForTesting(); UrlContext.Stub("http://server"); theUrlResolver = new ChainUrlResolver(theHttpRequest); theGraph = BehaviorGraph.BuildFrom(registry => { registry.Actions.IncludeType<ChainUrlResolverEndpoint>(); }); theSimpleChain = theGraph.BehaviorFor<ChainUrlResolverEndpoint>(x => x.get_index()); theChainWithRouteParams = theGraph.BehaviorFor(typeof(ChainUrlParams)); }
public void find_by_input_model_and_category_fails_when_there_are_multiple_matching_chains() { graph.BehaviorFor <ChainResolverController>(x => x.M2(null)) .UrlCategory.Category = Categories.NEW; graph.BehaviorFor <ChainResolverController>(x => x.M3(null)) .UrlCategory.Category = Categories.NEW; Exception <FubuException> .ShouldBeThrownBy( () => { _resolutionCache.FindUnique(new ChainResolverInput1(), Categories.NEW).FirstCall(); }).ErrorCode .ShouldEqual(2108); }
void IConfigurationAction.Configure(BehaviorGraph graph) { var chain = graph.BehaviorFor(_route); _nodes.Each(chain.AddToEnd); //graph.Observer.RecordStatus("Adding explicit route {0}".ToFormat(_route)); }
public void SetUp() { var registry = new FubuRegistry(x => { x.Actions.IncludeClassesSuffixedWithController(); x.Configure(g => { g.BehaviorFor<AuthorizedController>(c => c.Go(null)).Authorization.AddRole("RoleA"); }); }); graph = BehaviorGraph.BuildFrom(registry); goChain = graph.BehaviorFor<AuthorizedController>(x => x.Go(null)); moveChain = graph.BehaviorFor<AuthorizedController>(x => x.Move(null)); }
protected override void beforeEach() { _graph = ObjectMother.DiagnosticsGraph(); _chain = _graph.BehaviorFor(typeof(DashboardRequestModel)); Container.Configure(x => x.For <BehaviorGraph>().Use(_graph)); }
void IConfigurationAction.Configure(BehaviorGraph graph) { var chain = graph.BehaviorFor(_route); _nodes.Each(chain.AddToEnd); _chainConfigs.Each(x => x(chain)); }
private bool chainHasFilter <T>(BehaviorGraph graph, Expression <Func <T, object> > expression) { return(graph .BehaviorFor(expression) .Filters .Any(x => x.GetType() == typeof(HttpContentEncodingFilter))); }
public void home_url_policy_registration_should_be_higher_priority() { var homeDefinition = graphWithHomeAndUrlPolicy.BehaviorFor <OneController>(c => c.HomeWithInputOutput(new SimpleInputModel())); homeDefinition.Route.Pattern.ShouldEqual(""); }
public void should_apply_download_behavior_convention() { BehaviorNode behavior = graph.BehaviorFor <DownloadTestController>(x => x.Download()).Calls.First().Next; var outputNode = behavior.ShouldBeOfType <OutputNode>(); outputNode.BehaviorType.ShouldEqual(typeof(DownloadFileBehavior)); }
public void SetUp() { var registry = new FubuRegistry(x => { x.Actions.IncludeClassesSuffixedWithController(); x.Configure(g => { g.BehaviorFor <AuthorizedController>(c => c.Go(null)).Authorization.AddRole("RoleA"); }); }); graph = BehaviorGraph.BuildFrom(registry); goChain = graph.BehaviorFor <AuthorizedController>(x => x.Go(null)); moveChain = graph.BehaviorFor <AuthorizedController>(x => x.Move(null)); }
public void should_apply_custom_conventions() { var behavior = graph.BehaviorFor <JsonOutputAttachmentTesterController>(x => x.StringifyHtml()).Calls.First().Next; behavior.ShouldBeOfType <OutputNode>(); }
public void SetUp() { var registry = new FubuRegistry(x => { x.Actions.IncludeTypesNamed(t => t.EndsWith("Controller")); x.Configure(g => { g.BehaviorFor <AuthorizedController>(c => c.Go()).Authorization.AddRole("RoleA"); }); }); graph = registry.BuildGraph(); goChain = graph.BehaviorFor <AuthorizedController>(x => x.Go()); moveChain = graph.BehaviorFor <AuthorizedController>(x => x.Move()); }
public void SetUp() { var registry = new FubuRegistry(x => { x.Actions.IncludeTypesNamed(t => t.EndsWith("Controller")); x.Configure(g => { g.BehaviorFor<AuthorizedController>(c => c.Go()).Authorization.AddRole("RoleA"); }); }); graph = registry.BuildGraph(); goChain = graph.BehaviorFor<AuthorizedController>(x => x.Go()); moveChain = graph.BehaviorFor<AuthorizedController>(x => x.Move()); }
public void Configure(BehaviorGraph graph) { var chain = graph.BehaviorFor<TwitterController>(x => x.Button(null)); if (!chain.Output.HasView(typeof(Always))) { chain.Output.Writers.AddToEnd(new WriteDefaultTwitterButton()); } }
public void the_constructed_behavior_chain_should_be_a_call_to_the_action_and_then_to_json() { ActionCallSpec spec = ActionCallSpec.For <InputController>(c => c.DoSomething(null)); spec.Json <OutputModel>(); spec.Verify(graph.BehaviorFor(route)); }
public void Configure(BehaviorGraph graph) { var chain = graph.BehaviorFor<InlineModelEndpoint>(e => e.post_inline_model(null)); var validation = chain.ValidationNode(); if(validation != null) { validation.Strategies.RegisterStrategy(RenderingStrategy.Inline); } }
public void Configure(BehaviorGraph graph) { var chain = graph.BehaviorFor <GoogleController>(x => x.Button(null)); if (!chain.Output.HasView(typeof(Always))) { chain.Output.Writers.AddToEnd(new WriteDefaultGoogleButton()); } }
public void move_behavior_before_authorization() { // Ordinarily, AuthorizationNode would be before any other behavior wrappers var chain = graph.BehaviorFor <OrderingPolicyController>(x => x.M1()); chain.First().ShouldBeOfType <Wrapper>().BehaviorType.ShouldEqual(typeof(OPWrapper1)); chain.ToList()[1].ShouldBeOfType <AuthorizationNode>(); }
public void someaction_call_should_be_enriched() { var chain = _graph.BehaviorFor <TestController>(x => x.SomeAction(null)); // InputNode, then ActionCall, then Wrapper var wrapper = chain.Top.Next.Next.ShouldBeOfType <Wrapper>(); wrapper.BehaviorType.ShouldEqual(typeof(FakeUnitOfWorkBehavior)); wrapper.Previous.ShouldBeOfType <ActionCall>(); }
public void home_route_definition_pattern_should_be_empty() { var homeDefinition1 = graphWithMethodHome.BehaviorFor <OneController>(c => c.Home()); var homeDefinition2 = graphWithModelHome.BehaviorFor <OneController>(c => c.HomeWithInputOutput(new SimpleInputModel())); var notHomeDefinition = graphWithoutHome.BehaviorFor <OneController>(c => c.Home()); homeDefinition1.Route.Pattern.ShouldEqual(""); homeDefinition2.Route.Pattern.ShouldEqual(""); notHomeDefinition.Route.Pattern.ShouldNotBeEmpty(); }
public void Configure(BehaviorGraph graph) { var chain = graph.BehaviorFor(typeof (ValidationSummary)); if (chain == null) return; if (!chain.Output.HasView(typeof(Always))) { chain.Output.Writers.AddToEnd(new DefaultValidationSummaryNode()); } }
public void Configure(BehaviorGraph graph) { var chain = graph.BehaviorFor<LoginController>(x => x.Login(null)); if (chain == null) return; if(!chain.Output.HasView(typeof(Always))) { chain.Output.Writers.AddToEnd(new WriteDefaultLogin()); } }
// TODO -- This really needs to change to returning an IEnumerable and // we possibly need an alternative that finds by category public BehaviorChain Find <T>(Expression <Action <T> > expression) { var chain = _behaviorGraph.BehaviorFor(expression); if (chain == null) { throw new FubuException(2108, "No behavior chain registered for {0}.{1}()", typeof(T).FullName, ReflectionHelper.GetMethod(expression).Name); } return(chain); }
public void Configure(BehaviorGraph graph) { var chain = graph.BehaviorFor(_action); if (chain == null || !chain.FirstCall().HasOutput) { return; } var node = new Wrapper(typeof(ProductNotFoundConvention <>).MakeGenericType(chain.ActionOutputType())); chain.FirstCall().AddAfter(node); }
public void should_throw_an_exception_if_the_result_is_not_unique() { var call1 = ActionCall.For<Issue101Endpoint>(x => x.get_hello()); var call2 = ActionCall.For<Issue101Endpoint>(x => x.get_hello()); var graph = new BehaviorGraph(); graph.AddChain().AddToEnd(call1); graph.AddChain().AddToEnd(call2); Exception<FubuException>.ShouldBeThrownBy(() => { graph.BehaviorFor<Issue101Endpoint>(x => x.get_hello()); }); }
public void action_without_json_attributes_or_JsonMessage_input_model_has_no_conneg() { // You have to make the endpoint get some sort of reader/writer to test the negative case, // otherwise the default "use json & xml if nothing else is provided" convention // takes over var registry = new FubuRegistry(); registry.Actions.IncludeType<JsonController>(); registry.Configure(graph => { graph.Behaviors.Where(x => x.InputType() == typeof (Input1)).Each(chain => { chain.Input.AddFormatter<XmlFormatter>(); chain.Output.AddFormatter<XmlFormatter>(); }); }); theGraph = BehaviorGraph.BuildFrom(registry); var theChain = theGraph.BehaviorFor(typeof (Input1)); theChain.Input.UsesFormatter<JsonFormatter>().ShouldBeFalse(); theChain.Output.UsesFormatter<JsonFormatter>().ShouldBeFalse(); }
public void SetUp() { FubuTransport.AllQueuesInMemory = true; container = new Container(); container.Inject(new TransportSettings { DelayMessagePolling = Int32.MaxValue, ListenerCleanupPolling = Int32.MaxValue }); theServiceBus = MockRepository.GenerateMock<IServiceBus>(); theRuntime = FubuApplication.DefaultPolicies().StructureMap(container).Bootstrap(); theGraph = theRuntime.Factory.Get<BehaviorGraph>(); chain = theGraph.BehaviorFor<MessageOnePublisher>(x => x.post_message1(null)); container.Inject(theServiceBus); }
void IConfigurationAction.Configure(BehaviorGraph graph) { graph.BehaviorFor(_route).AddToEnd(_topBehavior); //graph.Observer.RecordStatus("Adding explicit route {0}".ToFormat(_route)); }
public void SetUp() { FubuMode.Reset(); _runtime = FubuApplication.For<ApplicationRegistry>().StructureMap().Bootstrap(); behaviors = _runtime.Factory.Get<BehaviorGraph>(); appChain = behaviors.BehaviorFor<ApplicationActions>(x => x.get_app_action()); pakChain = behaviors.BehaviorFor<PackageActions>(x => x.get_pak_action()); }
void IConfigurationAction.Configure(BehaviorGraph graph) { graph.BehaviorFor(_route).Append(_topBehavior); }
public void SetUp() { theRegistry = new LoggedFubuRegistry(); // Do it this way so that it gets the assembly package container = new Container(); theGraph = FubuApplication.For(theRegistry).StructureMap(container) .Bootstrap().Factory.Get<BehaviorGraph>(); theGraph.BehaviorFor<LoggedEndpoint>(x => x.get_logged_hello()).ShouldNotBeNull(); theLogs = container.GetInstance<ConfigLog>(); }