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();
        }
예제 #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);
        }
예제 #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);
            }
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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();
        }
예제 #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();
        }
예제 #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
         });
     }
 }
예제 #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");
        }
예제 #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");
        }
예제 #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();
        }
예제 #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;
        }
예제 #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();
        }
예제 #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();
        }
예제 #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;
        }
예제 #22
0
        public static void Modify(BehaviorChain chain)
        {
            if (chain.OfType <OutputCachingNode>().Any())
            {
                return;
            }

            chain.AddToEnd(new OutputCachingNode());
        }
예제 #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);
        }
예제 #24
0
        public void SetUp()
        {
            inner = Wrapper.For<SimpleBehavior>();
            chain = new BehaviorChain();

            chain.AddToEnd(inner);

            theNode = new DiagnosticNode(chain);
        }
예제 #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();
        }
예제 #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();
        }
예제 #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();
        }
예제 #28
0
        public void SetUp()
        {
            inner = Wrapper.For <SimpleBehavior>();
            chain = new BehaviorChain();

            chain.AddToEnd(inner);

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

            chain.AddToEnd(cacheNode);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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();
        }
예제 #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();
        }
예제 #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);
        }
예제 #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));
        }
예제 #37
0
        public void SetUp()
        {
            inner = Wrapper.For<SimpleBehavior>();
            chain = new BehaviorChain();

            chain.AddToEnd(inner);

            theNode = new BehaviorTracerNode(inner);
        }
예제 #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);
        }
예제 #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);
        }
예제 #40
0
        public void SetUp()
        {
            inner = Wrapper.For <SimpleBehavior>();
            chain = new BehaviorChain();

            chain.AddToEnd(inner);

            theNode = new DiagnosticNode(chain);
        }
예제 #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);
 }
예제 #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);
        }
예제 #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();
        }
예제 #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();
        }
예제 #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);
        }
예제 #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();
        }
예제 #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);
        }
예제 #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);
        }
예제 #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();
        }
예제 #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");
        }
예제 #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>();
        }
예제 #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);
                   });
 }
예제 #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);
        }
예제 #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));
        }