public void append_when_next_is_null() { action = ActionCall.For<ControllerTarget>(x => x.OneInOneOut(null)); var next = new RenderJsonNode(typeof (Model2)); action.AddToEnd(next); action.Next.ShouldBeTheSameAs(next); }
public bool Equals(RenderJsonNode other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(other._modelType, _modelType)); }
public void enrich_puts_the_new_chain_node_directly_behind_the_call() { action = ActionCall.For<ControllerTarget>(x => x.OneInOneOut(null)); var next = new RenderJsonNode(typeof (Model2)); action.AddToEnd(next); var enricher = new Wrapper(typeof (string)); action.AddAfter(enricher); action.Next.ShouldBeTheSameAs(enricher); enricher.Next.ShouldBeTheSameAs(next); }
public void write_with_a_single_output() { var chain = new BehaviorChain(); var node = new RenderJsonNode(typeof (RouteParameter)); chain.AddToEnd(node); var tag = new HtmlTag("td"); var column = new OutputColumn(); column.WriteBody(chain, null, tag); tag.Text().ShouldEqual(node.Description); }
public void append_to_descendent_when_next_is_not_null() { action = ActionCall.For<ControllerTarget>(x => x.OneInOneOut(null)); var wrapper = new Wrapper(typeof (FakeBehavior)); action.AddAfter(wrapper); var next = new RenderJsonNode(typeof (Model2)); action.AddToEnd(next); action.Next.ShouldBeTheSameAs(wrapper); wrapper.Next.ShouldBeTheSameAs(next); action.ShouldHaveTheSameElementsAs(wrapper, next); }
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); }
public void Configure(BehaviorGraph graph) { graph.Actions().Where(x => x.HasOutputBehavior() && x.OutputType().CanBeCastTo<IEnumerable>() && getRenderViewNode(x) != null) .Each(x => { var modelType = x.OutputType(); var view = getRenderViewNode(x); var json = new RenderJsonNode(modelType); var xml = new RenderXmlNode(modelType); var variableOut = new VariableOutputNode(); view.ReplaceWith(variableOut); variableOut.AddOutput(a => a.RenderFormat == "json", json); variableOut.AddOutput(a => a.RenderFormat == "xml", xml); variableOut.AddOutput(a => a.AcceptsFormat("text/html"), view); variableOut.AddOutput(a => a.AcceptsFormat("application/xml"), xml); variableOut.AddOutput(a => a.AcceptsFormat("application/json"), json); graph.Observer.RecordCallStatus(x, "Adding variable output behavior"); }); }
public void Configure(BehaviorGraph graph) { graph.Actions().Where(x => x.HasOutputBehavior() && x.OutputType().CanBeCastTo<IEnumerable>()) .Each(x => { OutputNode output = null; var modelType = x.OutputType(); var view = getRenderViewNode(x); if (x.HasOutputBehavior()) { output = view ?? x.OfType<OutputNode>().FirstOrDefault(); } var json = new RenderJsonNode(modelType); var variableOut = new VariableOutputNode(); if (output != null) output.ReplaceWith(variableOut); else { x.AddToEnd(variableOut); } variableOut.AddOutput(a => a.RenderFormat == "json", json); variableOut.AddOutput(a => a.AcceptsFormat("application/json"), json); variableOut.AddOutput(a => a.AcceptsFormat("text/javascript"), json); if (view != null) { variableOut.AddOutput(a => a.AcceptsFormat("text/html"), view); variableOut.AddOutput(a => a.AcceptsFormat("*/*"), view); } graph.Observer.RecordCallStatus(x, "Adding variable output behavior"); }); graph.Actions().Where(x => x.OutputType().CanBeCastTo<IReturnJson>()) .Each(x => { OutputNode output = null; var view = getRenderViewNode(x); if (x.HasOutputBehavior()) { output = view ?? x.OfType<OutputNode>().FirstOrDefault(); } var modelType = x.OutputType(); var json = new CustomRenderJsonNode(modelType); var variableOut = new VariableOutputNode(); if (output != null) output.ReplaceWith(variableOut); else { x.AddToEnd(variableOut); } variableOut.AddOutput(a => a.RenderFormat == "json", json); variableOut.AddOutput(a => a.AcceptsFormat("application/json"), json); variableOut.AddOutput(a => a.AcceptsFormat("text/javascript"), json); if (view != null) { variableOut.AddOutput(a => a.AcceptsFormat("text/html"), view); variableOut.AddOutput(a => a.AcceptsFormat("*/*"), view); } graph.Observer.RecordCallStatus(x, "Adding variable output behavior"); }); }
public bool Equals(RenderJsonNode other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other._modelType, _modelType); }
public void SetUp() { node = new RenderJsonNode(typeof(FakeJsonModel)); }