/// <summary> /// Creates a new BehaviorChain for an action method /// </summary> /// <typeparam name = "T"></typeparam> /// <param name = "expression"></param> /// <returns></returns> public static RoutedChain For <T>(Expression <Action <T> > expression, string url) { var call = ActionCall.For(expression); var chain = new RoutedChain(new RouteDefinition(url), call.InputType(), call.ResourceType()); chain.AddToEnd(call); return(chain); }
public void apply_a_custome_exclusion_and_it_does_not_apply_to_login_page() { var settings = new AuthenticationSettings(); var chain = new RoutedChain("foo"); chain.AddToEnd(ActionCall.For<LoginController>(x => x.get_login(null))); settings.ShouldBeExcluded(chain).ShouldBeTrue(); settings.ExcludeChains = c => c.Calls.Count() == 5; // just need a fake settings.ShouldBeExcluded(chain).ShouldBeTrue(); }
public void SetUp() { var registry = new FubuRegistry(); 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); }); registry.Features.Diagnostics.Enable(TraceLevel.Verbose); BehaviorGraph.BuildFrom(registry); }
public void do_nothing_if_tracing_is_off() { var registry = new FubuRegistry(); registry.Features.Diagnostics.Enable(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.Chains.SelectMany(x => x).Any(x => x is BehaviorTracerNode).ShouldBeFalse(); }
public void apply_a_custom_exclusion() { var chain = new RoutedChain("foo"); chain.AddToEnd(ActionCall.For<AuthenticatedEndpoints>(x => x.get_tag())); var settings = new AuthenticationSettings(); settings.ShouldBeExcluded(chain).ShouldBeFalse(); settings.ExcludeChains = c => typeof (HtmlTag) == c.ResourceType(); settings.ShouldBeExcluded(chain).ShouldBeTrue(); }
public void behavior_tracers_deeper() { var node = Wrapper.For<SimpleBehavior>(); var chain = new RoutedChain("foo"); chain.AddToEnd(node); node.AddAfter(Wrapper.For<DifferentBehavior>()); ApplyTracing.ApplyToChain(chain); var objectDef = chain.As<IContainerModel>().ToObjectDef().FindDependencyDefinitionFor<IActionBehavior>(); objectDef.Type.ShouldEqual(typeof(BehaviorTracer)); var child1 = objectDef.FindDependencyDefinitionFor<IActionBehavior>(); child1.Type.ShouldEqual(typeof(SimpleBehavior)); var child2 = child1.FindDependencyDefinitionFor<IActionBehavior>(); child2.Type.ShouldEqual(typeof(BehaviorTracer)); var child3 = child2.FindDependencyDefinitionFor<IActionBehavior>(); child3.Type.ShouldEqual(typeof(DifferentBehavior)); }
public void automatically_excludes_the_NotAuthenticated_attribute() { var chain = new RoutedChain("foo"); chain.AddToEnd(ActionCall.For<AuthenticatedEndpoints>(x => x.get_notauthenticated())); new AuthenticationSettings().ShouldBeExcluded(chain) .ShouldBeTrue(); }
public void exclude_by_default_if_the_input_type_is_marked_as_NotAuthenticated() { var chain = new RoutedChain("bar"); chain.AddToEnd(ActionCall.For<AuthenticatedEndpoints>(x => x.post_something(null))); var settings = new AuthenticationSettings(); settings.ShouldBeExcluded(chain).ShouldBeTrue(); }
public void exclude_by_default_actions_marked_as_pass_through() { var chain = new RoutedChain("foo"); chain.AddToEnd(ActionCall.For<AuthenticatedEndpoints>(x => x.get_pass_through_authentication())); var settings = new AuthenticationSettings(); settings.ShouldBeExcluded(chain).ShouldBeTrue(); }