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 BehaviorChain();
                chain1.AddToEnd(Wrapper.For<SimpleBehavior>());
                chain1.AddToEnd(Wrapper.For<DifferentBehavior>());
                chain1.Route = new RouteDefinition("something");
                graph.AddChain(chain1);

                chain2 = new BehaviorChain();
                chain2.IsPartialOnly = true;
                chain2.AddToEnd(Wrapper.For<SimpleBehavior>());
                chain2.AddToEnd(Wrapper.For<DifferentBehavior>());
                graph.AddChain(chain2);
            });


            registry.Policies.Add<ApplyTracing>();

            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();
        }
Ejemplo n.º 2
0
        public void but_does_match_the_last_call()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<ActionEndpoint>(x => x.get_hello()));
            chain.AddToEnd(ActionCall.For<ActionEndpoint>(x => x.SaySomethingHTML()));

            var match = new LastActionMatch(call => call.Method.Name.EndsWith("HTML"));
            match.Matches(chain).ShouldBeTrue();
        }
        public void modifies_a_chain()
        {
            var chain = new BehaviorChain();
            var theAction = ActionCall.For<AjaxController>(x => x.get_success());
            chain.AddToEnd(theAction);
            chain.AddToEnd(chain.Output.As<OutputNode>());

            OutputBeforeAjaxContinuationPolicy.Modify(chain);

            chain.First().ShouldBeTheSameAs(chain.Output);
            chain.Last().ShouldBeTheSameAs(theAction);
        }
Ejemplo n.º 4
0
        public void calls_finds_all_calls_underneath_the_chain()
        {
            var chain = new BehaviorChain();
            var call = ActionCall.For<TestController>(x => x.AnotherAction(null));
            var call2 = ActionCall.For<TestController>(x => x.AnotherAction(null));
            chain.AddToEnd(call);
            chain.AddToEnd(call2);

            chain.Calls.Count().ShouldEqual(2);
            chain.Calls.Contains(call).ShouldBeTrue();
            chain.Calls.Contains(call2).ShouldBeTrue();
        }
        public void Configure(BehaviorGraph graph)
        {
            if (!graph.Behaviors.Any(x => x.Route != null && x.GetRoutePattern().IsEmpty()))
            {
                var action = ActionCall.For<DefaultHome>(x => x.GoToDiagnostics());
                var continuer = new ContinuationNode();

                var chain = new BehaviorChain();
                chain.Route = new RouteDefinition("");
                chain.AddToEnd(action);
                chain.AddToEnd(continuer);

                graph.AddChain(chain);
            }
        }
Ejemplo n.º 6
0
        public void appending_a_node_also_sets_the_previous_2()
        {
            var chain = new BehaviorChain();
            var wrapper = new Wrapper(typeof (ObjectDefInstanceTester.FakeJsonBehavior));

            chain.AddToEnd(wrapper);

            wrapper.Previous.ShouldBeTheSameAs(chain);

            var wrapper2 = new Wrapper(typeof (ObjectDefInstanceTester.FakeJsonBehavior));

            chain.AddToEnd(wrapper2);

            wrapper2.Previous.ShouldBeTheSameAs(wrapper);
            wrapper.Previous.ShouldBeTheSameAs(chain);
        }
Ejemplo n.º 7
0
        public void write_with_multiple_outputs()
        {
            var chain = new BehaviorChain();
            var json = new RenderJsonNode(typeof (RouteParameter));
            chain.AddToEnd(json);

            var text = new RenderTextNode<RouteParameter>();
            chain.AddToEnd(text);

            var tag = new HtmlTag("td");

            var column = new OutputColumn();
            column.WriteBody(chain, null, tag);

            tag.Text().ShouldEqual(json.Description + ", " + text.Description);
        }
Ejemplo n.º 8
0
        public void find_the_parent_chain_when_the_chain_is_the_immediate_parent()
        {
            var chain = new BehaviorChain();
            var node  = new Wrapper(typeof(ObjectDefInstanceTester.FakeJsonBehavior));

            chain.AddToEnd(node);
            node.ParentChain().ShouldBeTheSameAs(chain);
        }
Ejemplo n.º 9
0
        public void does_not_blow_up_if_there_is_no_resource_type()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<SomeEndpoints>(x => x.post_no_resource(null)));

            new ResourceTypeImplements<ISomeInterface>()
                .Matches(chain).ShouldBeFalse();
        }
Ejemplo n.º 10
0
        public void matches_positive()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<SomeEndpoints>(x => x.get_interface()));

            new ResourceTypeImplements<ISomeInterface>()
                .Matches(chain).ShouldBeTrue();
        }
Ejemplo n.º 11
0
 private void applyChrome(BehaviorChain chain)
 {
     if (Key.EndsWith("/splash"))
     {
         chain.AddToEnd(new ChromeNode(typeof(SplashChrome))
         {
             Title = () => Title
         });
     }
     else
     {
         chain.AddToEnd(new ChromeNode(typeof(TopicChrome))
         {
             Title = () => Title
         });
     }
 }
Ejemplo n.º 12
0
        public void return_description_if_first_call_is_not_null()
        {
            var chain = new BehaviorChain();
            var type  = typeof(ControllerTarget);

            chain.AddToEnd(new ActionCall(type, type.GetMethod("OneInZeroOut")));
            chain.FirstCallDescription().ShouldEqual("ControllerTarget.OneInZeroOut(Model1 input) : void");
        }
Ejemplo n.º 13
0
        public void returns_input_type_name_if_first_call_is_not_null()
        {
            var chain = new BehaviorChain();
            var type  = typeof(ControllerTarget);

            chain.AddToEnd(new ActionCall(type, type.GetMethod("OneInOneOut")));
            chain.GetInputTypeName().ShouldEqual("Model1");
        }
Ejemplo n.º 14
0
        public void matches_negative()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<SomeEndpoints>(x => x.post_no_interface(null)));

            new InputTypeImplements<ISomeInterface>()
                .Matches(chain).ShouldBeFalse();
        }
Ejemplo n.º 15
0
        public void does_not_blow_up_if_there_is_no_input_type()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<SomeEndpoints>(x => x.get_interface()));

            new InputTypeImplements<ISomeInterface>()
                .Matches(chain).ShouldBeFalse();
        }
        public void SetUp()
        {
            theChain = new BehaviorChain();
            var action = ActionCall.For<Controller1>(x => x.Go(null));
            theChain.AddToEnd(action);

            theOriginalGuid = action.UniqueId;
        }
Ejemplo n.º 17
0
        public void matches_negative_with_one_action()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<ActionEndpoint>(x => x.get_hello()));

            var match = new LastActionMatch(call => call.Method.Name.EndsWith("HTML"));
            match.Matches(chain).ShouldBeFalse();
        }
Ejemplo n.º 18
0
        public void matches_positive_with_one_action()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<ActionEndpoint>(x => x.SaySomethingHTML()));

            var match = new LastActionMatch(call => call.Method.Name.EndsWith("HTML"));
            match.Matches(chain).ShouldBeTrue();
        }
        public void automatically_excludes_the_NotAuthenticated_attribute()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<AuthenticatedEndpoints>(x => x.get_notauthenticated()));

            new AuthenticationSettings().ShouldBeExcluded(chain)
                .ShouldBeTrue();
        }
Ejemplo n.º 20
0
        public void write_body_cell_with_multiple_calls()
        {
            var chain = new BehaviorChain();
            ActionCall call1 = ActionCall.For<TargetController>(x => x.Go());
            chain.AddToEnd(call1);

            ActionCall call2 = ActionCall.For<TargetController>(x => x.GoWithInput(null));
            chain.AddToEnd(call2);

            var column = new ActionColumn();

            var tag = new HtmlTag("td");

            column.WriteBody(chain, null, tag);

            tag.Text().ShouldEqual(call1.Description + ", " + call2.Description);
        }
        public void SetUp()
        {
            theChain = new BehaviorChain();
            var action = ActionCall.For <Controller1>(x => x.Go(null));

            theChain.AddToEnd(action);

            theOriginalGuid = action.UniqueId;
        }
Ejemplo n.º 22
0
        public static void Modify(BehaviorChain chain)
        {
            if (chain.OfType <OutputCachingNode>().Any())
            {
                return;
            }

            chain.AddToEnd(new OutputCachingNode());
        }
Ejemplo n.º 23
0
        public void the_unique_id_of_the_behavior_chain_matches_the_object_def_name()
        {
            var        chain = new BehaviorChain();
            ActionCall call  = ActionCall.For <TestController>(x => x.AnotherAction(null));

            chain.AddToEnd(call);

            chain.UniqueId.ToString().ShouldEqual(chain.ToObjectDef().Name);
        }
Ejemplo n.º 24
0
        public void SetUp()
        {
            inner = Wrapper.For<SimpleBehavior>();
            chain = new BehaviorChain();

            chain.AddToEnd(inner);

            theNode = new DiagnosticNode(chain);
        }
Ejemplo n.º 25
0
        public void matches_positive()
        {
            var chain = new BehaviorChain();

            chain.AddToEnd(ActionCall.For <SomeEndpoints>(x => x.get_interface()));

            new ResourceTypeImplements <ISomeInterface>()
            .Matches(chain).ShouldBeTrue();
        }
Ejemplo n.º 26
0
        public void does_not_blow_up_if_there_is_no_resource_type()
        {
            var chain = new BehaviorChain();

            chain.AddToEnd(ActionCall.For <SomeEndpoints>(x => x.post_no_resource(null)));

            new ResourceTypeImplements <ISomeInterface>()
            .Matches(chain).ShouldBeFalse();
        }
Ejemplo n.º 27
0
        public void automatically_excludes_the_NotAuthenticated_attribute()
        {
            var chain = new BehaviorChain();

            chain.AddToEnd(ActionCall.For <AuthenticatedEndpoints>(x => x.get_notauthenticated()));

            new AuthenticationSettings().ShouldBeExcluded(chain)
            .ShouldBeTrue();
        }
Ejemplo n.º 28
0
        public void SetUp()
        {
            inner = Wrapper.For <SimpleBehavior>();
            chain = new BehaviorChain();

            chain.AddToEnd(inner);

            theNode = new BehaviorTracerNode(inner);
        }
Ejemplo n.º 29
0
        private void addCaching(BehaviorChain chain)
        {
            var cacheNode = new OutputCachingNode {
                ETagCache   = ObjectDef.ForValue(_assetCache),
                OutputCache = ObjectDef.ForValue(_assetCache)
            };

            chain.AddToEnd(cacheNode);
        }
Ejemplo n.º 30
0
        public void append_with_no_behaviors()
        {
            var chain   = new BehaviorChain();
            var wrapper = new Wrapper(typeof(ObjectDefInstanceTester.FakeJsonBehavior));

            chain.AddToEnd(wrapper);

            chain.Top.ShouldBeTheSameAs(wrapper);
        }
Ejemplo n.º 31
0
        public void append_with_no_behaviors()
        {
            var chain = new BehaviorChain();
            var wrapper = new Wrapper(typeof (ObjectDefInstanceTester.FakeJsonBehavior));

            chain.AddToEnd(wrapper);

            chain.Top.ShouldBeTheSameAs(wrapper);
        }
Ejemplo n.º 32
0
        public void does_not_blow_up_if_there_is_no_input_type()
        {
            var chain = new BehaviorChain();

            chain.AddToEnd(ActionCall.For <SomeEndpoints>(x => x.get_interface()));

            new InputTypeImplements <ISomeInterface>()
            .Matches(chain).ShouldBeFalse();
        }
Ejemplo n.º 33
0
        public void matches_negative()
        {
            var chain = new BehaviorChain();

            chain.AddToEnd(ActionCall.For <SomeEndpoints>(x => x.post_no_interface(null)));

            new InputTypeImplements <ISomeInterface>()
            .Matches(chain).ShouldBeFalse();
        }
Ejemplo n.º 34
0
        private static void addReloadedEndpoint(BehaviorGraph graph)
        {
            var action = ActionCall.For<AboutEndpoint>(x => x.get__loaded());
            var chain = new BehaviorChain();
            chain.AddToEnd(action);
            chain.Route = new RouteDefinition("_loaded");

            graph.AddChain(chain);
        }
Ejemplo n.º 35
0
        public void adding_a_node_to_the_end_sets_the_chain_on_the_node()
        {
            var chain = new BehaviorChain();
            var wrapper = new Wrapper(typeof(ObjectDefInstanceTester.FakeJsonBehavior));

            chain.AddToEnd(wrapper);

            wrapper.ParentChain().ShouldBeTheSameAs(chain);
        }
        public void the_remove_method_puts_a_node_removed_event_on_the_chain()
        {
            var chain = new BehaviorChain();

            chain.AddToEnd(new SimpleNode());

            var nodeToBeRemoved = new SimpleNode();

            chain.AddToEnd(nodeToBeRemoved);

            chain.AddToEnd(new SimpleNode());
            chain.AddToEnd(new SimpleNode());

            nodeToBeRemoved.Remove();

            chain.As <ITracedModel>().StagedEvents.Last()
            .ShouldEqual(new NodeRemoved(nodeToBeRemoved));
        }
Ejemplo n.º 37
0
        public void SetUp()
        {
            inner = Wrapper.For<SimpleBehavior>();
            chain = new BehaviorChain();

            chain.AddToEnd(inner);

            theNode = new BehaviorTracerNode(inner);
        }
Ejemplo n.º 38
0
        public void appending_a_node_also_sets_the_previous_2()
        {
            var chain   = new BehaviorChain();
            var wrapper = new Wrapper(typeof(ObjectDefInstanceTester.FakeJsonBehavior));

            chain.AddToEnd(wrapper);

            wrapper.Previous.ShouldBeNull();
            wrapper.ParentChain().ShouldBeTheSameAs(chain);

            var wrapper2 = new Wrapper(typeof(ObjectDefInstanceTester.FakeJsonBehavior));

            chain.AddToEnd(wrapper2);

            wrapper2.Previous.ShouldBeTheSameAs(wrapper);
            wrapper.Previous.ShouldBeNull();
            wrapper.ParentChain().ShouldBeTheSameAs(chain);
        }
Ejemplo n.º 39
0
        private BehaviorChain chainWithOutput <T>(IViewToken token) where T : class
        {
            var chain = new BehaviorChain();

            chain.AddToEnd(ActionCall.For <StubController <T> >(x => x.Post(null)));
            chain.Output.Writers.AddToEnd(new ViewNode(token));

            return(chain);
        }
Ejemplo n.º 40
0
        public void SetUp()
        {
            inner = Wrapper.For <SimpleBehavior>();
            chain = new BehaviorChain();

            chain.AddToEnd(inner);

            theNode = new DiagnosticNode(chain);
        }
Ejemplo n.º 41
0
        private bool matches <T>(Expression <Func <T, object> > expression)
        {
            var call  = ActionCall.For(expression);
            var chain = new BehaviorChain();

            chain.AddToEnd(call);

            return(new NotValidatedAttributeFilter().Matches(chain));
        }
 public void Configure(BehaviorGraph graph)
 {
     var route = new RouteDefinition("");
     route.AddHttpMethodConstraint("GET");
     var chain = new BehaviorChain { Route = route };
     chain.AddToEnd(new RedirectNode());
     graph.AddChain(chain);
     graph.Services.AddService(this);
 }
Ejemplo n.º 43
0
        public void adding_a_node_to_the_end_sets_the_chain_on_the_node()
        {
            var chain   = new BehaviorChain();
            var wrapper = new Wrapper(typeof(ObjectDefInstanceTester.FakeJsonBehavior));

            chain.AddToEnd(wrapper);

            wrapper.ParentChain().ShouldBeTheSameAs(chain);
        }
Ejemplo n.º 44
0
        public void write_with_multiple_outputs()
        {
            var chain = new BehaviorChain();
            var json  = new OutputNode(typeof(RouteParameter));

            chain.AddToEnd(json);

            var text = new RenderTextNode <RouteParameter>();

            chain.AddToEnd(text);

            var tag = new HtmlTag("td");

            var column = new OutputColumn();

            column.WriteBody(chain, null, tag);

            tag.Text().ShouldEqual(json.Description + ", " + text.Description);
        }
        public void exclude_by_default_if_the_input_type_is_marked_as_NotAuthenticated()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<AuthenticatedEndpoints>(x => x.post_something(null)));


            var settings = new AuthenticationSettings();

            settings.ShouldBeExcluded(chain).ShouldBeTrue();
        }
Ejemplo n.º 46
0
        public void matches_negative_with_one_action()
        {
            var chain = new BehaviorChain();

            chain.AddToEnd(ActionCall.For <ActionEndpoint>(x => x.get_hello()));

            var match = new LastActionMatch(call => call.Method.Name.EndsWith("HTML"));

            match.Matches(chain).ShouldBeFalse();
        }
Ejemplo n.º 47
0
        public void write_body_cell_with_multiple_calls()
        {
            var        chain = new BehaviorChain();
            ActionCall call1 = ActionCall.For <TargetController>(x => x.Go());

            chain.AddToEnd(call1);

            ActionCall call2 = ActionCall.For <TargetController>(x => x.GoWithInput(null));

            chain.AddToEnd(call2);

            var column = new ActionColumn();

            var tag = new HtmlTag("td");

            column.WriteBody(chain, null, tag);

            tag.Text().ShouldEqual(call1.Description + ", " + call2.Description);
        }
Ejemplo n.º 48
0
        public void matches_positive_with_one_action()
        {
            var chain = new BehaviorChain();

            chain.AddToEnd(ActionCall.For <ActionEndpoint>(x => x.SaySomethingHTML()));

            var match = new LastActionMatch(call => call.Method.Name.EndsWith("HTML"));

            match.Matches(chain).ShouldBeTrue();
        }
        public void SetUp()
        {
            theChain      = BehaviorChain.For <ActionJackson>(x => x.OneInOneOut(null));
            theOutputNode = new OutputNode(typeof(OutputBehavior));

            theChain.AddToEnd(theOutputNode);

            // Nothing up my sleeve
            theChain.Any(x => x is ConnegNode).ShouldBeFalse();
        }
Ejemplo n.º 50
0
        public void Configure(BehaviorGraph graph)
        {
            var action = ActionCall.For <AboutEndpoint>(x => x.get__about());
            var chain  = new BehaviorChain();

            chain.AddToEnd(action);
            chain.Route = new RouteDefinition("_about");

            graph.AddChain(chain);
        }
Ejemplo n.º 51
0
        private static void addCaching(BehaviorChain chain, AssetContentCache assetCache)
        {
            var cacheNode = new OutputCachingNode
                            {
                                ETagCache = ObjectDef.ForValue(assetCache),
                                OutputCache = ObjectDef.ForValue(assetCache)
                            };

            chain.AddToEnd(cacheNode);
        }
Ejemplo n.º 52
0
        private static void addReloadedEndpoint(BehaviorGraph graph)
        {
            var action = ActionCall.For <AboutEndpoint>(x => x.get__loaded());
            var chain  = new BehaviorChain();

            chain.AddToEnd(action);
            chain.Route = new RouteDefinition("_loaded");

            graph.AddChain(chain);
        }
        public void apply_a_custome_exclusion_and_it_does_not_apply_to_login_page()
        {
            var settings = new AuthenticationSettings();
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<LoginController>(x => x.get_login(null)));
            settings.ShouldBeExcluded(chain).ShouldBeTrue();
            
            settings.ExcludeChains.ChainMatches(c => c.Calls.Count() == 5); // just need a fake

            settings.ShouldBeExcluded(chain).ShouldBeTrue();
        }
Ejemplo n.º 54
0
 public void Configure(BehaviorGraph graph)
 {
     _sources
     .SelectMany(src => src.FindActions(_types))
     .Each(call =>
     {
         var chain = new BehaviorChain();
         chain.AddToEnd(call);
         graph.AddChain(chain);
     });
 }
        public void Title_if_there_is_no_route_partial_with_controller_action()
        {
            var chain = new BehaviorChain();
            chain.IsPartialOnly = true;
            chain.AddToEnd(ActionCall.For<SomeEndpoint>(x => x.Go()));

            new ChainVisualization{
                Report = new RouteReport(chain, null, null),
                Chain = chain
            }.Title.ShouldEqual("SomeEndpoint.Go() : String");
        }
Ejemplo n.º 56
0
        public void add_a_writer()
        {
            var modification = new AddWriter<WriteString>();

            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<StringEndpoint>(x => x.get_output()));

            modification.Modify(chain);

            chain.Output.Writers.Single().ShouldBeOfType<WriteString>();
        }
Ejemplo n.º 57
0
 public void Configure(BehaviorGraph graph)
 {
     _sources
         .SelectMany(src => src.FindActions(_types))
         .Each(call =>
                   {
                       var chain = new BehaviorChain();
                       chain.AddToEnd(call);
                       graph.AddChain(chain);
                   });
 }
Ejemplo n.º 58
0
        public void write_body_for_chain_with_input_type()
        {
            var chain = new BehaviorChain();
            chain.AddToEnd(ActionCall.For<ControllerTarget>(x => x.OneInOneOut(null)));
            var tag = new HtmlTag("td");

            new InputModelColumn().WriteBody(chain, null, tag);

            tag.Text().ShouldEqual(typeof (Model1).Name);
            tag.Title().ShouldEqual(typeof (Model1).AssemblyQualifiedName);
        }
Ejemplo n.º 59
0
        public void alter_chain_with_more_overridden_vary_by()
        {
            var chain = new BehaviorChain();
            var call = ActionCall.For<CacheAttributeTester>(x => x.alter_chain_with_more_overridden_vary_by());
            chain.AddToEnd(call);

            call.As<IModifiesChain>().Modify(chain);

            chain.OfType<OutputCachingNode>().Single().VaryByPolicies()
                .ShouldHaveTheSameElementsAs(typeof (VaryByResource), typeof (VaryByThreadCulture));
        }