public void pick_up_behaviors_from_this_assembly() { var graph = BehaviorGraph.BuildFrom(x => x.Actions.IncludeClassesSuffixedWithController()); graph.Chains.Count().ShouldBeGreaterThan(0); graph.Chains.OfType <RoutedChain>().Where(x => x.Calls.Any()).Each(x => x.Calls.First().HandlerType.Name.EndsWith("Controller")); }
public void alter_settings_modifies_settings_object() { var registry = new FubuRegistry(r => r.AlterSettings <SettingsObject>(so => so.Touched = true)); BehaviorGraph.BuildFrom(registry) .Settings.Get <SettingsObject>().Touched.ShouldBeTrue(); }
public void SetUp() { graph = BehaviorGraph.BuildFrom(x => { x.Actions.IncludeType <JsonOutputAttachmentTesterController>(); }); }
public void apply_policy_to_import_only_applies_to_the_chains_in_the_imported_registry() { import.Route("a/m1").Calls <Action1>(x => x.M1()); import.Route("a/m2").Calls <Action1>(x => x.M2()); import.Policies.Add(policy => policy.Wrap.WithBehavior <Wrapper>()); parent.Import(import, "import"); parent.Route("b/m1").Calls <Action2>(x => x.M1()); parent.Route("b/m2").Calls <Action2>(x => x.M2()); var graph = BehaviorGraph.BuildFrom(parent); // Chains from the import should have the wrapper var chain = graph.BehaviorFor <Action1>(x => x.M1()); chain.IsWrappedBy(typeof(Wrapper)).ShouldBeTrue(); graph.BehaviorFor <Action1>(x => x.M2()).IsWrappedBy(typeof(Wrapper)).ShouldBeTrue(); // Chains from the parent should not have the wrapper graph.BehaviorFor <Action2>(x => x.M1()).IsWrappedBy(typeof(Wrapper)).ShouldBeFalse(); graph.BehaviorFor <Action2>(x => x.M2()).IsWrappedBy(typeof(Wrapper)).ShouldBeFalse(); }
public void SetUp() { _theCurrentHttpRequest = new StubCurrentHttpRequest { TheApplicationRoot = "http://server/fubu" }; var registry = new FubuRegistry(); registry.Actions.IncludeType <OneController>(); registry.Actions.IncludeType <TwoController>(); registry.Actions.IncludeType <QueryStringTestController>(); registry.Actions.IncludeType <OnlyOneActionController>(); registry.Routes .IgnoreControllerFolderName() .IgnoreNamespaceForUrlFrom <UrlRegistryIntegrationTester>() .IgnoreClassSuffix("Controller"); registry.Configure(x => { x.TypeResolver.AddStrategy <UrlModelForwarder>(); }); registry.Routes.HomeIs <DefaultModel>(); graph = BehaviorGraph.BuildFrom(registry); var resolver = graph.Services.DefaultServiceFor <ITypeResolver>().Value; urls = new UrlRegistry(new ChainResolutionCache((ITypeResolver)resolver, graph), new JQueryUrlTemplate(), _theCurrentHttpRequest); }
public void SetUp() { graph1 = BehaviorGraph.BuildFrom(x => { x.Route("method1/{Name}/{Age}") .Calls <TestController>(c => c.AnotherAction(null)).OutputToJson(); x.Route("method2/{Name}/{Age}") .Calls <TestController>(c => c.AnotherAction(null)).OutputToJson(); x.Route("method3/{Name}/{Age}") .Calls <TestController>(c => c.AnotherAction(null)).OutputToJson(); }); chain = new BehaviorChain(); graph1.AddChain(chain); graph2 = BehaviorGraph.BuildFrom(x => { x.Route("/root/{Name}/{Age}") .Calls <TestController>(c => c.AnotherAction(null)).OutputToJson(); }); graph2.As <IChainImporter>().Import(graph1, b => b.PrependToUrl("area1")); }
private void registeredTypeIs <TService, TImplementation>() { BehaviorGraph.BuildFrom(x => { x.Services <Saml2ServicesRegistry>(); }).Services.DefaultServiceFor <TService>().Type.ShouldEqual( typeof(TImplementation)); }
public void SetUp() { theHttpRequest = OwinHttpRequest.ForTesting(); theHttpRequest.FullUrl("http://server/fubu"); var registry = new FubuRegistry(); registry.Actions.IncludeType <OneController>(); registry.Actions.IncludeType <TwoController>(); registry.Actions.IncludeType <QueryStringTestController>(); registry.Actions.IncludeType <OnlyOneActionController>(); registry.Configure(x => { x.TypeResolver.AddStrategy <UrlModelForwarder>(); }); //registry.Routes.HomeIs<DefaultModel>(); graph = BehaviorGraph.BuildFrom(registry); var resolver = graph.Services.DefaultServiceFor <ITypeResolver>().Value; var urlResolver = new ChainUrlResolver(theHttpRequest); urls = new UrlRegistry(new ChainResolutionCache((ITypeResolver)resolver, graph), urlResolver, new JQueryUrlTemplate(), theHttpRequest); }
public void SetUp() { var registry = new FubuRegistry(); registry.Actions.IncludeType <RestController1>(); // TODO -- this really needs to be done with a Bottle var typePool = new TypePool(); typePool.AddAssembly(Assembly.GetExecutingAssembly()); registry.Policies.Add(new ConnegAttachmentPolicy(typePool)); registry.Services <ResourcesServiceRegistry>(); registry.Policies.Add(x => { x.Where.AnyActionMatches( call => call.HandlerType == typeof(RestController1) && !call.Method.Name.StartsWith("Not")); x.Conneg.ApplyConneg(); }); theBehaviorGraph = BehaviorGraph.BuildFrom(registry); theConnegGraph = new ConnegGraph(theBehaviorGraph); }
public void SetUp() { theGraph = BehaviorGraph.BuildFrom(x => { x.Actions.IncludeClassesSuffixedWithController(); }); }
private static IEnumerable <ActionCall> build(bool enableDiagnostics) { var graph = BehaviorGraph.BuildFrom(new CustomFubuRegistry(enableDiagnostics)); return(graph.Actions() .Where(a => a.HandlerType.Assembly == typeof(CustomFubuRegistry).Assembly)); }
public void should_be_a_script_configuration_activator_registered_as_a_service() { var services = BehaviorGraph.BuildFrom(x => x.Import <AssetBottleRegistration>()).Services; services.ServicesFor <IActivator>() .Any(x => x.Type == typeof(AssetGraphConfigurationActivator)).ShouldBeTrue(); }
public void SetUp() { graph = BehaviorGraph.BuildFrom(x => { x.Import <NavigationRegistryExtension>(); x.Actions.IncludeType <Controller1>(); }); }
public void default_namespaces_are_set_including_anything_from_CommonViewNamespaces() { var registry = new FubuRegistry(); registry.Import <RazorViewFacility>(); registry.AlterSettings <CommonViewNamespaces>(x => { x.Add("Foo"); x.Add("Bar"); }); var graph = BehaviorGraph.BuildFrom(registry); var useNamespaces = graph.Services.DefaultServiceFor <CommonViewNamespaces>().Value.As <CommonViewNamespaces>(); useNamespaces.Namespaces.ShouldHaveTheSameElementsAs(new[] { "System.Web", "System", "FubuCore", "System.Linq", "HtmlTags", "FubuMVC.Core.UI", "FubuMVC.Core.UI.Extensions", "FubuMVC.Razor", "Foo", "Bar" }); }
public void SetUp() { graphWithMethodHome = BehaviorGraph.BuildFrom(x => { x.Actions.IncludeClassesSuffixedWithController(); x.Routes.HomeIs <OneController>(c => c.Home()); }); graphWithModelHome = BehaviorGraph.BuildFrom(x => { x.Actions.IncludeClassesSuffixedWithController(); x.Routes.HomeIs <SimpleInputModel>(); }); graphWithoutHome = BehaviorGraph.BuildFrom(x => { x.Actions.IncludeClassesSuffixedWithController(); }); graphWithHomeAndUrlPolicy = BehaviorGraph.BuildFrom(x => { x.Actions.IncludeClassesSuffixedWithController(); x.Routes .UrlPolicy <AllEncompassingUrlPolicy>() .HomeIs <SimpleInputModel>(); }); }
public void authorization_rules_from_settings_are_applied() { BehaviorGraph authorizedGraph = BehaviorGraph.BuildFrom(r => { r.Import <DiagnosticsRegistration>(); r.AlterSettings <DiagnosticsSettings>(x => { x.RestrictToRule("admin"); }); }); BehaviorGraph notAuthorizedGraph = BehaviorGraph.BuildFrom(r => { r.Import <DiagnosticsRegistration>(); // r.AlterSettings<DiagnosticsSettings>(x => // { // x.RestrictToRule("admin"); // }); }); authorizedGraph.Behaviors.OfType <DiagnosticChain>() .Each(x => x.Authorization.AllowedRoles().Single().ShouldEqual("admin")); notAuthorizedGraph.Behaviors.OfType <DiagnosticChain>() .Each(x => x.Authorization.HasRules().ShouldBeFalse()); }
public void do_nothing_if_tracing_is_off() { var registry = new FubuRegistry(); registry.AlterSettings <DiagnosticsSettings>(x => x.TraceLevel = TraceLevel.None); registry.Configure(graph => { chain1 = new RoutedChain("something"); chain1.AddToEnd(Wrapper.For <SimpleBehavior>()); chain1.AddToEnd(Wrapper.For <DifferentBehavior>()); graph.AddChain(chain1); chain2 = new BehaviorChain(); chain2.IsPartialOnly = true; chain2.AddToEnd(Wrapper.For <SimpleBehavior>()); chain2.AddToEnd(Wrapper.For <DifferentBehavior>()); graph.AddChain(chain2); }); var notTracedGraph = BehaviorGraph.BuildFrom(registry); notTracedGraph.Behaviors.SelectMany(x => x).Any(x => x is DiagnosticBehavior).ShouldBeFalse(); notTracedGraph.Behaviors.SelectMany(x => x).Any(x => x is BehaviorTracer).ShouldBeFalse(); }
public void SetUp() { theRequirements = MockRepository.GenerateStub <IAssetRequirements>(); theGraph = BehaviorGraph.BuildFrom(x => x.Actions.IncludeType <FormModeEndpoint>()); theRegistry = theGraph.Settings.Get <FormSettings>().BuildRegistry(); }
public void SetUp() { registry = new FubuRegistry(x => { x.Actions.IncludeTypes(t => false); // Tell FubuMVC to wrap the behavior chain for each // RouteHandler with the "FakeUnitOfWorkBehavior" // Kind of like a global [ActionFilter] in MVC x.Policies.ConditionallyWrapBehaviorChainsWith <FakeUnitOfWorkBehavior>( call => call.Method.Name == "SomeAction"); // Explicit junk you would only do for exception cases to // override the conventions x.Route("area/sub/{Name}/{Age}") .Calls <TestController>(c => c.SomeAction(null)).OutputToJson(); x.Route("area/sub2/{Name}/{Age}") .Calls <TestController>(c => c.AnotherAction(null)).OutputToJson(); x.Route("area/sub3/{Name}/{Age}") .Calls <TestController>(c => c.ThirdAction(null)).OutputToJson(); }); _graph = BehaviorGraph.BuildFrom(registry); }
public void applies_the_tags() { var graph = BehaviorGraph.BuildFrom(x => x.Actions.IncludeType <TaggedEndpoint>()); graph.BehaviorFor <TaggedEndpoint>(x => x.get_tags()) .Tags.ShouldHaveTheSameElementsAs("foo", "bar"); }
protected override void beforeEach() { var registry = new FubuRegistry(); ClassUnderTest.As <IFubuRegistryExtension>().Configure(registry); _services = BehaviorGraph.BuildFrom(registry).Services; }
public void SetUp() { theFubuRegistry = new FubuRegistry(); theFubuRegistry.Actions.IncludeType <Controller1>(); theGraph = new Lazy <BehaviorGraph>(() => BehaviorGraph.BuildFrom(theFubuRegistry)); }
public void is_registered() { var services = BehaviorGraph.BuildFrom(new FubuRegistry()).Services; services.ServicesFor(typeof(IConverterFamily)).Select(x => x.Type) .ShouldContain(typeof(AspNetPassthroughConverter)); }
public void adds_the_about_endpoint_if_in_development_mode() { var graph = BehaviorGraph.BuildFrom(x => x.Mode = "development"); graph.ChainFor <AboutFubuDiagnostics>(x => x.get_about()) .ShouldNotBeNull(); }
public void SetUp() { graph = BehaviorGraph.BuildFrom(x => { x.Actions.IncludeType <TagController>(); }); }
public void authorization_rules_from_settings_are_applied() { var authorizedGraph = BehaviorGraph.BuildFrom(r => { r.Features.Diagnostics.Configure(x => { x.TraceLevel = TraceLevel.Verbose; x.RestrictToRole("admin"); }); }); var notAuthorizedGraph = BehaviorGraph.BuildFrom(r => { r.Features.Diagnostics.Enable(TraceLevel.Verbose); // r.AlterSettings<DiagnosticsSettings>(x => // { // x.RestrictToRule("admin"); // }); }); authorizedGraph.Chains.OfType <DiagnosticChain>() .Each(x => x.Authorization.AllowedRoles().Single().ShouldBe("admin")); notAuthorizedGraph.Chains.OfType <DiagnosticChain>() .Each(x => x.Authorization.HasRules().ShouldBeFalse()); }
public void is_registered() { var registry = new FubuRegistry(); registry.Import <ViewEnginesExtension>(); registry.AlterSettings <CommonViewNamespaces>(x => { x.Add("Foo"); x.Add("Bar"); }); var graph = BehaviorGraph.BuildFrom(registry); var useNamespaces = graph.Services.DefaultServiceFor <CommonViewNamespaces>().Value.As <CommonViewNamespaces>(); useNamespaces.Namespaces.Each(x => Debug.WriteLine(x)); useNamespaces.Namespaces.ShouldHaveTheSameElementsAs(new[] { typeof(VirtualPathUtility).Namespace, typeof(string).Namespace, typeof(FileSet).Namespace, typeof(ParallelQuery).Namespace, typeof(HtmlTag).Namespace, "Foo", "Bar", }); }
public void when_auto_import_is_true_namespaces_are_added() { var graph = BehaviorGraph.BuildFrom(_registry); var commonViewNamespaces = graph.Settings.Get <CommonViewNamespaces>(); commonViewNamespaces.Namespaces.ShouldHaveTheSameElementsAs("FubuMVC.Core.View.Testing", "FakeTestNamespaceForAutoImport"); }
public void policies_can_be_applied_locally() { var graph = BehaviorGraph.BuildFrom(x => { x.Import <BlueRegistry>(); x.Import <GreenRegistry>(); x.Policies.ChainSource <ImportHandlers>(); // This would be here by Bottles normally }); var cache = new ChainResolutionCache(new TypeResolver(), graph); cache.FindUniqueByType(typeof(Message1)).IsWrappedBy(typeof(GreenWrapper)).ShouldBeTrue(); cache.FindUniqueByType(typeof(Message2)).IsWrappedBy(typeof(GreenWrapper)).ShouldBeTrue(); cache.FindUniqueByType(typeof(Message3)).IsWrappedBy(typeof(GreenWrapper)).ShouldBeTrue(); cache.FindUniqueByType(typeof(Message4)).IsWrappedBy(typeof(GreenWrapper)).ShouldBeFalse(); cache.FindUniqueByType(typeof(Message5)).IsWrappedBy(typeof(GreenWrapper)).ShouldBeFalse(); cache.FindUniqueByType(typeof(Message6)).IsWrappedBy(typeof(GreenWrapper)).ShouldBeFalse(); cache.FindUniqueByType(typeof(Message1)).IsWrappedBy(typeof(BlueWrapper)).ShouldBeFalse(); cache.FindUniqueByType(typeof(Message2)).IsWrappedBy(typeof(BlueWrapper)).ShouldBeFalse(); cache.FindUniqueByType(typeof(Message3)).IsWrappedBy(typeof(BlueWrapper)).ShouldBeFalse(); cache.FindUniqueByType(typeof(Message4)).IsWrappedBy(typeof(BlueWrapper)).ShouldBeTrue(); cache.FindUniqueByType(typeof(Message5)).IsWrappedBy(typeof(BlueWrapper)).ShouldBeTrue(); cache.FindUniqueByType(typeof(Message6)).IsWrappedBy(typeof(BlueWrapper)).ShouldBeTrue(); }
public void SetUp() { FubuMode.Reset(); verboseGraph = BehaviorGraph.BuildFrom(r => { r.AlterSettings <DiagnosticsSettings>(x => { x.TraceLevel = TraceLevel.Verbose; }); }); productionGraph = BehaviorGraph.BuildFrom(r => { r.AlterSettings <DiagnosticsSettings>(x => { x.TraceLevel = TraceLevel.Production; }); }); noneGraph = BehaviorGraph.BuildFrom(r => { r.AlterSettings <DiagnosticsSettings>(x => { x.TraceLevel = TraceLevel.None; }); }); }