Exemplo n.º 1
0
        public void calls_finds_all_calls_underneath_the_chain()
        {
            var chain = new BehaviorChain();
            ActionCall call = ActionCall.For<TestController>(x => x.AnotherAction(null));
            ActionCall call2 = ActionCall.For<TestController>(x => x.AnotherAction(null));
            chain.Append(call);
            chain.Append(call2);

            chain.Calls.Count().ShouldEqual(2);
            chain.Calls.Contains(call).ShouldBeTrue();
            chain.Calls.Contains(call2).ShouldBeTrue();
        }
Exemplo n.º 2
0
        public void write_with_multiple_outputs()
        {
            var chain = new BehaviorChain();
            var json = new RenderJsonNode(typeof (RouteInput));
            chain.Append(json);

            var text = new RenderTextNode<RouteInput>();
            chain.Append(text);

            var tag = new HtmlTag("td");

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

            tag.Text().ShouldEqual(json.Description + ", " + text.Description);
        }
Exemplo n.º 3
0
        public void write_body_cell_with_multiple_calls()
        {
            var chain = new BehaviorChain();
            ActionCall call1 = ActionCall.For<TargetController>(x => x.Go());
            chain.Append(call1);

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

            var column = new ActionColumn();

            var tag = new HtmlTag("td");

            column.WriteBody(chain, tag);

            tag.Text().ShouldEqual(call1.Description + ", " + call2.Description);
        }
Exemplo n.º 4
0
        public void append_with_no_behaviors()
        {
            var chain = new BehaviorChain();
            var wrapper = new Wrapper(typeof (ObjectDefInstanceTester.FakeJsonBehavior));

            chain.Append(wrapper);

            chain.Top.ShouldBeTheSameAs(wrapper);
        }
Exemplo n.º 5
0
        public void write_body_for_chain_with_input_type()
        {
            var chain = new BehaviorChain();
            chain.Append(ActionCall.For<ControllerTarget>(x => x.OneInOneOut(null)));
            var tag = new HtmlTag("td");

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

            tag.Text().ShouldEqual(typeof (Model1).Name);
            tag.Title().ShouldEqual(typeof (Model1).AssemblyQualifiedName);
        }
Exemplo n.º 6
0
        public void prepend_with_an_existing_top_behavior()
        {
            var chain = new BehaviorChain();
            ActionCall call = ActionCall.For<TestController>(x => x.AnotherAction(null));
            chain.Append(call);

            var wrapper = new Wrapper(typeof (ObjectDefInstanceTester.FakeJsonBehavior));
            chain.Prepend(wrapper);

            chain.Top.ShouldBeTheSameAs(wrapper);
            wrapper.Next.ShouldBeTheSameAs(call);
        }
Exemplo n.º 7
0
        public void has_input()
        {
            var chain = new BehaviorChain();
            chain.HasInput().ShouldBeFalse();

            chain.Append(ActionCall.For<ControllerTarget>(x => x.ZeroInOneOut()));
            chain.HasInput().ShouldBeFalse();

            chain = new BehaviorChain();
            chain.Append(ActionCall.For<ControllerTarget>(x => x.OneInOneOut(null)));
            chain.HasInput().ShouldBeTrue();
        }
Exemplo n.º 8
0
        public void write_with_a_single_output()
        {
            var chain = new BehaviorChain();
            var node = new RenderJsonNode(typeof (RouteInput));
            chain.Append(node);

            var tag = new HtmlTag("td");

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

            tag.Text().ShouldEqual(node.Description);
        }
Exemplo n.º 9
0
        public void write_body_cell_with_only_one_call()
        {
            var chain = new BehaviorChain();
            ActionCall call = ActionCall.For<TargetController>(x => x.Go());
            chain.Append(call);

            var column = new ActionColumn();

            var tag = new HtmlTag("td");

            column.WriteBody(chain, tag);

            tag.Text().ShouldEqual(call.Description);
        }
Exemplo n.º 10
0
        public void insert_before_on_a_node()
        {
            var chain = new BehaviorChain();
            var wrapper = new Wrapper(typeof (ObjectDefInstanceTester.FakeJsonBehavior));

            chain.Append(wrapper);

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

            wrapper.InsertDirectlyBefore(wrapper2);

            chain.Top.ShouldBeTheSameAs(wrapper2);
            wrapper2.Next.ShouldBeTheSameAs(wrapper);

            wrapper2.Previous.ShouldBeTheSameAs(chain);
            wrapper.Previous.ShouldBeTheSameAs(wrapper2);
        }
Exemplo n.º 11
0
        public void setting_next_on_a_node_also_sets_the_previous()
        {
            var chain = new BehaviorChain();
            var wrapper = new Wrapper(typeof (ObjectDefInstanceTester.FakeJsonBehavior));

            chain.Append(wrapper);

            wrapper.Previous.ShouldBeTheSameAs(chain);

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

            wrapper.Append(wrapper2);

            wrapper2.Previous.ShouldBeTheSameAs(wrapper);
            wrapper.Previous.ShouldBeTheSameAs(chain);
        }
Exemplo n.º 12
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.Append(call);

            chain.UniqueId.ToString().ShouldEqual(chain.ToObjectDef().Name);
        }
Exemplo n.º 13
0
 private void registerBehavior(ActionCall call)
 {
     var chain = new BehaviorChain();
     chain.Append(call);
     _graph.AddChain(chain);
 }