public void Title_if_there_is_no_route_no_action_but_a_writer()
        {
            var chain = BehaviorChain.ForWriter(new FakeWriterNode());

            new ChainVisualization
            {
                Report = new RouteReport(chain, null, null),
                Chain  = chain
            }.Title.ShouldEqual("Fake Writer");
        }
Beispiel #2
0
        public void Configure(BehaviorGraph graph)
        {
            graph.Settings.Get <ViewBag>()
            .Views
            .Where(token => _viewTokenFilter(token))
            .Each(token =>
            {
                var chain = BehaviorChain.ForWriter(new ViewNode(token));
                graph.AddChain(chain);

                _configureChain(chain, token);
            });
        }
        public void should_build_a_route_for_view_model_marked_with_UrlPattern()
        {
            var graph = BehaviorGraph.BuildFrom(x =>
            {
                x.Configure(g =>
                {
                    g.AddChain(BehaviorChain.ForWriter(new FooWriter()));
                });
            });

            var chain = graph.Behaviors.First(x => x.ResourceType() == typeof(Foo));

            chain.Route.Pattern.ShouldEqual("foo/{Name}");

            chain.Route.Input.ShouldBeOfType <RouteInput <Foo> >()
            .RouteParameters.Single().Name.ShouldEqual("Name");
        }
        public void Configure(BehaviorGraph graph)
        {
            var attachedViews = graph.Behaviors
                                .Where(x => x.HasOutput())
                                .SelectMany(x => x.Output.Writers.OfType <ViewNode>())
                                .Select(x => x.View).ToList();

            var unattached = graph.Settings.Get <ViewEngines>().Views.Views.Where(x => x.ViewModel != null && !attachedViews.Contains(x));

            unattached.Each(v =>
            {
                var chain           = BehaviorChain.ForWriter(new ViewNode(v));
                chain.IsPartialOnly = true;

                graph.AddChain(chain);
            });
        }
        public void applies_to_resource_type_marked_as_Cache_on_writer_only_chains()
        {
            var graph = BehaviorGraph.BuildFrom(x =>
            {
                x.Actions.IncludeClassesSuffixedWithController(); // Just making it not use SomeEndpoint

                x.Configure(g =>
                {
                    var chain = BehaviorChain.ForWriter(new CachedResourceWriter());
                    g.AddChain(chain);
                });
            });

            var chain2 = graph.Behaviors.Single(x => x.ResourceType() == typeof(CachedResource));

            var node = chain2.OfType <OutputCachingNode>().Single();

            node.VaryByPolicies().Single().ShouldEqual(typeof(VaryByThreadCulture));
        }
Beispiel #6
0
 public void SetUp()
 {
     theWriter = new WriteHtml(typeof(HtmlTag));
     theChain  = BehaviorChain.ForWriter(theWriter);
 }